Package javax.enterprise.inject.spi

Examples of javax.enterprise.inject.spi.BeanManager.resolve()


                bm = null;
                bean = null;
            } else {
                bm = wc.getBeanManagerImpl();
                final Set<Bean<?>> beans = bm.getBeans(clazz);
                bean = bm.resolve(beans);
            }

            // create the MBean instance with cdi if possible or manually otherwise
            final Object instance;
            final CreationalContext creationalContext;
View Full Code Here


                final ClassLoader tccl = SecurityActions.getContextClassLoader();
                try {
                    SecurityActions.setContextClassLoader(classLoader);
                    //it does not matter if this happens twice
                    final BeanManager beanManager = weldContainer.getValue().getBeanManager();
                    final Bean<?> bean = beanManager.resolve(beanManager.getBeans(EjbRequestContext.class, EjbLiteral.INSTANCE));
                    final CreationalContext<?> ctx = beanManager.createCreationalContext(bean);
                    EjbRequestContext requestContext = (EjbRequestContext) beanManager.getReference(bean, EjbRequestContext.class, ctx);
                    interceptor = new EjbRequestScopeActivationInterceptor(requestContext);
                } finally {
                    SecurityActions.setContextClassLoader(tccl);
View Full Code Here

                bm = null;
                bean = null;
            } else {
                bm = wc.getBeanManagerImpl();
                final Set<Bean<?>> beans = bm.getBeans(clazz);
                bean = bm.resolve(beans);
            }

            // create the MBean instance with cdi if possible or manually otherwise
            final Object instance;
            final CreationalContext creationalContext;
View Full Code Here

                        "(e.g. via BeanProvider.getContextualReference(ContextControl.class) ). " +
                        "If the container wasn't started already, you have to use CdiContainer#boot before.");

                return null;
            }
            ctxCtrlBean = (Bean<ContextControl>) beanManager.resolve(beans);

            ctxCtrlCreationalContext = getBeanManager().createCreationalContext(ctxCtrlBean);

            ctxCtrl = (ContextControl)
                    getBeanManager().getReference(ctxCtrlBean, ContextControl.class, ctxCtrlCreationalContext);
View Full Code Here

    final Set<Bean<?>> beans = beanManager.getBeans(clazz, qualifiers);
    logger.debug("getInstance() - beans found : "+beans+" for class "+clazz.getSimpleName());
    if (beans == null || beans.isEmpty()) {
      return null;
    }
    final Bean<?> bean = beanManager.resolve(beans);
    logger.debug("getInstance() - bean resolved : "+bean);
    final CreationalContext<?> creationalContext = beanManager.createCreationalContext(bean);
    final Object result = beanManager.getReference(bean, clazz, creationalContext);
    return new BeanInstance(result, creationalContext, Dependent.class.equals(bean.getScope()));
  }
View Full Code Here

    if(beanQualifiers == null || beanQualifiers.length == 0){
      beanQualifiers = new Annotation[]{};
    }
    Set<Bean<?>> beans = beanManager.getBeans(clazz, beanQualifiers);
    if(beans!=null && beans.size()>0) {
      Bean<T> bean = (Bean<T>) beanManager.resolve(beans);
      logger.debug("Bean found : "+bean);
      CreationalContext<T> ctx = beanManager.createCreationalContext(bean);
      T o = clazz.cast(beanManager.getReference(bean, clazz, ctx));
      logger.debug("Found and returning: "+clazz.getCanonicalName());
      return o;
View Full Code Here

    @Test
    public void testAllBeanDiscoveryAlternative(Cat representative) {
        BeanManager bm = representative.getBeanManager();
        Set<Bean<?>> beans = bm.getBeans(DogInterface.class);
        assertEquals(2, beans.size());
        assertEquals(AlternativeDog.class, bm.resolve(beans).getBeanClass());
    }

    @Test
    public void testAnnotatedBeanDiscoveryAlternative(Plant representative) {
        BeanManager bm = representative.getBeanManager();
View Full Code Here

    @Test
    public void testAnnotatedBeanDiscoveryAlternative(Plant representative) {
        BeanManager bm = representative.getBeanManager();
        Set<Bean<?>> treeBeans = bm.getBeans(Tree.class);
        assertEquals(2, treeBeans.size());
        assertEquals(AlternativeTree.class, bm.resolve(treeBeans).getBeanClass());

        Set<Bean<?>> stoneBeans = bm.getBeans(Stone.class);
        assertEquals(0, stoneBeans.size());
    }
View Full Code Here

        // Our entry point is the single bean deployment archive
        BeanManager beanManager = container.getBeanManager(container.getDeployment().getBeanDeploymentArchives().iterator().next());

        // Obtain a reference to the Car and pass it to the TCK to generate the testsuite
        Bean<?> bean = beanManager.resolve(beanManager.getBeans(Car.class));
        Car instance = (Car) beanManager.getReference(bean, Car.class, beanManager.createCreationalContext(bean));

        return Tck.testsFor(instance, false /* supportsStatic */, true /* supportsPrivate */);
    }
}
View Full Code Here

        container.startContainer();
        container.ensureRequestActive();

        BeanManager manager = getBeanManager(container);

        Bean<? extends Object> bean = manager.resolve(manager.getBeans(Foo.class));
        ijs.reset();
        Foo foo = (Foo) manager.getReference(bean, Foo.class, manager.createCreationalContext(bean));

        Assert.assertTrue(ijs.isBefore());
        Assert.assertTrue(ijs.isAfter());
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.