Package org.jboss.weld.manager

Examples of org.jboss.weld.manager.BeanManagerImpl.createCreationalContext()


            //we just look up the service rather than using a dependency
            //the component itself has a dependency on this service, which means that it has to be up
            final WeldContainer weldContainer = (WeldContainer) CurrentServiceContainer.getServiceContainer().getRequiredService(weldContainerServiceName).getValue();
            final BeanManagerImpl beanManager = (BeanManagerImpl) weldContainer.getBeanManager();
            final Bean<?> bean = beanManager.resolve(beanManager.getBeans(EjbRequestContext.class, EjbLiteral.INSTANCE));
            final CreationalContext<?> ctx = beanManager.createCreationalContext(bean);
            requestContext = (EjbRequestContext) beanManager.getReference(bean, EjbRequestContext.class, ctx);
        }
        try {
            requestContext.associate(context.getInvocationContext());
            requestContext.activate();
View Full Code Here


            //we just look up the service rather than using a dependency
            //the component itself has a dependency on this service, which means that it has to be up
            final WeldContainer weldContainer = (WeldContainer) CurrentServiceContainer.getServiceContainer().getRequiredService(weldContainerServiceName).getValue();
            final BeanManagerImpl beanManager = (BeanManagerImpl) weldContainer.getBeanManager();
            final Bean<?> bean = beanManager.resolve(beanManager.getBeans(EjbRequestContext.class, EjbLiteral.INSTANCE));
            final CreationalContext<?> ctx = beanManager.createCreationalContext(bean);
            requestContext = (EjbRequestContext) beanManager.getReference(bean, EjbRequestContext.class, ctx);
        }
        try {
            requestContext.associate(context.getInvocationContext());
            requestContext.activate();
View Full Code Here

        final ComponentInstance componentInstance = interceptorContext.getPrivateData(ComponentInstance.class);
        WeldInterceptorInstances existing = (WeldInterceptorInstances) componentInstance.getInstanceData(SerializedCdiInterceptorsKey.class);

        if (existing == null) {
            CreationalContext<Object> creationalContext = beanManager.createCreationalContext(bean);
            HashMap<String, SerializableContextualInstance<Interceptor<Object>, Object>> interceptorInstances = new HashMap<String, SerializableContextualInstance<Interceptor<Object>, Object>>();

            if (interceptorBindings != null) {
                for (Interceptor<?> interceptor : interceptorBindings.getAllInterceptors()) {
                    addInterceptorInstance((Interceptor<Object>) interceptor, beanManager, interceptorInstances, creationalContext);
View Full Code Here

        container1.startContainer();
        container1.ensureRequestActive();

        BeanManagerImpl beanManager1 = getBeanManager(container1);
        Bean<?> fooBean1 = beanManager1.resolve(beanManager1.getBeans(Foo.class));
        Foo foo1 = (Foo) beanManager1.getReference(fooBean1, Foo.class, beanManager1.createCreationalContext(fooBean1));
        foo1.setName("container 1");

        // Bootstrap container 2
        SwitchableSingletonProvider.use(2);
View Full Code Here

        container2.startContainer();
        container2.ensureRequestActive();

        BeanManagerImpl beanManager2 = getBeanManager(container2);
        Bean<?> fooBean2 = beanManager2.resolve(beanManager2.getBeans(Foo.class));
        Foo foo2 = (Foo) beanManager2.getReference(fooBean2, Foo.class, beanManager2.createCreationalContext(fooBean2));
        foo2.setName("container 2");

        // Switch to container 1 and check value
        SwitchableSingletonProvider.use(1);
        foo1 = (Foo) beanManager1.getReference(fooBean1, Foo.class, beanManager1.createCreationalContext(fooBean1));
View Full Code Here

        foo1 = (Foo) beanManager1.getReference(fooBean1, Foo.class, beanManager1.createCreationalContext(fooBean1));
        assert foo1.getName().equals("container 1");

        // Switch to container 2 and check value
        SwitchableSingletonProvider.use(2);
        foo2 = (Foo) beanManager2.getReference(fooBean2, Foo.class, beanManager2.createCreationalContext(fooBean2));
        assert foo2.getName().equals("container 2");
        SwitchableSingletonProvider.use(1);
        container1.stopContainer();
        SwitchableSingletonProvider.use(2);
        container2.stopContainer();
View Full Code Here

        foo1.setName("container 1");

        replicateSession(1, container1, 2, container2);

        use(2);
        Foo foo2 = (Foo) beanManager2.getReference(fooBean2, Foo.class, beanManager2.createCreationalContext(fooBean2));
        assert foo2.getName().equals("container 1");
        use(2);
        container2.stopContainer();
        use(1);
        container1.stopContainer();
View Full Code Here

        replicateSession(1, container1, 2, container2);

        use(2);

        Stable stable2 = (Stable) beanManager2.getReference(stableBean2, Stable.class, beanManager2.createCreationalContext(stableBean2));
        assert stable2.getFodder().getAmount() == stable1.getFodder().getAmount();
        assert stable2.getHorse().getName() == null;

        use(1);
        assert stable1.getFodder().getAmount() == 10;
View Full Code Here

        replicateSession(1, container1, 2, container2);

        use(2);

        Stable stable2 = (Stable) beanManager2.getReference(stableBean2, Stable.class, beanManager2.createCreationalContext(stableBean2));
        assert stable2.getFodder().getAmount() == stable1.getFodder().getAmount();
        assert stable2.getHorse().getName() == null;
        use(1);
        container1.stopContainer();
        use(2);
View Full Code Here

        Bean<?> dummyBean = createDummyBean(childActivity, Cow.class);
        childActivity.addBean(dummyBean);
        Assert.assertNotNull(
                childActivity.getInjectableReference(
                        dummyBean.getInjectionPoints().iterator().next(),
                        childActivity.createCreationalContext(dummyBean)));
    }

    @Test
    public void testObserverBelongingToParentActivityBelongsToChildActivity() {
        Assert.assertEquals(1, beanManager.resolveObserverMethods(new NightTime()).size());
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.