Package org.apache.webbeans.intercept

Examples of org.apache.webbeans.intercept.InterceptorDataImpl


            method = checkCommonAnnotationCriterias(interceptorClass, interceptionType, definedInInterceptorClass);
        }

        if (method != null)
        {
            intData = new InterceptorDataImpl(defineWithInterceptorBinding, webBeansContext);
            intData.setDefinedInInterceptorClass(definedInInterceptorClass);
            intData.setDefinedInMethod(definedInMethod);
            intData.setInterceptorBindingMethod(annotatedInterceptorClassMethod);
            intData.setWebBeansInterceptor(webBeansInterceptor);
View Full Code Here


            method = checkCommonAnnotationCriterias(annotatedType, annotation, definedInInterceptorClass);
        }

        if (method != null)
        {
            intData = new InterceptorDataImpl(true, webBeansContext);
            intData.setDefinedInInterceptorClass(definedInInterceptorClass);
            intData.setDefinedInMethod(definedInMethod);
            intData.setInterceptorBindingMethod(annotatedInterceptorClassMethod);
            intData.setWebBeansInterceptor(webBeansInterceptor);
            intData.setInterceptorMethod(method, annotation);
View Full Code Here

     */
    private Object callInterceptorsAndDecorators(Method method, Object instance, Object[] arguments, InvocationContext ejbContext) throws Exception
    {
        Object rv = null;
        BaseEjbBean<?> injectionTarget = this.contextual;
        InterceptorDataImpl decoratorInterceptorDataImpl = null;
        List<Object> decorators = null;
        DelegateHandler delegateHandler = null;
        List<Decorator<?>> decoratorStack = injectionTarget.getDecoratorStack();
        List<InterceptorData> interceptorStack = injectionTarget.getInterceptorStack();


        if (logger.isLoggable(Level.FINE))
        {
            logger.log(Level.FINE, "Decorator stack for target {0}", decoratorStack);
            logger.log(Level.FINE, "Interceptor stack {0}", interceptorStack);
        }
                   
        if (decoratorStack.size() > 0 )
        {   
            if (logger.isLoggable(Level.FINE))
            {
                logger.fine("Obtaining a delegate");
            }
            Class<?> proxyClass = webBeansContext.getJavassistProxyFactory().getInterceptorProxyClasses().get(injectionTarget);
            if (proxyClass == null)
            {
                JavassistProxyFactory proxyFactory = webBeansContext.getJavassistProxyFactory();
                ProxyFactory delegateFactory = proxyFactory.createProxyFactory(injectionTarget);
                proxyClass = proxyFactory.getProxyClass(delegateFactory);
                proxyFactory.getInterceptorProxyClasses().put(injectionTarget, proxyClass);
            }
            Object delegate = proxyClass.newInstance();
            delegateHandler = new DelegateHandler(this.contextual, ejbContext);
            ((ProxyObject)delegate).setHandler(delegateHandler);
    
            // Gets component decorator stack
            decorators = WebBeansDecoratorConfig.getDecoratorStack(injectionTarget, instance, delegate,
                                                                   (CreationalContextImpl<?>)this.cc);         
           
            //Sets decorator stack of delegate
            delegateHandler.setDecorators(decorators);
        }
       
        if (interceptorStack.size() == 0)
        {  
            if (decoratorStack.size() == 0)
            {
                rv = ejbContext.proceed();
            }
            else
            {
                // We only have decorators, so run the decorator stack directly without interceptors.
                // The delegate handler knows about the ejbContext.proceed()
                rv = delegateHandler.invoke(instance, method, null, arguments);   
            }
        }
        else
        {
            // We have at least one interceptor.  Our delegateHandler will need to be wrapped in an interceptor.
          
            if (this.interceptedMethodMap.get(method) == null)
            {
                //Holds filtered interceptor stack
                List<InterceptorData> filteredInterceptorStack = new ArrayList<InterceptorData>(interceptorStack);

                // Filter both EJB and WebBeans interceptors
                webBeansContext.getInterceptorUtil().filterCommonInterceptorStackList(filteredInterceptorStack, method);
                webBeansContext.getInterceptorUtil().filterOverridenAroundInvokeInterceptor(injectionTarget.getBeanClass(), filteredInterceptorStack);

                this.interceptedMethodMap.put(method, filteredInterceptorStack);
            }
            List<InterceptorData> filteredInterceptorStack = new ArrayList<InterceptorData>(this.interceptedMethodMap.get(method));
           
            if (delegateHandler != null)
            {
                WebBeansDecoratorInterceptor lastInterceptor = new WebBeansDecoratorInterceptor(delegateHandler, instance);
                decoratorInterceptorDataImpl = new InterceptorDataImpl(true, lastInterceptor, webBeansContext);
                decoratorInterceptorDataImpl.setDefinedInInterceptorClass(true);
                decoratorInterceptorDataImpl.setAroundInvoke(
                        webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethod(lastInterceptor.getClass(),
                                "invokeDecorators",
                                new Class[] {InvocationContext.class}));
                filteredInterceptorStack.add(decoratorInterceptorDataImpl);
            }
View Full Code Here

            }
        }

        if (method != null)
        {
            intData = new InterceptorDataImpl(isDefinedWithWebBeans);
            intData.setDefinedInInterceptorClass(definedInInterceptorClass);
            intData.setDefinedInMethod(definedInMethod);
            intData.setAnnotatedMethod(annotatedInterceptorClassMethod);
            intData.setWebBeansInterceptor(webBeansInterceptor);
View Full Code Here

     */
    private Object callInterceptorsAndDecorators(Method method, Object instance, Object[] arguments, InvocationContext ejbContext) throws Exception
    {
        Object rv = null;
        BaseEjbBean<?> injectionTarget = this.contextual;
        InterceptorDataImpl decoratorInterceptorDataImpl = null;
       
               
        List<Object> decorators = null;
        DelegateHandler delegateHandler = null;
        List<Decorator<?>> decoratorStack = injectionTarget.getDecoratorStack();
        List<InterceptorData> interceptorStack = injectionTarget.getInterceptorStack();


        if (logger.wblWillLogDebug())
        {
            logger.debug("Decorator stack for target {0}", decoratorStack);
            logger.debug("Interceptor stack {0}", interceptorStack);
        }
                   
        if (decoratorStack.size() > 0 )
        {   
            if (logger.wblWillLogDebug())
            {
                logger.debug("Obtaining a delegate");
            }
            Class<?> proxyClass = JavassistProxyFactory.getInstance().getInterceptorProxyClasses().get(injectionTarget);
            if (proxyClass == null)
            {
                ProxyFactory delegateFactory = JavassistProxyFactory.getInstance().createProxyFactory(injectionTarget);
                proxyClass = JavassistProxyFactory.getInstance().getProxyClass(delegateFactory);
                JavassistProxyFactory.getInstance().getInterceptorProxyClasses().put(injectionTarget, proxyClass);
            }
            Object delegate = proxyClass.newInstance();
            delegateHandler = new DelegateHandler(this.contextual, ejbContext);
            ((ProxyObject)delegate).setHandler(delegateHandler);
    
            // Gets component decorator stack
            decorators = WebBeansDecoratorConfig.getDecoratorStack(injectionTarget, instance, delegate,
                                                                   (CreationalContextImpl<?>)this.cc);         
           
            //Sets decorator stack of delegate
            delegateHandler.setDecorators(decorators);
        }
       
        if (interceptorStack.size() == 0)
        {  
            if (decoratorStack.size() == 0)
            {
                rv = ejbContext.proceed();
            }
            else
            {
                // We only have decorators, so run the decorator stack directly without interceptors.
                // The delegate handler knows about the ejbContext.proceed()
                rv = delegateHandler.invoke(instance, method, null, arguments);   
            }
        }
        else
        {
            // We have at least one interceptor.  Our delegateHandler will need to be wrapped in an interceptor.
          
            if (this.interceptedMethodMap.get(method) == null)
            {
                //Holds filtered interceptor stack
                List<InterceptorData> filteredInterceptorStack = new ArrayList<InterceptorData>(interceptorStack);

                // Filter both EJB and WebBeans interceptors
                InterceptorUtil.filterCommonInterceptorStackList(filteredInterceptorStack, method);
                InterceptorUtil.filterOverridenAroundInvokeInterceptor(injectionTarget.getBeanClass(), filteredInterceptorStack);

                this.interceptedMethodMap.put(method, filteredInterceptorStack);
            }
            List<InterceptorData> filteredInterceptorStack = new ArrayList<InterceptorData>(this.interceptedMethodMap.get(method));
           
            if (delegateHandler != null)
            {
                WebBeansDecoratorInterceptor lastInterceptor = new WebBeansDecoratorInterceptor(delegateHandler, instance);
                decoratorInterceptorDataImpl = new InterceptorDataImpl(true, lastInterceptor);
                decoratorInterceptorDataImpl.setDefinedInInterceptorClass(true);
                decoratorInterceptorDataImpl.setAroundInvoke(SecurityUtil.doPrivilegedGetDeclaredMethods(lastInterceptor.getClass())[0]);
                filteredInterceptorStack.add(decoratorInterceptorDataImpl);
            }
           
            // Call Around Invokes,
            //      If there were decorators, the DelegatHandler will handle the  ejbcontext.proceed at the top of the stack.
View Full Code Here

            method = WebBeansUtil.checkCommonAnnotationCriterias(interceptorClass, interceptorType, definedInInterceptorClass);
        }

        if (method != null)
        {
            intData = new InterceptorDataImpl(defineWithInterceptorBinding);
            intData.setDefinedInInterceptorClass(definedInInterceptorClass);
            intData.setDefinedInMethod(definedInMethod);
            intData.setInterceptorBindingMethod(annotatedInterceptorClassMethod);
            intData.setWebBeansInterceptor(webBeansInterceptor);
View Full Code Here

            method = WebBeansUtil.checkCommonAnnotationCriterias(annotatedType, annotation, definedInInterceptorClass);
        }

        if (method != null)
        {
            intData = new InterceptorDataImpl(true);
            intData.setDefinedInInterceptorClass(definedInInterceptorClass);
            intData.setDefinedInMethod(definedInMethod);
            intData.setInterceptorBindingMethod(annotatedInterceptorClassMethod);
            intData.setWebBeansInterceptor(webBeansInterceptor);
            intData.setInterceptorMethod(method, annotation);
View Full Code Here

            }
        }

        if (method != null)
        {
            intData = new InterceptorDataImpl(defineWithInterceptorBinding);
            intData.setDefinedInInterceptorClass(definedInInterceptorClass);
            intData.setDefinedInMethod(definedInMethod);
            intData.setInterceptorBindingMethod(annotatedInterceptorClassMethod);
            intData.setWebBeansInterceptor(webBeansInterceptor);
View Full Code Here

            }
        }

        if (method != null)
        {
            intData = new InterceptorDataImpl(true);
            intData.setDefinedInInterceptorClass(definedInInterceptorClass);
            intData.setDefinedInMethod(definedInMethod);
            intData.setInterceptorBindingMethod(annotatedInterceptorClassMethod);
            intData.setWebBeansInterceptor(webBeansInterceptor);
            intData.setInterceptorMethod(method, annotation);
View Full Code Here

     */
    private CallReturnValue callInterceptorsAndDecorators(Method method, Object instance, Object[] arguments, InvocationContext ejbContext) throws Exception
    {
        CallReturnValue rv = new CallReturnValue();
        InjectionTargetBean<?> injectionTarget = (InjectionTargetBean<?>) threadLocal.get();
        InterceptorDataImpl decoratorInterceptorDataImpl = null;

        String methodName = method.getName();
        if(ClassUtil.isObjectMethod(methodName) && !methodName.equals("toString"))
        {
            logger.trace("Calling method on proxy is restricted except Object.toString(), but current method is Object. [{0}]", methodName);
        }
               
        if (InterceptorUtil.isWebBeansBusinessMethod(method) &&
                EjbUtility.isBusinessMethod(method, threadLocal.get()))
        {

            List<Object> decorators = null;
            DelegateHandler delegateHandler = null;
            logger.debug("Decorator stack for target {0}", injectionTarget.getDecoratorStack());

            if (injectionTarget.getDecoratorStack().size() > 0)
            {
                Class<?> proxyClass = JavassistProxyFactory.getInterceptorProxyClasses().get(injectionTarget);
                if (proxyClass == null)
                {
                    ProxyFactory delegateFactory = JavassistProxyFactory.createProxyFactory(injectionTarget);
                    proxyClass = JavassistProxyFactory.getProxyClass(delegateFactory);
                    JavassistProxyFactory.getInterceptorProxyClasses().put(injectionTarget, proxyClass);
                }
                Object delegate = proxyClass.newInstance();
                delegateHandler = new DelegateHandler(threadLocal.get(),ejbContext);
                ((ProxyObject)delegate).setHandler(delegateHandler);

                // Gets component decorator stack
                decorators = WebBeansDecoratorConfig.getDecoratorStack(injectionTarget, instance, delegate,
                                                                       (CreationalContextImpl<?>)threadLocalCreationalContext.get());                       
                //Sets decorator stack of delegate
                delegateHandler.setDecorators(decorators);
               
            }

            // Run around invoke chain
            List<InterceptorData> interceptorStack = injectionTarget.getInterceptorStack();
            if (interceptorStack.size() > 0)
            {
                if (decorators != null)
                {
                    // We have interceptors and decorators, Our delegateHandler will need to be wrapped in an interceptor
                    WebBeansDecoratorInterceptor lastInterceptor = new WebBeansDecoratorInterceptor(delegateHandler, instance);
                    decoratorInterceptorDataImpl = new InterceptorDataImpl(true, lastInterceptor);
                    decoratorInterceptorDataImpl.setDefinedInInterceptorClass(true);
                    decoratorInterceptorDataImpl.setAroundInvoke(SecurityUtil.doPrivilegedGetDeclaredMethods(lastInterceptor.getClass())[0]);
                }
               
                if (this.interceptedMethodMap.get(method) == null)
                {
                    //Holds filtered interceptor stack
View Full Code Here

TOP

Related Classes of org.apache.webbeans.intercept.InterceptorDataImpl

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.