Examples of WebBeansContext


Examples of org.apache.webbeans.config.WebBeansContext

        //Read for contextual
        String id = (String) s.readObject();
        if (id != null)
        {
            WebBeansContext webBeansContext = WebBeansContext.currentInstance();
            contextual = (Contextual<S>) webBeansContext.getBeanManagerImpl().getPassivationCapableBean(id);
        }
    }
View Full Code Here

Examples of org.apache.webbeans.config.WebBeansContext

        private  void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException
        {
            if(s.readLong() == serialVersionUID)
            {
                String id = (String)s.readObject();
                WebBeansContext webBeansContext = WebBeansContext.currentInstance();
                bean = (BuildInOwbBean<T>)webBeansContext.getBeanManagerImpl().getPassivationCapableBean(id);
                // create new real instance after deserialized.
                actualObject = bean.createActualInstance(null);
            }
            else
            {
View Full Code Here

Examples of org.apache.webbeans.config.WebBeansContext

       
    }
       
    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(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();       
        checkProducerMethods(producerMethodBeans, 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()));
        }
       
        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()));
        }
       
        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
View Full Code Here

Examples of org.apache.webbeans.config.WebBeansContext

   
    public static <T> void defineSpecializedData(Class<T> clazz, BaseEjbBean<T> ejbBean)
    {
        final String message = "There are errors that are added by %s event observers for %s. Look at logs for further details";

        final WebBeansContext webBeansContext = ejbBean.getWebBeansContext();
        final BeanManagerImpl manager = webBeansContext.getBeanManagerImpl();

        final AnnotatedElementFactory annotatedElementFactory = webBeansContext.getAnnotatedElementFactory();

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

        final DefinitionUtil util = webBeansContext.getDefinitionUtil();

        final Set<ProducerMethodBean<?>> producerMethodBeans = util.defineProducerMethods(ejbBean, clazz);

        final Set<ProducerFieldBean<?>> producerFieldBeans = util.defineProducerFields(ejbBean, clazz);

        checkProducerMethods(producerMethodBeans, ejbBean);

        // PRODUCER METHODS
        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(String.format(message, "ProcessProducer", "ProducerMethods"));

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

        // PRODUCER FIELDS
        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(String.format(message, "ProcessProducer", "ProducerFields"));

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

        //Fires ProcessProducerMethod
        webBeansContext.getWebBeansUtil().fireProcessProducerMethodBeanEvent(annotatedMethods, annotatedType);
        webBeansContext.getWebBeansUtil().inspectErrorStack(String.format(message, "ProcessProducerMethod", "producer method beans"));

        //Fires ProcessProducerField
        webBeansContext.getWebBeansUtil().fireProcessProducerFieldBeanEvent(annotatedFields);
        webBeansContext.getWebBeansUtil().inspectErrorStack(String.format(message, "ProcessProducerField", "producer field beans"));

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

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

Examples of org.apache.webbeans.config.WebBeansContext

        Collection<Class<?>> classes = new ArrayList<Class<?>>();
        classes.add(ExternalTestScopedBean.class);
        addExtension(new ExternalTestScopeExtension());
        startContainer(classes);

        WebBeansContext webBeansContext = WebBeansContext.getInstance();
        webBeansContext.getContextFactory().initApplicationContext(null);

        @SuppressWarnings("unchecked")
        Bean<ExternalTestScopedBean> bean = (Bean<ExternalTestScopedBean>) getBeanManager().getBeans(ExternalTestScopedBean.class,
                                                                                                     new DefaultLiteral()).iterator().next();
       
        ExternalTestScopedBean instance = (ExternalTestScopedBean) getBeanManager().getReference(bean, ExternalTestScopedBean.class,
                                                                                                 getBeanManager().createCreationalContext(bean));
       
        Assert.assertNotNull(instance);
       
        Assert.assertTrue(getBeanManager().isPassivatingScope(ExternalTestScoped.class));
       
        //Fire shut down
        getBeanManager().fireEvent(new BeforeShutdownImpl());

        webBeansContext.getContextFactory().destroyApplicationContext(null);

        shutDownContainer();
       
    }
View Full Code Here

Examples of org.apache.webbeans.config.WebBeansContext

    private List<AbstractOwbBean<?>> componentList = new ArrayList<AbstractOwbBean<?>>();

    public MockManager()
    {
        WebBeansFinder.clearInstances(WebBeansUtil.getCurrentClassLoader());
        WebBeansContext webBeansContext = WebBeansContext.getInstance();
        this.manager = webBeansContext.getBeanManagerImpl();
        manager.addBean(webBeansContext.getWebBeansUtil().getManagerBean());
    }
View Full Code Here

Examples of org.apache.webbeans.config.WebBeansContext

     */
    public void writeExternal(ObjectOutput out) throws IOException
    {       
        // write bean id first
        out.writeObject(bean.getId());
        WebBeansContext webBeansContext = WebBeansContext.getInstance();
        ResourceInjectionService resourceInjectionService = webBeansContext.getService(ResourceInjectionService.class);
        resourceInjectionService.writeExternal(bean, actualResource, out);
    }
View Full Code Here

Examples of org.apache.webbeans.config.WebBeansContext

    }

    public void readExternal(ObjectInput in) throws IOException,
            ClassNotFoundException
    {
        WebBeansContext webBeansContext = WebBeansContext.currentInstance();

        scopeType = (Class<? extends Annotation>) in.readObject();
        Map<String, BeanInstanceBag<?>> map = (Map<String, BeanInstanceBag<?>>)in.readObject();
        setComponentInstanceMap();
        Iterator<String> it = map.keySet().iterator();
        Contextual<?> contextual = null;
        while(it.hasNext())
        {
            String id = it.next();
            if (id != null)
            {
                contextual = webBeansContext.getBeanManagerImpl().getPassivationCapableBean(id);
            }
            if (contextual != null)
            {
                componentInstanceMap.put(contextual, map.get(id));
            }
View Full Code Here

Examples of org.apache.webbeans.config.WebBeansContext

     */
    public void readExternal(ObjectInput in) throws IOException,
            ClassNotFoundException
    {
        String id = (String)in.readObject();
        WebBeansContext webBeansContext = WebBeansContext.currentInstance();
        bean = (ResourceBean) webBeansContext.getBeanManagerImpl().getPassivationCapableBean(id);
        ResourceInjectionService resourceInjectionService = webBeansContext.getService(ResourceInjectionService.class);
        actualResource = resourceInjectionService.readExternal(bean, in);
    }
View Full Code Here

Examples of org.apache.webbeans.config.WebBeansContext

     * @return list of observer method parameters
     */
    @SuppressWarnings("unchecked")
    protected List<ObserverParams> getMethodArguments(Object event)
    {
        WebBeansContext webBeansContext = bean.getWebBeansContext();
        AnnotatedElementFactory annotatedElementFactory = webBeansContext.getAnnotatedElementFactory();
        AnnotationManager annotationManager = webBeansContext.getAnnotationManager();

        Type[] types = observerMethod.getGenericParameterTypes();
        Annotation[][] annots = observerMethod.getParameterAnnotations();
        List<ObserverParams> list = new ArrayList<ObserverParams>();

        BeanManagerImpl manager = webBeansContext.getBeanManagerImpl();
        ObserverParams param;
        if (types.length > 0)
        {
            int i = 0;
            for (Type type : types)
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.