Package org.springframework.web.context.support

Examples of org.springframework.web.context.support.GenericWebApplicationContext


import org.springframework.web.context.support.GenericWebApplicationContext;

public class WebPlaceholderDelegatingContextLoader implements DelegatingContextLoader {

  public ConfigurableApplicationContext loadApplicationContext(ApplicationContext parent, ModuleDefinition definition) {
    GenericWebApplicationContext context = new GenericWebApplicationContext();
    context.refresh();
    return context;
  }
View Full Code Here


  protected ModuleManagementFactory createBootStrapFactory(ServletContext servletContext) {
    String[] locations = getBootstrapContextLocations(servletContext);
    logger.info("Loading bootstrap context from locations " + Arrays.toString(locations));

    final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
    final GenericWebApplicationContext applicationContext = new GenericWebApplicationContext(beanFactory);
    applicationContext.setServletContext(servletContext);

    XmlBeanDefinitionReader definitionReader = new XmlBeanDefinitionReader(beanFactory);
    for (int i = 0; i < locations.length; i++) {
      definitionReader.loadBeanDefinitions(new ClassPathResource(locations[i]));
    }
    applicationContext.refresh();

    return ObjectUtils.cast(applicationContext.getBean("moduleManagementFactory"), ModuleManagementFactory.class);
  }
View Full Code Here

    if (actualLocation == null) {
      actualLocation = getApplicationContext().getResource(DEFAULT_LOCATION);
    }

    // Create child ApplicationContext for views.
    GenericWebApplicationContext factory = new GenericWebApplicationContext();
    factory.setParent(getApplicationContext());
    factory.setServletContext(getServletContext());

    // Load XML resource with context-aware entity resolver.
    XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory);
    reader.setEnvironment(getApplicationContext().getEnvironment());
    reader.setEntityResolver(new ResourceEntityResolver(getApplicationContext()));
    reader.loadBeanDefinitions(actualLocation);

    factory.refresh();

    if (isCache()) {
      this.cachedFactory = factory;
    }
    return factory;
View Full Code Here

  public GenericWebApplicationContext newApplicationContext(ApplicationContext parent,
      ModuleDefinition moduleDefinition, ClassLoader classLoader) {
    final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
    beanFactory.setBeanClassLoader(classLoader);

    final GenericWebApplicationContext context = new GenericWebApplicationContext(beanFactory);
    context.setParent(parent);
    context.setServletContext(servletContext);
    context.setClassLoader(classLoader);

    return context;
  }
View Full Code Here

    }
   
    final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
    beanFactory.setBeanClassLoader(classLoader);

    final GenericWebApplicationContext context = new GenericWebApplicationContext(beanFactory);
    context.setParent(parent);
    context.setServletContext(wrappedServletContext);
    context.setClassLoader(classLoader);

    return context;
  }
View Full Code Here

        return cachedFactory;
      }
    }

    // Create child ApplicationContext for views.
    GenericWebApplicationContext factory = new GenericWebApplicationContext();
    factory.setParent(getApplicationContext());
    factory.setServletContext(getServletContext());

    // Load bean definitions from resource bundle.
    PropertiesBeanDefinitionReader reader = new PropertiesBeanDefinitionReader(factory);
    reader.setDefaultParentBean(this.defaultParentView);
    for (int i = 0; i < bundles.size(); i++) {
      ResourceBundle bundle = (ResourceBundle) bundles.get(i);
      reader.registerBeanDefinitions(bundle);
    }

    factory.refresh();

    // Cache factory for both Locale and ResourceBundle list.
    if (isCache()) {
      this.localeCache.put(locale, factory);
      this.bundleCache.put(bundles, factory);
View Full Code Here

    if (actualLocation == null) {
      actualLocation = getApplicationContext().getResource(DEFAULT_LOCATION);
    }

    // Create child ApplicationContext for views.
    GenericWebApplicationContext factory = new GenericWebApplicationContext();
    factory.setParent(getApplicationContext());
    factory.setServletContext(getServletContext());

    // Load XML resource with context-aware entity resolver.
    XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory);
    reader.setEntityResolver(new ResourceEntityResolver(getApplicationContext()));
    reader.loadBeanDefinitions(actualLocation);

    factory.refresh();

    if (isCache()) {
      this.cachedFactory = factory;
    }
    return factory;
View Full Code Here

    assertEquals(MODIFIED_NAME, bean.getName());
  }


  private ApplicationContext createContext(ScopedProxyMode scopedProxyMode) {
    GenericWebApplicationContext context = new GenericWebApplicationContext();
    ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, false);
    scanner.setIncludeAnnotationConfig(false);
    scanner.addIncludeFilter(new AnnotationTypeFilter(ScopeTestComponent.class));
    scanner.setBeanNameGenerator(new BeanNameGenerator() {
      public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) {
        String beanClassName = ClassUtils.getShortName(definition.getBeanClassName());
        int begin = beanClassName.lastIndexOf('.') + 1;
        int end = beanClassName.lastIndexOf("ScopedTestBean");
        return beanClassName.substring(begin, end).toLowerCase();
      }
    });
    scanner.setScopedProxyMode(scopedProxyMode);

    // Scan twice in order to find errors in the bean definition compatibility check.
    scanner.scan(getClass().getPackage().getName());
    scanner.scan(getClass().getPackage().getName());

    context.refresh();
    return context;
  }
View Full Code Here

public class PortletAnnotationControllerTests extends TestCase {

  public void testStandardHandleMethod() throws Exception {
    DispatcherPortlet portlet = new DispatcherPortlet() {
      protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
        GenericWebApplicationContext wac = new GenericWebApplicationContext();
        wac.registerBeanDefinition("controller", new RootBeanDefinition(MyController.class));
        wac.refresh();
        return wac;
      }
    };
    portlet.init(new MockPortletConfig());
View Full Code Here

  }

  public void doTestAdaptedHandleMethods(final Class controllerClass) throws Exception {
    DispatcherPortlet portlet = new DispatcherPortlet() {
      protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
        GenericWebApplicationContext wac = new GenericWebApplicationContext();
        wac.registerBeanDefinition("controller", new RootBeanDefinition(controllerClass));
        wac.refresh();
        return wac;
      }
    };
    portlet.init(new MockPortletConfig());
View Full Code Here

TOP

Related Classes of org.springframework.web.context.support.GenericWebApplicationContext

Copyright © 2018 www.massapicom. 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.