Examples of WebBeansContext


Examples of org.apache.webbeans.config.WebBeansContext

     * @param event event payload
     * @return observer method parameters
     */
    protected List<ObserverParams> getAnnotatedMethodArguments(Object event)
    {
        final WebBeansContext webBeansContext = bean.getWebBeansContext();
        final AnnotationManager annotationManager = webBeansContext.getAnnotationManager();
        final BeanManagerImpl manager = webBeansContext.getBeanManagerImpl();
        List<ObserverParams> list = new ArrayList<ObserverParams>();
        List<AnnotatedParameter<T>> parameters = annotatedMethod.getParameters();
        ObserverParams param = null;
        for(AnnotatedParameter<T> parameter : parameters)
        {
View Full Code Here

Examples of org.apache.webbeans.config.WebBeansContext

        ClassLoader classLoader = (ClassLoader) key;
        synchronized (singletonMap)
        {
            //util.Track.sync(key);
           
            WebBeansContext webBeansContext = singletonMap.get(classLoader);
            //util.Track.get(key);

            if (webBeansContext == null)
            {
                webBeansContext = new WebBeansContext();
                singletonMap.put(classLoader, webBeansContext);
            }

            return webBeansContext;
View Full Code Here

Examples of org.apache.webbeans.config.WebBeansContext

        ObjectInputStream in = new CustomObjectInputStream(inp, WebBeansUtil.getCurrentClassLoader());

        Class<?> beanClass = (Class<?>)in.readObject();
        Set<Annotation> anns = new HashSet<Annotation>();
        WebBeansContext webBeansContext = WebBeansContext.currentInstance();
        AnnotatedElementFactory annotatedElementFactory = webBeansContext.getAnnotatedElementFactory();

        while(!in.readObject().equals('~'))   // read throw-away '-' or '~' terminal delimiter.
        {
            Annotation ann = (Annotation) in.readObject()// now read the annotation.
            anns.add(ann);
        }
       
        //process annotations
        ownerBean = webBeansContext.getBeanManagerImpl().getBeans(beanClass, anns.toArray(new Annotation[anns.size()])).iterator().next();
        qualifierAnnotations = anns;
       
        // determine type of injection point member (0=field, 1=method, 2=constructor) and read...
        int c = in.readByte();
        if(c == 0)
        {
            String fieldName = in.readUTF();
            Field field = webBeansContext.getSecurityService().doPrivilegedGetDeclaredField(beanClass, fieldName);

            injectionMember = field;
           
            AnnotatedType<?> annotatedType = annotatedElementFactory.newAnnotatedType(beanClass);
            annotated = annotatedElementFactory.newAnnotatedField(field, annotatedType);
            injectionType = field.getGenericType();
           
        }
        else if(c == 1)
        {
            String methodName = in.readUTF();
            Class<?>[] parameters = (Class<?>[])in.readObject();
           
            Method method = webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethod(beanClass, methodName, parameters);
            injectionMember = method;
           
            AnnotatedType<?> annotatedType = annotatedElementFactory.newAnnotatedType(beanClass);
            AnnotatedMethod<Object> am =  (AnnotatedMethod<Object>)annotatedElementFactory.
                                    newAnnotatedMethod((Method) injectionMember,annotatedType);
View Full Code Here

Examples of org.apache.webbeans.config.WebBeansContext

        if(customDecorator != null)
        {
            return customDecorator.create(creationalContext);
        }

        WebBeansContext webBeansContext = wrappedBean.getWebBeansContext();
        Context context = webBeansContext.getBeanManagerImpl().getContext(getScope());
        Object actualInstance = context.get((Bean<Object>) wrappedBean, (CreationalContext<Object>)creationalContext);
        T proxy = (T) webBeansContext.getJavassistProxyFactory().createDependentScopedBeanProxy(wrappedBean, actualInstance, creationalContext);
       
        return proxy;       
    }
View Full Code Here

Examples of org.apache.webbeans.config.WebBeansContext

    }
   
    @SuppressWarnings("unchecked")
    public <X> Set<ObserverMethod<?>> defineObserverMethods(AbstractInjectionTargetBean<X> bean,AnnotatedType<X> annotatedType)
    {
        WebBeansContext webBeansContext = bean.getWebBeansContext();
        Set<ObserverMethod<?>> definedObservers = new HashSet<ObserverMethod<?>>();
        Set<AnnotatedMethod<? super X>> annotatedMethods = annotatedType.getMethods();   
        for (AnnotatedMethod<? super X> annotatedMethod : annotatedMethods)
        {
            AnnotatedMethod<X> annt = (AnnotatedMethod<X>)annotatedMethod;
            List<AnnotatedParameter<X>> parameters = annt.getParameters();
            boolean found = false;
            for(AnnotatedParameter<X> parameter : parameters)
            {
                if(parameter.isAnnotationPresent(Observes.class))
                {
                    found = true;
                    break;
                }
            }
           
            if(found)
            {
                checkObserverMethodConditions(annotatedMethod, annotatedMethod.getDeclaringType().getJavaClass());
                if(bean.getScope().equals(Dependent.class))
                {
                    //Check Reception
                     AnnotationUtil.getAnnotatedMethodFirstParameterWithAnnotation(annotatedMethod, Observes.class);
                   
                     Observes observes = AnnotationUtil.getAnnotatedMethodFirstParameterAnnotation(annotatedMethod, Observes.class);
                     Reception reception = observes.notifyObserver();
                     if(reception.equals(Reception.IF_EXISTS))
                     {
                         throw new WebBeansConfigurationException("Dependent Bean : " + bean + " can not define observer method with @Receiver = IF_EXIST");
                     }
                }
               
                //Add method
                bean.addObservableMethod(annotatedMethod.getJavaMember());

                //Add injection point data
                addMethodInjectionPointMetaData(bean, annotatedMethod);
               
                //Looking for ObserverMethod
                ObserverMethod<?> definedObserver = webBeansContext.getBeanManagerImpl().getNotificationManager().getObservableMethodForAnnotatedMethod(annotatedMethod, bean);
                if(definedObserver != null)
                {
                    definedObservers.add(definedObserver);
                }
            }
View Full Code Here

Examples of org.apache.webbeans.config.WebBeansContext

    }

    // manually add the correct LifecycleInterceptorBbd
    public void observeLiveCycleInterceptorBbd(@Observes BeforeBeanDiscovery bbd)
    {
        WebBeansContext webBeansContext = WebBeansContext.getInstance();
        AnnotatedTypeImpl<LifecycleInterceptorBbd> annotatedType =
                new AnnotatedTypeImpl<LifecycleInterceptorBbd>(LifecycleInterceptorBbd.class );

        Set<Annotation> anns = new HashSet<Annotation>();
        anns.add(new AnnotationLiteral<LifecycleBinding>(){});
View Full Code Here

Examples of org.apache.webbeans.config.WebBeansContext

    }

    public void startContexts() throws Exception
    {
        logger.log(Level.FINE, "starting all OWB Contexts");
        WebBeansContext webBeansContext = WebBeansContext.currentInstance();
        ContextsService contextsService = webBeansContext.getContextsService();

        contextsService.startContext(Singleton.class, servletContext);
        contextsService.startContext(ApplicationScoped.class, servletContext);
        contextsService.startContext(SessionScoped.class, session);
        contextsService.startContext(ConversationScoped.class, null);
View Full Code Here

Examples of org.apache.webbeans.config.WebBeansContext

    }

    public void startApplicationScope() throws Exception
    {
        logger.log(Level.FINE, "starting the OWB ApplicationContext");
        WebBeansContext webBeansContext = WebBeansContext.currentInstance();
        ContextsService contextsService = webBeansContext.getContextsService();

        contextsService.startContext(ApplicationScoped.class, servletContext);
    }
View Full Code Here

Examples of org.apache.webbeans.config.WebBeansContext

    }

    public void startConversationScope() throws Exception
    {
        logger.log(Level.FINE, "starting the OWB ConversationContext");
        WebBeansContext webBeansContext = WebBeansContext.currentInstance();
        ContextsService contextsService = webBeansContext.getContextsService();

        contextsService.startContext(ConversationScoped.class, null);
    }
View Full Code Here

Examples of org.apache.webbeans.config.WebBeansContext

    }

    public void startRequestScope() throws Exception
    {
        logger.log(Level.FINE, "starting the OWB RequestContext");
        WebBeansContext webBeansContext = WebBeansContext.currentInstance();
        ContextsService contextsService = webBeansContext.getContextsService();

        contextsService.startContext(RequestScoped.class, null);
    }
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.