Examples of GenericApplicationContext


Examples of org.springframework.context.support.GenericApplicationContext

        context.refresh();

        // Have to create a child context that implements BeanDefinitionRegistry
        // to pass to registerAnnotationConfigProcessors, since
        // JavaConfigApplicationContext does not
        final GenericApplicationContext gac = new GenericApplicationContext(context);
        AnnotationConfigUtils.registerAnnotationConfigProcessors(gac);
        // copy BeanPostProcessors to the child context
        for (String bppName : context.getBeanFactory().getBeanNamesForType(BeanPostProcessor.class)) {
            gac.registerBeanDefinition(bppName, context.getBeanFactory().getBeanDefinition(bppName));
        }
        gac.refresh();
        gac.registerShutdownHook();

        return gac;
    }
View Full Code Here

Examples of org.springframework.context.support.GenericApplicationContext

     *
     * @return ApplicationContext a parent {@link ApplicationContext} configured
     *         to exclude certain classes from package scanning
     */
    protected ApplicationContext getRouteExcludingApplicationContext() {
        GenericApplicationContext routeExcludingContext = new GenericApplicationContext();
        routeExcludingContext.registerBeanDefinition("excludingResolver", new RootBeanDefinition(ExcludingPackageScanClassResolver.class));
        routeExcludingContext.refresh();

        ExcludingPackageScanClassResolver excludingResolver = (ExcludingPackageScanClassResolver)routeExcludingContext.getBean("excludingResolver");
        List<Class<?>> excluded = CastUtils.cast(Arrays.asList(excludeRoutes()));
        excludingResolver.setExcludedClasses(new HashSet<Class<?>>(excluded));

        return routeExcludingContext;
    }
View Full Code Here

Examples of org.springframework.context.support.GenericApplicationContext

    /**
     * @return application context
     */
    public ApplicationContext getApplicationContext() {
      if (applicationContext == null) {
        applicationContext = new GenericApplicationContext();
      }
        return applicationContext;
    }
View Full Code Here

Examples of org.springframework.context.support.GenericApplicationContext

     *
     * @param configFile the configuration file to be used
     */
    public SpringConfigExtension(String name, String configFile) {
        setName(name);
        appContext = new GenericApplicationContext();
        XmlBeanDefinitionReader xbdr = new XmlBeanDefinitionReader(appContext);
        xbdr.setValidating(false);
        xbdr.loadBeanDefinitions(new FileSystemResource(configFile));
        appContext.refresh();
    }
View Full Code Here

Examples of org.springframework.context.support.GenericApplicationContext

            System.setProperty("org.apache.cxf.transports.http_jetty.DontClosePort", close);
        }
    }
   
    public void setUpBus(boolean includeService) throws Exception {
        applicationContext = new GenericApplicationContext();
        readBeans(new ClassPathResource("cxf.xml"));
        readBeans(new ClassPathResource("META-INF/cxf/cxf.xml"));
        readBeans(new ClassPathResource("META-INF/cxf/cxf-extension-soap.xml"));
        readBeans(new ClassPathResource("META-INF/cxf/cxf-extension-http.xml"));
        readBeans(new ClassPathResource("META-INF/cxf/cxf-extension-http-jetty.xml"));
View Full Code Here

Examples of org.springframework.context.support.GenericApplicationContext

    @Before
    public void setupBeans() throws Exception {
        if (applicationContext != null) {
            return;
        }
        applicationContext = new GenericApplicationContext();
        resourceLoader = new DefaultResourceLoader(getClass().getClassLoader());
        for (String beanDefinitionPath : getConfigLocations()) {
            XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(applicationContext);
            Resource resource = resourceLoader.getResource(beanDefinitionPath);
            reader.loadBeanDefinitions(resource);
View Full Code Here

Examples of org.springframework.context.support.GenericApplicationContext

      // expected
    }
  }

  public void testDestroy() {
    GenericApplicationContext context = new GenericApplicationContext();
    context.refresh();
    flow.setApplicationContext(context);
    assertTrue(context.isActive());
    flow.destroy();
    assertFalse(context.isActive());
  }
View Full Code Here

Examples of org.springframework.context.support.GenericApplicationContext

* @author Juergen Hoeller
*/
public class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanTests {

  public void testPrivatePersistenceContextField() {
    GenericApplicationContext gac = new GenericApplicationContext();
    gac.getDefaultListableBeanFactory().registerSingleton("entityManagerFactory", mockEmf);
    gac.registerBeanDefinition("annotationProcessor",
        new RootBeanDefinition(PersistenceAnnotationBeanPostProcessor.class));
    gac.registerBeanDefinition(DefaultPrivatePersistenceContextField.class.getName(),
        new RootBeanDefinition(DefaultPrivatePersistenceContextField.class));
    gac.registerBeanDefinition(FactoryBeanWithPersistenceContextField.class.getName(),
        new RootBeanDefinition(FactoryBeanWithPersistenceContextField.class));
    gac.refresh();

    DefaultPrivatePersistenceContextField bean = (DefaultPrivatePersistenceContextField) gac.getBean(
        DefaultPrivatePersistenceContextField.class.getName());
    FactoryBeanWithPersistenceContextField bean2 = (FactoryBeanWithPersistenceContextField) gac.getBean(
        "&" + FactoryBeanWithPersistenceContextField.class.getName());
    assertNotNull(bean.em);
    assertNotNull(bean2.em);
  }
View Full Code Here

Examples of org.springframework.context.support.GenericApplicationContext

    assertNotNull(bean.em);
    assertNotNull(bean2.em);
  }

  public void testPrivateVendorSpecificPersistenceContextField() {
    GenericApplicationContext gac = new GenericApplicationContext();
    gac.getDefaultListableBeanFactory().registerSingleton("entityManagerFactory", mockEmf);
    gac.registerBeanDefinition("annotationProcessor",
        new RootBeanDefinition(PersistenceAnnotationBeanPostProcessor.class));
    gac.registerBeanDefinition(DefaultVendorSpecificPrivatePersistenceContextField.class.getName(),
        new RootBeanDefinition(DefaultVendorSpecificPrivatePersistenceContextField.class));
    gac.refresh();

    DefaultVendorSpecificPrivatePersistenceContextField bean = (DefaultVendorSpecificPrivatePersistenceContextField)
        gac.getBean(DefaultVendorSpecificPrivatePersistenceContextField.class.getName());
    assertNotNull(bean.em);
  }
View Full Code Here

Examples of org.springframework.context.support.GenericApplicationContext

    Object mockEm = (EntityManager) MockControl.createControl(EntityManager.class).getMock();
    mockEmf.createEntityManager();
    emfMc.setReturnValue(mockEm, 1);
    emfMc.replay();

    GenericApplicationContext gac = new GenericApplicationContext();
    gac.getDefaultListableBeanFactory().registerSingleton("entityManagerFactory", mockEmf);
    gac.registerBeanDefinition("annotationProcessor",
        new RootBeanDefinition(PersistenceAnnotationBeanPostProcessor.class));
    gac.registerBeanDefinition(DefaultPublicPersistenceContextSetter.class.getName(),
        new RootBeanDefinition(DefaultPublicPersistenceContextSetter.class));
    gac.refresh();

    DefaultPublicPersistenceContextSetter bean = (DefaultPublicPersistenceContextSetter) gac.getBean(
        DefaultPublicPersistenceContextSetter.class.getName());
    assertNotNull(bean.em);
    emfMc.verify();
  }
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.