Package javax.enterprise.context.spi

Examples of javax.enterprise.context.spi.CreationalContext


        // First get BeanDeploymentArchive for this ejb
        BeanDeploymentArchive bda = weldDeployer.getBeanDeploymentArchiveForBundle(topLevelBundleDesc);
        WeldBootstrap bootstrap = weldDeployer.getBootstrapForApp(bundle.getApplication());
        BeanManager beanManager = bootstrap.getManager(bda);
        CreationalContext cc = beanManager.createCreationalContext(null);

        AnnotatedType annotatedType = beanManager.createAnnotatedType(interceptorClass);
        InjectionTarget it =
            ((WeldManager) beanManager).getInjectionTargetFactory(annotatedType).createInterceptorInjectionTarget();
        T interceptorInstance = (T) it.produce(cc);
View Full Code Here


        InjectionTarget it = ((BeanDeploymentArchiveImpl)bda).getInjectionTarget(annotatedType);
        if (it == null) {
            it = beanManager.createInjectionTarget(annotatedType);
        }

        CreationalContext cc = beanManager.createCreationalContext(null);

        managedObject = it.produce(cc);

        it.inject(managedObject, cc);
View Full Code Here

        ClassLoader tccl = Thread.currentThread().getContextClassLoader();
        try {
            Thread.currentThread().setContextClassLoader(_beanDeploymentMetaData.getDeploymentClassLoader());

            BeanManager beanManager = _cdiBean.getBeanManager();
            CreationalContext creationalContext = beanManager.createCreationalContext(_cdiBean.getBean());
            Object beanRef = beanManager.getReference(_cdiBean.getBean(), Object.class, creationalContext);

            return new ServiceProxyHandler(beanRef, _serviceMetadata, _beanDeploymentMetaData);
        } finally {
            Thread.currentThread().setContextClassLoader(tccl);
View Full Code Here

    @Test
    @SuppressWarnings({"unchecked"})
    public void testLifecycle(BeanManager bm) throws Exception {
        for (Bean b : bm.getBeans(TestBean.class)) {
            CreationalContext ctx = bm.createCreationalContext(null);
            TestBean testBean = (TestBean) bm.getReference(b, b.getBeanClass(), ctx);
            b.destroy(testBean, ctx);
            Assert.assertEquals("PreDestroy invocation number.", 1, testBean.getCounter());
        }
    }
View Full Code Here

   @Test
   public void testSimpleInterceptor()
   {
      Bean bean = beanManager.getBeans(SimpleBeanImpl.class).iterator().next();
      CreationalContext creationalContext = beanManager.createCreationalContext(bean);
      SimpleBeanImpl simpleBean = (SimpleBeanImpl) bean.create(creationalContext);
      String result = simpleBean.doSomething();
      assert "decorated-Hello!-decorated".equals(result);
      bean.destroy(simpleBean, creationalContext);
      assert SimpleInterceptor.aroundInvokeCalled;
View Full Code Here

   @Test
   public void testSimpleInterceptorWithStereotype()
   {
      Bean bean = beanManager.getBeans(SimpleBeanWithStereotype.class).iterator().next();
      CreationalContext creationalContext = beanManager.createCreationalContext(bean);
      SimpleBeanWithStereotype simpleBean = (SimpleBeanWithStereotype) bean.create(creationalContext);
      String result = simpleBean.doSomething();
      assert "Hello!".equals(result);
      bean.destroy(simpleBean, creationalContext);
      assert SimpleInterceptor.aroundInvokeCalled;
View Full Code Here

    @Test
    @SuppressWarnings("unchecked")
    public void testLifecycleInterceptor() {
        Bean bean = beanManager.getBeans(Marathon.class).iterator().next();
        CreationalContext creationalContext = beanManager.createCreationalContext(bean);
        Marathon m = (Marathon) bean.create(creationalContext);

        Assert.assertTrue(LifecycleInterceptor.isPostConstructCalled());
        Assert.assertEquals(42, m.getLength());
        bean.destroy(m, creationalContext);
View Full Code Here

    @Test
    @Ignore // requires Module CL resolution
    public void testPassivationAndActivation() throws Exception {
        Bean bean = beanManager.getBeans(Ball.class).iterator().next();
        CreationalContext creationalContext = beanManager.createCreationalContext(bean);

        PassivationActivationInterceptor.initialMessage = "Goal!";

        Ball ball = (Ball) bean.create(creationalContext);
View Full Code Here

    @Test
    public void testSimpleInterceptor() {
        reset();
        Bean bean = beanManager.getBeans(Ball.class).iterator().next();
        CreationalContext creationalContext = beanManager.createCreationalContext(bean);
        Ball ball = (Ball) bean.create(creationalContext);
        ball.shoot();
        assert Defender.defended;
        assert Ball.played;
        assert !Goalkeeper.caught;
View Full Code Here

    @Test
    public void testSimpleInterceptor2() {
        reset();
        Bean bean = beanManager.getBeans(Ball.class).iterator().next();
        CreationalContext creationalContext = beanManager.createCreationalContext(bean);
        Ball ball = (Ball) bean.create(creationalContext);
        ball.pass();
        assert Defender.defended;
        assert Ball.played;
        assert Goalkeeper.caught;
View Full Code Here

TOP

Related Classes of javax.enterprise.context.spi.CreationalContext

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.