Examples of WeldManager


Examples of org.jboss.weld.manager.api.WeldManager

        // First get BeanDeploymentArchive for this ejb
        BeanDeploymentArchive bda = getBDAForBeanClass(topLevelBundleDesc, ejb.getEjbClassName());
    
        WeldBootstrap bootstrap = weldDeployer.getBootstrapForApp(ejb.getEjbBundleDescriptor().getApplication());
        WeldManager weldManager = bootstrap.getManager(bda);

        org.jboss.weld.ejb.spi.EjbDescriptor ejbDesc = weldManager.getEjbDescriptor(ejb.getName());

        // Get an the Bean object
        Bean<?> bean = weldManager.getBean(ejbDesc);

        // Create the injection target
        InjectionTarget it = weldManager.createInjectionTarget(ejbDesc);

        // Per instance required, create the creational context
        CreationalContext<?> cc = weldManager.createCreationalContext(bean);  
 
      Object beanInstance = instance;
   
      if( beanInstance == null ) {
          // Create instance , perform constructor injection.
View Full Code Here

Examples of org.jboss.weld.manager.api.WeldManager

        // First get BeanDeploymentArchive for this ejb
        BeanDeploymentArchive bda = getBDAForBeanClass(topLevelBundleDesc, ejb.getEjbClassName());

        WeldBootstrap bootstrap = weldDeployer.getBootstrapForApp(ejb.getEjbBundleDescriptor().getApplication());
        WeldManager weldManager = bootstrap.getManager(bda);

        org.jboss.weld.ejb.spi.EjbDescriptor ejbDesc = weldManager.getEjbDescriptor(ejb.getName());

        // Get an the Bean object
        Bean<?> bean = weldManager.getBean(ejbDesc);

        // Create the injection target
        InjectionTarget it = weldManager.createInjectionTarget(ejbDesc);

        // Per instance required, create the creational context
        CreationalContext<?> cc = weldManager.createCreationalContext(bean);

      Object beanInstance = instance;

      if( beanInstance == null ) {
          // Create instance , perform constructor injection.
View Full Code Here

Examples of org.jboss.weld.manager.api.WeldManager

        // First get BeanDeploymentArchive for this ejb
        BeanDeploymentArchive bda = getBDAForBeanClass(topLevelBundleDesc, ejb.getEjbClassName());

        WeldBootstrap bootstrap = weldDeployer.getBootstrapForApp(ejb.getEjbBundleDescriptor().getApplication());
        WeldManager weldManager = bootstrap.getManager(bda);

        org.jboss.weld.ejb.spi.EjbDescriptor ejbDesc = weldManager.getEjbDescriptor(ejb.getName());

        // Get an the Bean object
        Bean<?> bean = weldManager.getBean(ejbDesc);

        // Create the injection target
        InjectionTarget it = weldManager.createInjectionTarget(ejbDesc);

        // Per instance required, create the creational context
        CreationalContext<?> cc = weldManager.createCreationalContext(bean);

      Object beanInstance = instance;

      if( beanInstance == null ) {
          // Create instance , perform constructor injection.
View Full Code Here

Examples of org.jboss.weld.manager.api.WeldManager

     * @param context
     * @return <code>true</code> if initialized properly, <code>false</code> otherwise
     */
    boolean initialize(ServletContext context) {

        WeldManager manager = (WeldManager) context.getAttribute(BEAN_MANAGER_ATTRIBUTE_NAME);
        if (manager != null) {
            isBootstrapNeeded = false;
        }

        if (isBootstrapNeeded) {

            CDI11Deployment deployment = createDeployment(context, bootstrap);

            if (deployment.getBeanDeploymentArchives().isEmpty()) {
                // Skip initialization - there is no bean archive in the deployment
                CommonLogger.LOG.initSkippedNoBeanArchiveFound();
                return false;
            }

            ResourceInjectionServices resourceInjectionServices = new ServletResourceInjectionServices() {
            };
            try {
                for (BeanDeploymentArchive archive : deployment.getBeanDeploymentArchives()) {
                    archive.getServices().add(ResourceInjectionServices.class, resourceInjectionServices);
                }
            } catch (NoClassDefFoundError e) {
                // Support GAE
                WeldServletLogger.LOG.resourceInjectionNotAvailable();
            }
            String id = context.getInitParameter(CONTEXT_ID_KEY);
            if (id != null) {
                bootstrap.startContainer(id, Environments.SERVLET, deployment);
            } else {
                bootstrap.startContainer(Environments.SERVLET, deployment);
            }
            bootstrap.startInitialization();

            /*
             * This should work fine as all bean archives share the same classloader. The only difference this can make is per-BDA (CDI 1.0 style) enablement of
             * alternatives, interceptors and decorators. Nothing we can do about that.
             */
            manager = bootstrap.getManager(deployment.getBeanDeploymentArchives().iterator().next());

            // Push the manager into the servlet context so we can access in JSF
            context.setAttribute(BEAN_MANAGER_ATTRIBUTE_NAME, manager);
        }

        ContainerContext containerContext = new ContainerContext(context, manager);
        StringBuilder dump = new StringBuilder();
        Container container = findContainer(containerContext, dump);
        if (container == null) {
            WeldServletLogger.LOG.noSupportedServletContainerDetected();
            WeldServletLogger.LOG.debugv("Exception dump from Container lookup: {0}", dump);
        } else {
            container.initialize(containerContext);
            this.container = container;
        }

        if (JspFactory.getDefaultFactory() != null) {
            JspApplicationContext jspApplicationContext = JspFactory.getDefaultFactory().getJspApplicationContext(context);

            // Register the ELResolver with JSP
            jspApplicationContext.addELResolver(manager.getELResolver());

            // Register ELContextListener with JSP
            try {
                jspApplicationContext.addELContextListener(Reflections.<ELContextListener> newInstance("org.jboss.weld.el.WeldELContextListener"));
            } catch (IllegalArgumentException e) {
                throw WeldServletLogger.LOG.errorLoadingWeldELContextListener(e);
            }

            // Push the wrapped expression factory into the servlet context so that Tomcat or Jetty can hook it in using a container code
            context.setAttribute(EXPRESSION_FACTORY_NAME, manager.wrapExpressionFactory(jspApplicationContext.getExpressionFactory()));
        }

        if (isBootstrapNeeded) {
            bootstrap.deployBeans().validateBeans().endInitialization();
        }
View Full Code Here

Examples of org.jboss.weld.manager.api.WeldManager

    @Test
    public void testInjectedManagerIsCurrentActivity() {
        Context dummyContext = new DummyContext();
        beanManager.addContext(dummyContext);
        Assert.assertEquals(1, beanManager.getBeans(Cow.class).size());
        WeldManager childActivity = beanManager.createActivity();
        childActivity.setCurrent(dummyContext.getScope());
        Assert.assertEquals(childActivity, Utils.getReference(beanManager, Horse.class).getManager());
    }
View Full Code Here

Examples of org.jboss.weld.manager.api.WeldManager

    @Category(Broken.class) // JBAS-8436
    public void testJndiManagerIsCurrentActivity() {
        Context dummyContext = new DummyContext();
        beanManager.addContext(dummyContext);
        assertEquals(1, beanManager.getBeans(Cow.class).size());
        WeldManager childActivity = beanManager.createActivity();
        childActivity.setCurrent(dummyContext.getScope());
        assertEquals(childActivity, getReference(beanManager, Donkey.class).getManager());
    }
View Full Code Here

Examples of org.jboss.weld.manager.api.WeldManager

    @Test(expected = IllegalArgumentException.class)
    public void testNonNormalScope() {
        Context dummyContext = new NonNormalContext();
        beanManager.addContext(dummyContext);
        WeldManager childActivity = beanManager.createActivity();
        childActivity.setCurrent(dummyContext.getScope());
    }
View Full Code Here

Examples of org.jboss.weld.manager.api.WeldManager

    @Test(expected = ContextNotActiveException.class)
    public void testInactiveScope() {
        DummyContext dummyContext = new DummyContext();
        dummyContext.setActive(false);
        beanManager.addContext(dummyContext);
        WeldManager childActivity = beanManager.createActivity();
        childActivity.setCurrent(dummyContext.getScope());
    }
View Full Code Here

Examples of org.jboss.weld.manager.api.WeldManager

                  .startInitialization()
                  .deployBeans()
                  .validateBeans()
                  .endInitialization();

      WeldManager manager = bootstrap.getManager(beanArchive);
     
      weldBootstrapInst.set(bootstrap);
      weldManagerInst.set(manager);
      beanManagerInst.set(manager);
     
View Full Code Here

Examples of org.jboss.weld.manager.api.WeldManager

                  .startInitialization()
                  .deployBeans()
                  .validateBeans()
                  .endInitialization();

      WeldManager manager = bootstrap.getManager(beanArchive);
     
      weldBootstrapProducer.set(bootstrap);
      weldManagerProducer.set(manager);
     
      return new ProtocolMetaData(); // local execution only, not specific protocol metadata needed
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.