Examples of BeanManagerImpl


Examples of org.apache.webbeans.container.BeanManagerImpl

                //Invoke Method
                this.observerMethod.invoke(object, args);
            }
            else
            {
                BeanManagerImpl manager = BeanManagerImpl.getManager();
                specializedComponent = (AbstractOwbBean<Object>)WebBeansUtil.getMostSpecializedBean(manager, baseComponent);       
                Context context = null;
                try
                {
                    context = manager.getContext(specializedComponent.getScope());
                }
                catch (ContextNotActiveException cnae)
                {
                    // this may happen if we try to e.g. send an event to a @ConversationScoped bean from a ServletListener
                    logger.info(OWBLogConst.INFO_0010, bean);
                    return;
                }
               
                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

Examples of org.apache.webbeans.container.BeanManagerImpl

       
        Type[] types = this.observerMethod.getGenericParameterTypes();
        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);
                   
                    //Annotated parameter
                    AnnotatedParameter<T> annotatedParameter = annotatedMethod.getParameters().get(i);
                   
                    //Creating injection point
                    InjectionPoint point = InjectionPointFactory.getPartialInjectionPoint(this.bean, type, this.observerMethod, annotatedParameter, bindingTypes);
                   
                    //Injected Bean
                    Bean<Object> injectedBean = (Bean<Object>)InjectionResolver.getInstance().getInjectionPointBean(point);
                   
                    //Set for @Inject InjectionPoint
                    if(WebBeansUtil.isDependent(injectedBean))
                    {
                        if(!InjectionPoint.class.isAssignableFrom(ClassUtil.getClass(point.getType())))
                        {
                            InjectionPointBean.local.set(point);  
                        }
                    }                          
                   
                    CreationalContext<Object> creational = manager.createCreationalContext(injectedBean);
                    Object instance = manager.getInstance(injectedBean, creational);
                   
                    param = new ObserverParams();
                    param.isBean = true;
                    param.creational = creational;
                    param.instance = instance;
View Full Code Here

Examples of org.apache.webbeans.container.BeanManagerImpl

     * @param event event payload
     * @return observer method parameters
     */
    protected List<ObserverParams> getAnnotatedMethodArguments(Object event)
    {
        BeanManagerImpl manager = BeanManagerImpl.getManager();
        List<ObserverParams> list = new ArrayList<ObserverParams>();
        List<AnnotatedParameter<T>> parameters = this.annotatedMethod.getParameters();
        ObserverParams param = null;
        for(AnnotatedParameter<T> parameter : parameters)
        {
            if(parameter.isAnnotationPresent(Observes.class))
            {
                param = new ObserverParams();
                param.instance = event;
                list.add(param);                
            }
            else
            {
                //Get parameter annotations
                Annotation[] bindingTypes = AnnotationUtil.getQualifierAnnotations(AnnotationUtil.
                        getAnnotationsFromSet(parameter.getAnnotations()));

                InjectionPoint point = InjectionPointFactory.getPartialInjectionPoint(this.bean, parameter.getBaseType(),
                        parameter.getDeclaringCallable().getJavaMember(), parameter, bindingTypes);

                //Get observer parameter instance
                @SuppressWarnings("unchecked")
                Bean<Object> injectedBean = (Bean<Object>)InjectionResolver.getInstance().getInjectionPointBean(point);

                //Set for @Inject InjectionPoint
                if(WebBeansUtil.isDependent(injectedBean))
                {
                    if(!InjectionPoint.class.isAssignableFrom(ClassUtil.getClass(point.getType())))
                    {
                        InjectionPointBean.local.set(point);  
                    }
                }                   
               
                CreationalContext<Object> creational = manager.createCreationalContext(injectedBean);
                Object instance = manager.getInstance(injectedBean, creational);
                                   
                param = new ObserverParams();
                param.isBean = true;
                param.creational = creational;
                param.instance = instance;
View Full Code Here

Examples of org.apache.webbeans.container.BeanManagerImpl

    @Override
    @SuppressWarnings("unchecked")
    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

Examples of org.apache.webbeans.container.BeanManagerImpl

    /**
     * Configure Default Beans.
     */
    private void configureDefaultBeans()
    {
        BeanManagerImpl beanManager = BeanManagerImpl.getManager();
       
        // Register Conversation built-in component
        beanManager.addBean(WebBeansUtil.getConversationBean());
       
        // Register InjectionPoint bean
        beanManager.addBean(WebBeansUtil.getInjectionPointBean());
       
        //Register Instance Bean
        beanManager.addBean(WebBeansUtil.getInstanceBean());
       
        //Register Event Bean
        beanManager.addBean(WebBeansUtil.getEventBean());
       
        //REgister Provider Beans
        OpenWebBeansJavaEEPlugin beanEeProvider = PluginLoader.getInstance().getJavaEEPlugin();
        OpenWebBeansWebPlugin beanWebProvider = PluginLoader.getInstance().getWebPlugin();
       
View Full Code Here

Examples of org.apache.webbeans.container.BeanManagerImpl

    }

    public static NotificationManager getInstance()
    {
        BeanManagerImpl manager = BeanManagerImpl.getManager();

        return manager.getNotificationManager();
    }
View Full Code Here

Examples of org.apache.webbeans.container.BeanManagerImpl

    /**
     * Fires event after bean discovery.
     */
    private void fireAfterBeanDiscoveryEvent()
    {
        BeanManagerImpl manager = BeanManagerImpl.getManager();
        manager.fireEvent(new AfterBeanDiscoveryImpl(),new Annotation[0]);
       
        WebBeansUtil.inspectErrorStack("There are errors that are added by AfterBeanDiscovery event observers. Look at logs for further details");
    }
View Full Code Here

Examples of org.jboss.weld.manager.BeanManagerImpl

            return context.proceed();
        }
    }

    protected InterceptorBindings getInterceptorBindings(String ejbName) {
        BeanManagerImpl beanManager = (BeanManagerImpl) this.beanManager;
        EjbServices ejbServices = beanManager.getServices().get(EjbServices.class);
        if (ejbServices instanceof ForwardingEjbServices) {
            ejbServices = ((ForwardingEjbServices) ejbServices).delegate();
        }
        InterceptorBindings interceptorBindings = null;
        if (ejbServices instanceof WeldEjbServices) {
View Full Code Here

Examples of org.jboss.weld.manager.BeanManagerImpl

            return context.proceed();
        }
    }

    protected InterceptorBindings getInterceptorBindings(String ejbName) {
        BeanManagerImpl beanManager = (BeanManagerImpl) this.beanManager;
        EjbServices ejbServices = beanManager.getServices().get(EjbServices.class);
        if (ejbServices instanceof ForwardingEjbServices) {
            ejbServices = ((ForwardingEjbServices) ejbServices).delegate();
        }
        InterceptorBindings interceptorBindings = null;
        if (ejbServices instanceof WeldEjbServices) {
View Full Code Here

Examples of org.jboss.weld.manager.BeanManagerImpl

        if (requestContext == null) {
            //it does not matter if this happens twice
            //we just look up the service rather than using a dependency
            //the component itself has a dependency on this service, which means that it has to be up
            final WeldContainer weldContainer = (WeldContainer) CurrentServiceContainer.getServiceContainer().getRequiredService(weldContainerServiceName).getValue();
            final BeanManagerImpl beanManager = (BeanManagerImpl) weldContainer.getBeanManager();
            final Bean<?> bean = beanManager.resolve(beanManager.getBeans(EjbRequestContext.class, EjbLiteral.INSTANCE));
            final CreationalContext<?> ctx = beanManager.createCreationalContext(bean);
            requestContext = (EjbRequestContext) beanManager.getReference(bean, EjbRequestContext.class, ctx);
        }
        try {
            requestContext.associate(context.getInvocationContext());
            requestContext.activate();
            return context.proceed();
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.