Package org.apache.webbeans.container

Examples of org.apache.webbeans.container.BeanManagerImpl


        this.name = name;
    }

    public String echo()
    {
        BeanManagerImpl manager = BeanManagerImpl.getManager();
        Bean<?> b = manager.getBeans("injected").iterator().next();
        InjectionTargetBean bean = (InjectionTargetBean)manager.getReference(b, InjectionTargetBean.class, manager.createCreationalContext(b));
       
        System.out.println("EMF --> " + bean.getFactory().equals(this.emf));
       
        this.text = echo.echo(name);
       
View Full Code Here


     */   
    @Override
    @SuppressWarnings("unchecked")
    public Object getValue(ELContext context, Object obj, Object property) throws NullPointerException, PropertyNotFoundException, ELException
    {
        BeanManagerImpl manager = BeanManagerImpl.getManager();
        Object object = null;
        Bean<Object> bean = null;
        CreationalContext<Object> creationalContext = null;       
        ELContextStore store = null;
        boolean canBe = false;
       
        if (obj == null)
        {
            if((store = LOCAL_CONTEXT.get()) != null)
            {
                ELContext oldContext = store.getELContext();
                if(!oldContext.equals(context))
                {
                    store.destroy();
                    LOCAL_CONTEXT.remove();
                }
                else
                {
                    canBe = true;
                }
            }
                       
            String name = (String) property;           
            Set<Bean<?>> beans = manager.getBeans(name);
           
            if(beans != null && !beans.isEmpty())
            {
                bean = (Bean<Object>)beans.iterator().next();
                creationalContext = manager.createCreationalContext(bean);                   
               
                if(bean.getScope().equals(Dependent.class))
                {
                    if(canBe)
                    {
                       object = store.getDependent(bean);
                    }
                }                   
            }
           
           
            if(object == null)
            {
                object = manager.getInstanceByName(name,creationalContext);
               
                if (object != null)
                {                   
                    context.setPropertyResolved(true);
                   
View Full Code Here

public class ManagersImpl implements Managers
{

    public BeanManager getManager()
    {
        BeanManagerImpl impl = BeanManagerImpl.getManager();
       
        return impl;
    }
View Full Code Here

        return ((OwbBean) bean).isDependent();
    }
   
    public static void inspectErrorStack(String logMessage)
    {
        BeanManagerImpl manager = BeanManagerImpl.getManager();
        //Looks for errors
        ErrorStack stack = manager.getErrorStack();
        try
        {
            if(stack.hasErrors())
            {
                stack.logErrors();
View Full Code Here

            AnnotatedMethod<?> method = AnnotatedElementFactory.newAnnotatedMethod(impl.getObserverMethod(), impl.getBeanClass());
           
            observerMethodsMap.put(observerMethod, method);
        }
       
        BeanManagerImpl beanManager = BeanManagerImpl.getManager();
       
        //Fires ProcessManagedBean
        ProcessBeanImpl<T> processBeanEvent = new GProcessManagedBean(managedBean,annotatedType);           
        beanManager.fireEvent(processBeanEvent, new Annotation[0]);           
        WebBeansUtil.inspectErrorStack("There are errors that are added by ProcessManagedBean event observers for managed beans. Look at logs for further details");
       
        //Fires ProcessProducerMethod
        WebBeansUtil.fireProcessProducerMethodBeanEvent(annotatedMethods);           
        WebBeansUtil.inspectErrorStack("There are errors that are added by ProcessProducerMethod event observers for producer method beans. Look at logs for further details");           
       
        //Fires ProcessProducerField
        WebBeansUtil.fireProcessProducerFieldBeanEvent(annotatedFields);
        WebBeansUtil.inspectErrorStack("There are errors that are added by ProcessProducerField event observers for producer field beans. Look at logs for further details");           
       
        //Fire ObservableMethods
        WebBeansUtil.fireProcessObservableMethodBeanEvent(observerMethodsMap);
        WebBeansUtil.inspectErrorStack("There are errors that are added by ProcessObserverMethod event observers for observer methods. Look at logs for further details");
       
        //Set InjectionTarget that is used by the container to inject dependencies!
        if(managedBeanCreator.isInjectionTargetSet())
        {
            managedBean.setInjectionTarget(managedBeanCreator);  
        }

        beanManager.addBean(WebBeansUtil.createNewBean(managedBean));               
        if(!WebBeansAnnotatedTypeUtil.isAnnotatedTypeDecoratorOrInterceptor(annotatedType))
        {
            beanManager.addBean(managedBean);
            for (ProducerMethodBean<?> producerMethod : producerMethods)
            {
                // add them one after the other to enable serialization handling et al
                beanManager.addBean(producerMethod);
            }
            managedBeanCreator.defineDisposalMethods();//Define disposal method after adding producers
            for (ProducerFieldBean<?> producerField : producerFields)
            {
                // add them one after the other to enable serialization handling et al
                beanManager.addBean(producerField);
            }
        }
       
        return managedBean;
    }
View Full Code Here

   
    @SuppressWarnings("unchecked")
    @Override
    public Object invoke(Object instance, Method method, Method proceed, Object[] arguments) throws Exception
    {
        BeanManagerImpl beanManager = BeanManagerImpl.getManager();

        //Context of the bean
        Context webbeansContext = beanManager.getContext(bean.getScope());

        //Get bean instance from context
        Object webbeansInstance = webbeansContext.get((Contextual<Object>)this.bean, (CreationalContext<Object>) creationalContext);

        return super.invoke(webbeansInstance, method, proceed, arguments, (CreationalContextImpl<?>) creationalContext);
View Full Code Here

     */
    @Override
    protected List getMethodArguments(Object event)
    {
        List<Object> params = new ArrayList<Object>();
        BeanManagerImpl manager = BeanManagerImpl.getManager();
        for (XMLInjectionPointModel model : observersParameters)
        {
            Set<Annotation> setBindingTypes = model.getBindingTypes();
            Annotation[] anns = new Annotation[setBindingTypes.size()];
            anns = setBindingTypes.toArray(anns);
            params.add(manager.getInstance(InjectionResolver.getInstance().implResolveByType(model.getInjectionGenericType(), anns).iterator().next(),null));
        }

        return params;
    }
View Full Code Here

                //Invoke Method
                this.observerMethod.invoke(object, args);
            }
            else
            {
                BeanManagerImpl manager = BeanManagerImpl.getManager();
                specializedComponent = (AbstractOwbBean<Object>)WebBeansUtil.getMostSpecializedBean(manager, baseComponent);       
                Context context = manager.getContext(specializedComponent.getScope());
               
                creationalContext = manager.createCreationalContext(specializedComponent);
               
                // on Reception.IF_EXISTS: ignore this bean if a the contextual instance doesn't already exist
                if (ifExist && context.get(specializedComponent) == null)
                {
                    return;
                }
               
                // on Reception.ALWAYS we must get a contextual reference if we didn't find the contextual instance
                object = manager.getReference(specializedComponent, specializedComponent.getBeanClass(), creationalContext);
               
                if (object != null)
                {
                    //Invoke Method
                    this.observerMethod.invoke(object, args);
View Full Code Here

        Annotation[][] annots = this.observerMethod.getParameterAnnotations();

        List<ObserverParams> list = new ArrayList<ObserverParams>();

        BeanManagerImpl manager = BeanManagerImpl.getManager();
        ObserverParams param = null;
        if (types.length > 0)
        {
            int i = 0;
            for (Type type : types)
            {
                Annotation[] annot = annots[i];

                boolean observesAnnotation = false;

                if (annot.length == 0)
                {
                    annot = new Annotation[1];
                    annot[0] = new DefaultLiteral();
                }
                else
                {
                    for (Annotation observersAnnot : annot)
                    {
                        if (observersAnnot.annotationType().equals(Observes.class))
                        {
                            param = new ObserverParams();
                            param.instance = event;
                            list.add(param);
                            observesAnnotation = true;
                            break;
                        }
                    }
                }

                if (!observesAnnotation)
                {
                    //Get parameter annotations
                    Annotation[] bindingTypes = AnnotationUtil.getQualifierAnnotations(annot);

                    if (bindingTypes.length > 0)
                    {
                        InjectionPoint point = InjectionPointFactory.getPartialInjectionPoint(null, type, null, null, bindingTypes);
                        @SuppressWarnings("unchecked")
                        Bean<Object> bean = (Bean<Object>)InjectionResolver.getInstance().getInjectionPointBean(point);
                        CreationalContext<Object> creational = manager.createCreationalContext(bean);
                        Object instance = manager.getInstance(bean, creational);
                       
                        param = new ObserverParams();
                        param.isBean = true;
                        param.creational = creational;
                        param.instance = instance;
View Full Code Here

     * @throws WebBeansConfigurationException if any configuration exception occurs
     * @deprecated
     */
    public static <T> ManagedBean<T> define(Class<T> clazz, WebBeansType type) throws WebBeansConfigurationException
    {
        BeanManagerImpl manager = BeanManagerImpl.getManager();

        checkManagedBeanCondition(clazz);

        ManagedBean<T> component = new ManagedBean<T>(clazz, type);
       
        WebBeansUtil.setInjectionTargetBeanEnableFlag(component);  
       
        DefinitionUtil.defineSerializable(component);
        DefinitionUtil.defineStereoTypes(component, clazz.getDeclaredAnnotations());
               
        Annotation[] clazzAnns = clazz.getDeclaredAnnotations();

        DefinitionUtil.defineApiTypes(component, clazz);
        DefinitionUtil.defineScopeType(component, clazzAnns, "Simple WebBean Component implementation class : " + clazz.getName() + " stereotypes must declare same @Scope annotations");
       
        WebBeansUtil.checkGenericType(component);
        DefinitionUtil.defineQualifiers(component, clazzAnns);
        DefinitionUtil.defineName(component, clazzAnns, WebBeansUtil.getManagedBeanDefaultName(clazz.getSimpleName()));

        Constructor<T> constructor = WebBeansUtil.defineConstructor(clazz);
        component.setConstructor(constructor);
        DefinitionUtil.addConstructorInjectionPointMetaData(component, constructor);

        //Dropped from the speicification
        //WebBeansUtil.checkSteroTypeRequirements(component, clazz.getDeclaredAnnotations(), "Simple WebBean Component implementation class : " + clazz.getName());

        Set<ProducerMethodBean<?>> producerMethods = DefinitionUtil.defineProducerMethods(component);
        for (ProducerMethodBean<?> producerMethod : producerMethods)
        {
            // add them one after the other to enable serialization handling et al
            manager.addBean(producerMethod);
        }
       
        Set<ProducerFieldBean<?>> producerFields = DefinitionUtil.defineProduerFields(component);
        for (ProducerFieldBean<?> producerField : producerFields)
        {
            // add them one after the other to enable serialization handling et al
            manager.addBean(producerField);
        }
       

        DefinitionUtil.defineDisposalMethods(component);
        DefinitionUtil.defineInjectedFields(component);
View Full Code Here

TOP

Related Classes of org.apache.webbeans.container.BeanManagerImpl

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.