Package org.springframework.context.support

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


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

     *
     * @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

            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

    @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

      // 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

* @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

    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

    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

        getClass().getClassLoader(), new Class[] {EntityManager.class}, ih);
    mockEmf.createEntityManager();
    emfMc.setReturnValue(mockEm, 1);
    emfMc.replay();

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

    DefaultPublicPersistenceContextSetter bean = (DefaultPublicPersistenceContextSetter) gac.getBean(
        DefaultPublicPersistenceContextSetter.class.getName());
    assertNotNull(bean.em);
    assertNotNull(SerializationTestUtils.serializeAndDeserialize(bean.em));

    SimpleMapScope serialized = (SimpleMapScope) SerializationTestUtils.serializeAndDeserialize(myScope);
View Full Code Here

TOP

Related Classes of org.springframework.context.support.GenericApplicationContext

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.