Examples of CreationalContext


Examples of javax.enterprise.context.spi.CreationalContext

        if (contextMap != null) {
            for (Map.Entry<Contextual, ViewScopeContextObject> entry : contextMap.entrySet()) {
                Contextual contextual = entry.getKey();
                ViewScopeContextObject contextObject = entry.getValue();
                CreationalContext creationalContext = contextObject.getCreationalContext();
                contextual.destroy(viewMap.get(contextObject.getName()), creationalContext);
                removalNameList.add(contextObject.getName());
            }

            Iterator<String> removalNames = removalNameList.iterator();
View Full Code Here

Examples of javax.enterprise.context.spi.CreationalContext

    }

    public <T> T injectFields(T instance)
    {
        BeanManager beanManager = getBeanManager();
        CreationalContext creationalContext = beanManager.createCreationalContext(null);

        AnnotatedType annotatedType = beanManager.createAnnotatedType(instance.getClass());
        InjectionTarget injectionTarget = beanManager.createInjectionTarget(annotatedType);
        injectionTarget.inject(instance, creationalContext);
        return instance;
View Full Code Here

Examples of javax.enterprise.context.spi.CreationalContext

        Set<Bean<?>> beans  = bm.getBeans(name);
        if (beans.isEmpty()) throw new IllegalArgumentException("Bean not found by name: " + name);

        // Get the first bean found for the given name
        Bean bean = beans.iterator().next();
        CreationalContext ctx = bm.createCreationalContext(bean);
        Object o = bm.getReference(bean, bean.getBeanClass(), ctx);
        return o;
    }
View Full Code Here

Examples of javax.enterprise.context.spi.CreationalContext

        if (beans.isEmpty()) throw new IllegalArgumentException("Bean not found by type: " + type.getName());

        // Get the bean that matches exactly the given class.
        for (Bean<?> bean : beans) {
            if (bean.getBeanClass().equals(type)) {
                CreationalContext ctx = bm.createCreationalContext(bean);
                Object o = bm.getReference(bean, bean.getBeanClass(), ctx);
                return type.cast(o);
            }
        }
        // Get the first bean found that implements the given type.
        Bean bean = beans.iterator().next();
        CreationalContext ctx = bm.createCreationalContext(bean);
        Object o = bm.getReference(bean, bean.getBeanClass(), ctx);
        return type.cast(o);
    }
View Full Code Here

Examples of javax.enterprise.context.spi.CreationalContext

      {
         for (Entry<Contextual<?>, Object> componentEntry : componentInstanceMap.entrySet())
         {
            Contextual contextual = componentEntry.getKey();
            Object instance = componentEntry.getValue();
            CreationalContext creational = creationalContextMap.get(contextual);

            contextual.destroy(instance, creational);
         }
      }
   }
View Full Code Here

Examples of javax.enterprise.context.spi.CreationalContext

    }

    public static Object getBeanByName(String name) {
        BeanManager bm = getBeanManager();
        Bean bean = bm.getBeans(name).iterator().next();
        CreationalContext ctx = bm.createCreationalContext(bean);
        Object o = bm.getReference(bean, bean.getBeanClass(), ctx);
        return o;
    }
View Full Code Here

Examples of javax.enterprise.context.spi.CreationalContext

    }

    public static Object getBeanByType(Class type) {
        BeanManager bm = getBeanManager();
        Bean bean = bm.getBeans(type).iterator().next();
        CreationalContext ctx = bm.createCreationalContext(bean);
        Object o = bm.getReference(bean, bean.getBeanClass(), ctx);
        return o;
    }   
View Full Code Here

Examples of javax.enterprise.context.spi.CreationalContext

    public void setUp() throws Exception {
        StartMain startMain = new StartMain(new String[0]);
        beanManager = startMain.go().getBeanManager();
       
        final Bean pathsBean = (Bean) beanManager.getBeans( Paths.class ).iterator().next();
        final CreationalContext cc = beanManager.createCreationalContext( pathsBean );
        paths = (Paths) beanManager.getReference( pathsBean,
                                                  Paths.class,
                                                  cc );
       
        //Ensure URLs use the default:// scheme
View Full Code Here

Examples of javax.enterprise.context.spi.CreationalContext

        StartMain startMain = new StartMain( new String[ 0 ] );
        beanManager = startMain.go().getBeanManager();

        //Instantiate Paths used in tests for Path conversion
        final Bean pathsBean = (Bean) beanManager.getBeans( Paths.class ).iterator().next();
        final CreationalContext cc1 = beanManager.createCreationalContext( pathsBean );
        paths = (Paths) beanManager.getReference( pathsBean,
                                                  Paths.class,
                                                  cc1 );

        //Instantiate ConfigurationService
        final Bean configurationServiceBean = (Bean) beanManager.getBeans( ConfigurationService.class ).iterator().next();
        final CreationalContext cc2 = beanManager.createCreationalContext( configurationServiceBean );
        configurationService = (ConfigurationService) beanManager.getReference( configurationServiceBean,
                                                                                ConfigurationService.class,
                                                                                cc2 );

        //Instantiate ConfigurationFactory
        final Bean configurationFactoryBean = (Bean) beanManager.getBeans( ConfigurationFactory.class ).iterator().next();
        final CreationalContext cc3 = beanManager.createCreationalContext( configurationFactoryBean );
        configurationFactory = (ConfigurationFactory) beanManager.getReference( configurationFactoryBean,
                                                                                ConfigurationFactory.class,
                                                                                cc3 );

        //Instantiate BuildResultsObserver
        final Bean buildResultsObserverBean = (Bean) beanManager.getBeans( BuildResultsObserver.class ).iterator().next();
        final CreationalContext cc4 = beanManager.createCreationalContext( buildResultsObserverBean );
        buildResultsObserver = (BuildResultsObserver) beanManager.getReference( buildResultsObserverBean,
                                                                                BuildResultsObserver.class,
                                                                                cc4 );

        //Instantiate BuildService
        final Bean buildServiceBean = (Bean) beanManager.getBeans( BuildService.class ).iterator().next();
        final CreationalContext cc5 = beanManager.createCreationalContext( buildServiceBean );
        buildService = (BuildService) beanManager.getReference( buildServiceBean,
                                                                BuildService.class,
                                                                cc5 );

        //Instantiate ProjectService
        final Bean projectServiceBean = (Bean) beanManager.getBeans( ProjectService.class ).iterator().next();
        final CreationalContext cc6 = beanManager.createCreationalContext( projectServiceBean );
        projectService = (ProjectService) beanManager.getReference( projectServiceBean,
                                                                    ProjectService.class,
                                                                    cc6 );

        //Instantiate ProjectService
        final Bean ruleNamesServiceBean = (Bean) beanManager.getBeans( RuleNamesService.class ).iterator().next();
        final CreationalContext cc7 = beanManager.createCreationalContext( ruleNamesServiceBean );
        ruleNamesService = (RuleNamesService) beanManager.getReference( ruleNamesServiceBean,
                                                                        RuleNamesService.class,
                                                                        cc7 );

        //Define mandatory properties
View Full Code Here

Examples of javax.enterprise.context.spi.CreationalContext

    }

    @Test
    public void testConcurrentResourceUpdates() throws URISyntaxException {
        final Bean buildChangeListenerBean = (Bean) beanManager.getBeans( ResourceChangeIncrementalBuilder.class ).iterator().next();
        final CreationalContext cc = beanManager.createCreationalContext( buildChangeListenerBean );
        final ResourceChangeIncrementalBuilder buildChangeListener = (ResourceChangeIncrementalBuilder) beanManager.getReference( buildChangeListenerBean,
                                                                                                                                  ResourceChangeIncrementalBuilder.class,
                                                                                                                                  cc );

        final URL resourceUrl = this.getClass().getResource( "/BuildChangeListenerRepo/src/main/resources/update.drl" );
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.