Examples of CreationalContext


Examples of javax.enterprise.context.spi.CreationalContext

                if ((componentInstanceMap != null) && (creationalContextMap != null)) {
                    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

      /*
      Protocol protocol
        = (Protocol) webBeans.createTransientObjectNoInit(_protocolClass);
      */
      InjectionTarget target = webBeans.createInjectionTarget(_protocolClass);
      CreationalContext env = webBeans.createCreationalContext(null);

      AbstractProtocol protocol = (AbstractProtocol) target.produce(env);
      target.inject(protocol, env);

      if (_init != null)
View Full Code Here

Examples of javax.enterprise.context.spi.CreationalContext

      Object destComp = null;

      if (beanSet.size() > 0) {
        Bean destBean = webBeans.resolve(beanSet);
        CreationalContext env = webBeans.createCreationalContext(destBean);

        destComp
          = webBeans.getReference(destBean, destBean.getBeanClass(), env);
      }

      if (destComp == null)
        throw new ConfigException(L.l("{0}: '{1}' is an unknown destination type '{2}'",
                                      loc,
                                      _destinationName,
                                      _destinationType.getName()));

      bean.setDestinationValue((Destination) destComp);

      beanSet = webBeans.getBeans(ConnectionFactory.class);

      Bean factoryBean = webBeans.resolve(beanSet);
      CreationalContext env = webBeans.createCreationalContext(factoryBean);

      Object comp = webBeans.getReference(factoryBean);

      if (comp == null)
        throw new ConfigException(L.l("ejb-message-bean requires a configured JMS ConnectionFactory"));
View Full Code Here

Examples of javax.enterprise.context.spi.CreationalContext

    }

    @Override
    @SuppressWarnings("unchecked")
    public <T, U extends T> U newClassInstance(AtmosphereFramework framework, Class<T> classType, Class<U> classToInstantiate) throws InstantiationException, IllegalAccessException {
        CreationalContext cc = null;

        try {
            final Iterator<Bean<?>> i = bm.getBeans(classToInstantiate).iterator();
            if (!i.hasNext()) {
                logger.trace("Unable to find {}. Creating the object directly.", classToInstantiate.getName());
                return classToInstantiate.newInstance();
            }
            Bean<U> bean = (Bean<U>) i.next();
            CreationalContext<U> ctx = bm.createCreationalContext(bean);
            U dao = (U) bm.getReference(bean, classToInstantiate, ctx);

            if (framework.objectFactory().getClass().getName().equals("org.atmosphere.inject.InjectableObjectFactory")) {
                InjectableObjectFactory.class.cast(framework.objectFactory()).injectAtmosphereInternalObject(dao, classToInstantiate, framework);
            }

            return dao;
        } catch (Exception e) {
            logger.error("Unable to construct {}. Creating the object directly.", classToInstantiate.getName());
            return classToInstantiate.newInstance();
        } finally {
            if (cc != null) cc.release();
        }
    }
View Full Code Here

Examples of javax.enterprise.context.spi.CreationalContext

   public static <T> Instance<T> getInstance(Class<T> type, BeanManager manager, Annotation... qualifiers)
   {
      Type instanceType = new InstanceParamatizedTypeImpl<T>(type);
      Bean<?> bean = manager.resolve(manager.getBeans(instanceType, qualifiers));
      CreationalContext ctx = manager.createCreationalContext(bean);
      return (Instance<T>) manager.getInjectableReference(new InstanceInjectionPoint<T>(type, qualifiers), ctx);
   }
View Full Code Here

Examples of javax.enterprise.context.spi.CreationalContext

            return null;
        }

        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

    @SuppressWarnings("unchecked")
    protected T getInstance(CreationalContext<T> creationalContext) {

        final List<Class> classes = beanContext.getBusinessLocalInterfaces();
        CurrentCreationalContext currentCreationalContext = beanContext.get(CurrentCreationalContext.class);
        CreationalContext existing = currentCreationalContext.get();
        currentCreationalContext.set(creationalContext);
        try {
            if (classes.size() == 0 && beanContext.isLocalbean()) {
                BeanContext.BusinessLocalBeanHome home = beanContext.getBusinessLocalBeanHome();
                return (T) home.create();
View Full Code Here

Examples of javax.enterprise.context.spi.CreationalContext

        return tryToInjectFields(contextController);
    }

    private <T> T tryToInjectFields(T instance)
    {
        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

   
    @Test
    @Ignore //TODO {porcelli} have no idea why weld can't start container =/
    public void testCopyAndRenameAndDelete() throws Exception {
        final Bean drlTextEditorServiceBean = (Bean) beanManager.getBeans( DecisionTableXLSService.class ).iterator().next();
        final CreationalContext cc = beanManager.createCreationalContext( drlTextEditorServiceBean );
        final DecisionTableXLSService drlTextEditorService = (DecisionTableXLSService) beanManager.getReference( drlTextEditorServiceBean,
                DecisionTableXLSService.class, cc );
              
        //Copy
        drlTextEditorService.copy(makePath( "/ProjectStructureValid/src/main/resources/org/kie/test/rule1.drl"), "copiedFromRule1.drl", "copied");       
View Full Code Here

Examples of javax.enterprise.context.spi.CreationalContext

        List<Contextual<?>> flowScopedBeansToRemove = new ArrayList<Contextual<?>>();
       
        for (Entry<Contextual<?>, Object> entry : flowScopedBeanMap.entrySet()) {
            Contextual owner = entry.getKey();
            Object bean = entry.getValue();
            CreationalContext creational = creationalMap.get(owner);
           
            owner.destroy(bean, creational);
            flowScopedBeansToRemove.add(owner);
        }
       
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.