Package org.springframework.web.context.support

Examples of org.springframework.web.context.support.AnnotationConfigWebApplicationContext.scan()


  public void contextInitialized(ServletContextEvent sce) {
    final ServletContext ctx = sce.getServletContext();

    final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext();
    root.setServletContext(ctx);
    root.scan("app");
    root.refresh();

    final Dynamic servlet = ctx.addServlet("spring", new DispatcherServlet(root));
    servlet.setLoadOnStartup(1);
    servlet.addMapping("/");
View Full Code Here


    @Override
    protected WebApplicationContext createWebApplicationContext(ServletContext sc) {
  final AnnotationConfigWebApplicationContext springCtx = new AnnotationConfigWebApplicationContext();
  springCtx.setServletContext(sc);
  springCtx.scan("server");
  springCtx.refresh();

  sc.setAttribute(SPRING_CONTEXT, springCtx);

  return springCtx;
View Full Code Here

public class ServletInitializer extends AbstractDispatcherServletInitializer {

  @Override
  protected WebApplicationContext createServletApplicationContext() {
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.scan(ClassUtils.getPackageName(getClass()));
    return context;
  }

  @Override
  protected String[] getServletMappings() {
View Full Code Here

    @Given("^I have a web application with javaconfig in package \"([^\"]*)\"$")
    public void I_have_a_web_application_with_javaconfig_in_package(String scanPackage) throws Throwable {
        MockServletContext sc = new MockServletContext("");
        AnnotationConfigWebApplicationContext appContext = new AnnotationConfigWebApplicationContext();
        appContext.scan(scanPackage);
        appContext.setServletContext(sc);
        appContext.refresh();

        this.wac = appContext;

View Full Code Here

        parent.refresh();

        AnnotationConfigWebApplicationContext appContext = new AnnotationConfigWebApplicationContext();
        appContext.setParent(parent);
        appContext.scan("com.**.graphaware.**", "org.**.graphaware.**", "net.**.graphaware.**");

        return appContext;
    }

    @Override
View Full Code Here

    public void onStartup(final ServletContext sc) throws ServletException {
        System.out.println("MainWebAppInitializer.onStartup()");

        // Create the 'root' Spring application context
        final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext();
        root.scan("org.baeldung.spring.web.config");
        // root.getEnvironment().setDefaultProfiles("embedded");

        // Manages the lifecycle of the root application context
        sc.addListener(new ContextLoaderListener(root));
View Full Code Here

    public void onStartup(final ServletContext sc) throws ServletException {
        System.out.println("MainWebAppInitializer.onStartup()");

        // Create the 'root' Spring application context
        final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext();
        root.scan("org.baeldung.spring.config");
        // root.getEnvironment().setDefaultProfiles("embedded");

        // Manages the lifecycle of the root application context
        sc.addListener(new ContextLoaderListener(root));
View Full Code Here

    public void onStartup(final ServletContext sc) throws ServletException {
        System.out.println("MyWebAppInitializer.onStartup()");

        // Create the 'root' Spring application context
        final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext();
        root.scan("org.baeldung.config.parent");
        // root.getEnvironment().setDefaultProfiles("embedded");

        // Manages the lifecycle of the root application context
        sc.addListener(new ContextLoaderListener(root));
View Full Code Here

        // Manages the lifecycle of the root application context
        sc.addListener(new ContextLoaderListener(root));

        // Handles requests into the application
        final AnnotationConfigWebApplicationContext childWebApplicationContext = new AnnotationConfigWebApplicationContext();
        childWebApplicationContext.scan("org.baeldung.config.child");
        final ServletRegistration.Dynamic appServlet = sc.addServlet("api", new DispatcherServlet(childWebApplicationContext));
        appServlet.setLoadOnStartup(1);
        final Set<String> mappingConflicts = appServlet.addMapping("/");
        if (!mappingConflicts.isEmpty()) {
            throw new IllegalStateException("'appServlet' could not be mapped to '/' due " + "to an existing mapping. This is a known issue under Tomcat versions " + "<= 7.0.14; see https://issues.apache.org/bugzilla/show_bug.cgi?id=51278");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.