Package org.impalaframework.spring.module.impl

Examples of org.impalaframework.spring.module.impl.Child


        };
       
        parentContext.getBean("parent");
       
        Parent parentBean = (Parent) parentContext.getBean("parent");
        Child child = parentBean.tryGetChild();

        try {
            child.childMethod();
            fail();
        }
        catch (NoServiceException e) {
        }

        // now create child appliction context
        ClassPathXmlApplicationContext childContext = new ClassPathXmlApplicationContext(
                new String[] { "childcontainer/child-context.xml" }, parentContext){
             @Override
                protected DefaultListableBeanFactory createBeanFactory() {
                    DefaultListableBeanFactory beanFactory = super.createBeanFactory();
                    beanFactory.addBeanPostProcessor(new ServiceRegistryPostProcessor(serviceRegistry, null));
                    beanFactory.addBeanPostProcessor(new ModuleDefinitionPostProcessor(new SimpleModuleDefinition("module1")));
                    return beanFactory;
                }
        };

        // bingo, child.childMethod does nto throw NoServiceException
        child.childMethod();

        // now create another context which depends only on the parent
        ApplicationContext another = childContext;

        // call method from child
        Child anotherChild = (Child) another.getBean("child");
        anotherChild.childMethod();

        // shutdown the child context
        childContext.close();

        // should go back to what it was doing before
View Full Code Here


        checkInitialized(parent, childOfChild, "another");
       
    }

    private void checkDestroyed(ClassPathXmlApplicationContext parent, String beanName) {
        Child bean = (Child) parent.getBean(beanName);
        try {
            bean.childMethod();fail();
        }
        catch (NoServiceException e) {
            assertEquals("No service available for bean " + beanName, e.getMessage());
        }
    }
View Full Code Here

        assertTrue(beanFromChild instanceof ChildBean);
        assertTrue(beanFromRoot instanceof Child);
        assertFalse(beanFromRoot instanceof ChildBean);
       
        Child bean = (Child) parent.getBean(beanName);
        bean.childMethod();
    }
View Full Code Here

    public void testWithBeanName() throws Exception {
        bean.setProxyTypes(new Class[] { Child.class });
        bean.setBeanName("someBean");
        bean.afterPropertiesSet();

        Child child = (Child) bean.getObject();

        try {
            child.childMethod();
            fail();
        }
        catch (NoServiceException e) {
        }
       
        //now register using types. Will still not be able to find
        Child service = newChild();
        serviceRegistry.addService(null, "moduleName"new StaticServiceBeanReference(service), Arrays.asList(exportTypes) , null, classLoader);
        try {
            child.childMethod();
            fail();
        }
View Full Code Here

        bean.setProxyTypes(new Class[] { Child.class });
        bean.setBeanName("someBean");
        bean.setExportName("exportBean");
        bean.afterPropertiesSet();

        Child child = (Child) bean.getObject();

        try {
            child.childMethod();
            fail();
        }
        catch (NoServiceException e) {
            e.printStackTrace();
        }

        Child service = newChild();
        serviceRegistry.addService("exportBean", "moduleName"new StaticServiceBeanReference(service), classLoader);
        child.childMethod();
    }
View Full Code Here

        proxyFactoryCreator.setAllowNoService(true);
        bean.setProxyFactoryCreator(proxyFactoryCreator);
       
        bean.afterPropertiesSet();

        Child child = (Child) bean.getObject();
        child.childMethod();
    }
View Full Code Here

        Child child = (Child) bean.getObject();
        child.childMethod();
    }

    private Child newChild() {
        return new Child() {
            public void childMethod() {
            }

            public Parent tryGetParent() {
                return null;
View Full Code Here

       
        bean.setExportName("mybean");
        bean.setExportTypes(exportTypes);
        bean.afterPropertiesSet();

        Child child = (Child) bean.getObject();

        try {
            child.childMethod();
            fail();
        }
        catch (NoServiceException e) {
            e.printStackTrace();
        }

        //create service and register using export types
        Child service = newChild();
        serviceRegistry.addService(null, "moduleName"new StaticServiceBeanReference(service), Arrays.asList(exportTypes) , null, classLoader);
        try {
            child.childMethod();
            fail();
        }
View Full Code Here

   
    public void testWithExportTypesOnly() throws Exception {
        bean.setExportTypes(exportTypes);
        bean.afterPropertiesSet();

        Child child = (Child) bean.getObject();

        try {
            child.childMethod();
            fail();
        }
        catch (NoServiceException e) {
            e.printStackTrace();
        }

        Child service = newChild();
        serviceRegistry.addService(null, "moduleName"new StaticServiceBeanReference(service), Arrays.asList(exportTypes) , null, classLoader);
        child.childMethod();
   
View Full Code Here

        }
        catch (NoServiceException e) {
            e.printStackTrace();
        }

        Child service = newChild();
        serviceRegistry.addService(null, "moduleName"new StaticServiceBeanReference(service), Arrays.asList(exportTypes) , null, classLoader);
        child.childMethod();
    }
View Full Code Here

TOP

Related Classes of org.impalaframework.spring.module.impl.Child

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.