Package org.apache.webbeans.container

Examples of org.apache.webbeans.container.BeanManagerImpl


    }

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

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


    /**
     * 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 Validator Bean
        beanManager.addBean(new ValidatorBean());
       
        //Register ValidatorFactory Bean
        beanManager.addBean(new ValidatorFactoryBean());
       
        //Register Principal Bean
        beanManager.addBean(new PrinicipalBean());
    }
View Full Code Here

    /**
     * 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

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

     */
    private void validateInjectionPoints()
    {
        logger.debug("Validation of injection points has started.");

        BeanManagerImpl manager = BeanManagerImpl.getManager();       
        Set<Bean<?>> beans = new HashSet<Bean<?>>();
       
        //Adding decorators to validate
        Set<Decorator<?>> decorators = manager.getDecorators();
        for(Decorator decorator : decorators)
        {
            WebBeansDecorator wbDec = (WebBeansDecorator)decorator;
            beans.add(wbDec);
        }
       
       
        logger.debug("Validation of the decorator's injection points has started.");
       
        //Validate Decorators
        validate(beans);
       
        beans.clear();
       
        //Adding interceptors to validate
        Set<javax.enterprise.inject.spi.Interceptor<?>> interceptors = manager.getInterceptors();
        for(javax.enterprise.inject.spi.Interceptor interceptor : interceptors)
        {
            WebBeansInterceptor wbInt = (WebBeansInterceptor)interceptor;
            beans.add(wbInt);
        }
       
        logger.debug("Validation of the interceptor's injection points has started.");
       
        //Validate Interceptors
        validate(beans);
       
        beans.clear();
       
        beans = manager.getBeans();
       
        //Validate Others
        validate(beans);
               

View Full Code Here

     *
     * @param beans deployed beans
     */
    private void validate(Set<Bean<?>> beans)
    {
        BeanManagerImpl manager = BeanManagerImpl.getManager();
       
        if (beans != null && beans.size() > 0)
        {
            for (Bean<?> bean : beans)
            {
                //Configure decorator and interceptor stack for ManagedBeans
                if((bean instanceof AbstractInjectionTargetBean) &&
                        !(bean instanceof NewBean))
                {
                    if(!(bean instanceof Decorator) && !(bean instanceof javax.enterprise.inject.spi.Interceptor))
                    {
                        DefinitionUtil.defineDecoratorStack((AbstractInjectionTargetBean<Object>)bean);  
                    }
                   
                    if(!(bean instanceof javax.enterprise.inject.spi.Interceptor) &&
                            !(bean instanceof NewBean))
                    {
                        DefinitionUtil.defineBeanInterceptorStack((AbstractInjectionTargetBean<Object>)bean);  
                    }
                }
               
                checkPassivationScope(bean);
                               
                //Bean injection points
                Set<InjectionPoint> injectionPoints = bean.getInjectionPoints();
                               
                if(injectionPoints != null)
                {
                    for (InjectionPoint injectionPoint : injectionPoints)
                    {
                        if(!injectionPoint.isDelegate())
                        {
                            manager.validate(injectionPoint);  
                        }
                        else
                        {
                            if(!bean.getBeanClass().isAnnotationPresent(javax.decorator.Decorator.class))
                            {
View Full Code Here

                final CdiEjbBean<Object> bean = beanContext.get(CdiEjbBean.class);;

                if (bean == null) continue;

                final BeanManagerImpl manager = webBeansContext.getBeanManagerImpl();
                manager.addBean(new NewCdiEjbBean<Object>(bean));
            }

        } catch (Exception e1) {
            Assembler.logger.error("CDI Beans module deployment failed", e1);
            throw new RuntimeException(e1);
View Full Code Here

    }

    public static <T> void fireEvents(Class<T> clazz, BaseEjbBean<T> ejbBean,ProcessAnnotatedType<T> event)
    {
        WebBeansContext webBeansContext = ejbBean.getWebBeansContext();
        BeanManagerImpl manager = webBeansContext.getBeanManagerImpl();
        AnnotatedElementFactory annotatedElementFactory = webBeansContext.getAnnotatedElementFactory();

        AnnotatedType<T> annotatedType = annotatedElementFactory.newAnnotatedType(clazz);

        //Fires ProcessAnnotatedType
        ProcessAnnotatedTypeImpl<T> processAnnotatedEvent = (ProcessAnnotatedTypeImpl<T>)event;
        EjbBeanCreatorImpl<T> ejbBeanCreator = new EjbBeanCreatorImpl<T>(ejbBean);
        ejbBeanCreator.checkCreateConditions();

        if(processAnnotatedEvent.isVeto())
        {
            return;
        }

        if(processAnnotatedEvent.isModifiedAnnotatedType())
        {
            ejbBeanCreator.setMetaDataProvider(BeanCreator.MetaDataProvider.THIRDPARTY);
            ejbBeanCreator.setAnnotatedType(annotatedType);
        }

        //Define meta-data
        ejbBeanCreator.defineSerializable();
        ejbBeanCreator.defineStereoTypes();
        ejbBeanCreator.defineApiType();
        ejbBeanCreator.defineScopeType("Session Bean implementation class : " + clazz.getName() + " stereotypes must declare same @ScopeType annotations", false);
        ejbBeanCreator.defineQualifier();
        ejbBeanCreator.defineName(WebBeansUtil.getManagedBeanDefaultName(clazz.getSimpleName()));
        Set<ProducerMethodBean<?>> producerMethodBeans = ejbBeanCreator.defineProducerMethods();
        for(ProducerMethodBean<?> producerMethodBean : producerMethodBeans)
        {
            Method producerMethod = producerMethodBean.getCreatorMethod();
            if(!Modifier.isStatic(producerMethod.getModifiers()))
            {
                if(!EjbUtility.isBusinessMethod(producerMethod, ejbBean))
                {
                    throw new WebBeansConfigurationException("Producer Method Bean must be business method of session bean : " + ejbBean);
                }
            }
        }
        Set<ProducerFieldBean<?>> producerFieldBeans = ejbBeanCreator.defineProducerFields();
        ejbBeanCreator.defineInjectedFields();
        ejbBeanCreator.defineInjectedMethods();
        Set<ObserverMethod<?>> observerMethods = ejbBeanCreator.defineObserverMethods();

        //Fires ProcessInjectionTarget
        ProcessInjectionTargetImpl<T> processInjectionTargetEvent =
                webBeansContext.getWebBeansUtil().fireProcessInjectionTargetEvent(ejbBean);
        webBeansContext.getWebBeansUtil().inspectErrorStack(
                "There are errors that are added by ProcessInjectionTarget event observers. Look at logs for further details");
        //Put final InjectionTarget instance
        manager.putInjectionTargetWrapper(ejbBean, new InjectionTargetWrapper(processInjectionTargetEvent.getInjectionTarget()));

        Map<ProducerMethodBean<?>,AnnotatedMethod<?>> annotatedMethods = new HashMap<ProducerMethodBean<?>, AnnotatedMethod<?>>();
        for(ProducerMethodBean<?> producerMethod : producerMethodBeans)
        {
            AnnotatedMethod<?> method = annotatedElementFactory.newAnnotatedMethod(producerMethod.getCreatorMethod(), annotatedType);
            ProcessProducerImpl<?, ?> producerEvent =
                    webBeansContext.getWebBeansUtil().fireProcessProducerEventForMethod(producerMethod,
                            method);
            webBeansContext.getWebBeansUtil().inspectErrorStack(
                    "There are errors that are added by ProcessProducer event observers for ProducerMethods. Look at logs for further details");

            annotatedMethods.put(producerMethod, method);
            manager.putInjectionTargetWrapper(producerMethod, new InjectionTargetWrapper(producerEvent.getProducer()));

            producerEvent.setProducerSet(false);
        }

        Map<ProducerFieldBean<?>,AnnotatedField<?>> annotatedFields = new HashMap<ProducerFieldBean<?>, AnnotatedField<?>>();
        for(ProducerFieldBean<?> producerField : producerFieldBeans)
        {
            AnnotatedField<?> field = annotatedElementFactory.newAnnotatedField(producerField.getCreatorField(), annotatedType);
            ProcessProducerImpl<?, ?> producerEvent =
                    webBeansContext.getWebBeansUtil().fireProcessProducerEventForField(producerField, field);
            webBeansContext.getWebBeansUtil().inspectErrorStack(
                    "There are errors that are added by ProcessProducer event observers for ProducerFields. Look at logs for further details");

            annotatedFields.put(producerField, field);
            manager.putInjectionTargetWrapper(producerField, new InjectionTargetWrapper(producerEvent.getProducer()));


            producerEvent.setProducerSet(false);
        }

        Map<ObserverMethod<?>,AnnotatedMethod<?>> observerMethodsMap = new HashMap<ObserverMethod<?>, AnnotatedMethod<?>>();
        for(ObserverMethod<?> observerMethod : observerMethods)
        {
            ObserverMethodImpl<?> impl = (ObserverMethodImpl<?>)observerMethod;
            AnnotatedMethod<?> method = annotatedElementFactory.newAnnotatedMethod(impl.getObserverMethod(), annotatedType);

            observerMethodsMap.put(observerMethod, method);
        }

        //Fires ProcessManagedBean
        ProcessSessionBeanImpl<T> processBeanEvent = new GProcessSessionBean((Bean<Object>)ejbBean,annotatedType,ejbBean.getEjbName(),ejbBean.getEjbType());
        webBeansContext.getBeanManagerImpl().fireEvent(processBeanEvent, new Annotation[0]);
        webBeansContext.getWebBeansUtil().inspectErrorStack(
                "There are errors that are added by ProcessSessionBean event observers for managed beans. Look at logs for further details");

        //Fires ProcessProducerMethod
        webBeansContext.getWebBeansUtil().fireProcessProducerMethodBeanEvent(annotatedMethods,
                annotatedType);
        webBeansContext.getWebBeansUtil().inspectErrorStack(
                "There are errors that are added by ProcessProducerMethod event observers for producer method beans. Look at logs for further details");

        //Fires ProcessProducerField
        webBeansContext.getWebBeansUtil().fireProcessProducerFieldBeanEvent(annotatedFields);
        webBeansContext.getWebBeansUtil().inspectErrorStack(
                "There are errors that are added by ProcessProducerField event observers for producer field beans. Look at logs for further details");

        //Fire ObservableMethods
        webBeansContext.getWebBeansUtil().fireProcessObservableMethodBeanEvent(observerMethodsMap);
        webBeansContext.getWebBeansUtil().inspectErrorStack(
                "There are errors that are added by ProcessObserverMethod event observers for observer methods. Look at logs for further details");

        manager.addBean(ejbBean);

        // Let the plugin handle adding the new bean instance as it knows more about its EJB Bean

        manager.getBeans().addAll(producerMethodBeans);
        ejbBeanCreator.defineDisposalMethods();
        manager.getBeans().addAll(producerFieldBeans);
    }
View Full Code Here

    public void integrateCDIAndJaxRsInjections(@Observes final WebBeansContextCreated event) {
        contextCDIIntegration(event.getContext());
    }

    private void contextCDIIntegration(final WebBeansContext wbc) {
        final BeanManagerImpl beanManagerImpl = wbc.getBeanManagerImpl();
        beanManagerImpl.addAdditionalQualifier(Context.class);
        beanManagerImpl.addInternalBean(new ContextBean<SecurityContext>(SecurityContext.class, ThreadLocalContextManager.SECURITY_CONTEXT));
        beanManagerImpl.addInternalBean(new ContextBean<UriInfo>(UriInfo.class, ThreadLocalContextManager.URI_INFO));
        beanManagerImpl.addInternalBean(new ContextBean<HttpServletRequest>(HttpServletRequest.class, ThreadLocalContextManager.HTTP_SERVLET_REQUEST));
        beanManagerImpl.addInternalBean(new ContextBean<HttpServletResponse>(HttpServletResponse.class, ThreadLocalContextManager.HTTP_SERVLET_RESPONSE));
        beanManagerImpl.addInternalBean(new ContextBean<HttpHeaders>(HttpHeaders.class, ThreadLocalContextManager.HTTP_HEADERS));
        beanManagerImpl.addInternalBean(new ContextBean<Request>(Request.class, ThreadLocalContextManager.REQUEST));
        beanManagerImpl.addInternalBean(new ContextBean<ServletRequest>(ServletRequest.class, ThreadLocalContextManager.SERVLET_REQUEST));
        beanManagerImpl.addInternalBean(new ContextBean<ServletContext>(ServletContext.class, ThreadLocalContextManager.SERVLET_CONTEXT));
        beanManagerImpl.addInternalBean(new ContextBean<ServletConfig>(ServletConfig.class, ThreadLocalContextManager.SERVLET_CONFIG));
        beanManagerImpl.addInternalBean(new ContextBean<Providers>(Providers.class, ThreadLocalContextManager.PROVIDERS));
        beanManagerImpl.addInternalBean(new ContextBean<ContextResolver>(ContextResolver.class, ThreadLocalContextManager.CONTEXT_RESOLVER));
    }
View Full Code Here

            return;
        }

        final BeanContext context = SystemInstance.get().getComponent(ContainerSystem.class).getBeanContext(ctx.getId() + "_" + testInstance.getClass().getName());

        final BeanManagerImpl bm = findBeanManager(ctx);
        if (bm != null && bm.isInUse()) {
            try {
                final Set<Bean<?>> beans = bm.getBeans(testInstance.getClass());
                final Bean<?> bean = bm.resolve(beans);
                final CreationalContext<?> cc = bm.createCreationalContext(bean);
                if (context != null) {
                    context.set(CreationalContext.class, cc);
                }
                OWBInjector.inject(bm, testInstance, cc);
            } catch (final Throwable t) {
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.