Return-Path:
Delivered-To:
apmail-incubator-openwebbeans-commits-archive@minotaur.apache.org
Received: (qmail 52120 invoked from network); 16 Oct 2009 15:38:21 -0000
Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3)
by minotaur.apache.org with SMTP; 16 Oct 2009 15:38:21 -0000
Received: (qmail 44039 invoked by uid 500); 16 Oct 2009 15:38:21 -0000
Delivered-To:
apmail-incubator-openwebbeans-commits-archive@incubator.apache.org
Received: (qmail 44017 invoked by uid 500); 16 Oct 2009 15:38:21 -0000
Mailing-List: contact openwebbeans-commits-help@incubator.apache.org;
run by ezmlm
Precedence: bulk
List-Help:
List-Unsubscribe:
List-Post:
List-Id:
Reply-To: openwebbeans-dev@incubator.apache.org
Delivered-To: mailing list openwebbeans-commits@incubator.apache.org
Received: (qmail 44007 invoked by uid 99); 16 Oct 2009 15:38:21 -0000
Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136)
by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Oct 2009 15:38:21 +0000
X-ASF-Spam-Status: No, hits=-2.6 required=5.0
tests=BAYES_00
X-Spam-Check-By: apache.org
Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4)
by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Oct 2009 15:38:18 +0000
Received: by eris.apache.org (Postfix, from userid 65534)
id DA5912388854; Fri, 16 Oct 2009 15:37:58 +0000 (UTC)
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: svn commit: r825948 -
/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
Date: Fri, 16 Oct 2009 15:37:58 -0000
To: openwebbeans-commits@incubator.apache.org
From: gerdogdu@apache.org
X-Mailer: svnmailer-1.0.8
Message-Id: <20091016153758.DA5912388854@eris.apache.org>
Author: gerdogdu
Date: Fri Oct 16 15:37:58 2009
New Revision: 825948
URL: http://svn.apache.org/viewvc?rev=825948&view=rev
Log:
Adding more comments. Also some tweaks on ArrayList copying.
Modified:
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java (contents, props changed)
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java?rev=825948&r1=825947&r2=825948&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java Fri Oct 16 15:37:58 2009
@@ -29,17 +29,111 @@
import javax.interceptor.Interceptors;
import org.apache.webbeans.component.AbstractBean;
+import org.apache.webbeans.config.DefinitionUtil;
+import org.apache.webbeans.config.WebBeansContainerDeployer;
import org.apache.webbeans.container.BeanManagerImpl;
+import org.apache.webbeans.decorator.WebBeansDecorator;
+import org.apache.webbeans.decorator.WebBeansDecoratorConfig;
import org.apache.webbeans.exception.WebBeansException;
+import org.apache.webbeans.intercept.ejb.EJBInterceptorConfig;
+import org.apache.webbeans.intercept.webbeans.WebBeansInterceptor;
import org.apache.webbeans.logger.WebBeansLogger;
import org.apache.webbeans.util.AnnotationUtil;
import org.apache.webbeans.util.ClassUtil;
import org.apache.webbeans.util.WebBeansUtil;
+/**
+ * Logic for how interceptors & decorators work in OWB.
+ *
+ *
+ * - 1- Configuration of decorators and interceptors
+ *
+ * Decorators and Interceptors are configured from {@link WebBeansContainerDeployer}
+ * class via methods configureInterceptors(scanner)
and
+ * configureDecorators(scanner)
. Those methods further call
+ * defineInterceptor(interceptor class)
and defineDecorator(decorator class)
+ * methods. Those methods finally call {@link WebBeansUtil#defineInterceptors(Class)} and
+ * {@link WebBeansUtil#defineDecorators(Class)} methods for actual configuration.
+ *
+ * Let's look at the "WebBeansUtil's" methods;
+ *
+ *
+ * -
+ *
defineInterceptors
: This method firstly
+ * creates a "Managed Bean" for the given interceptor with
+ * "WebBeansType.INTERCEPTOR" as a type. After checking some controls, it calls
+ * "WebBeansInterceptorConfig#configureInterceptorClass".
+ * "configureInterceptorClass" method creates a "WebBeansInterceptor" instance
+ * that wraps the given managed bean instance and configuring interceptor's
+ * *Interceptor Binding* annotations. If everything goes well, it adds
+ * interceptor instance into the "BeanManager" interceptor list.
+ *
+ * defineDecorators
: Exactly doing same thing as "defineInterceptors". If
+ * everything goes well, it adds decorator instance into the "BeanManager"
+ * decorator list.
+ *
+ *
+ * 2* Configuring ManagedBean Instance Interceptor and Decorator Stack
+ *
+ * Currently interceptors and decorators are supported for the "Managed Beans".
+ * OWB delegates calling of "EJB Beans" interceptors to the EJB container. It
+ * does not provide built-in interceptor and decorator support for EJB beans.
+ * Current implementation supports configuration of the interceptors on the
+ * "Managed Beans" with 2 different scenarios, i.e. it supports
+ * "EJB related interceptors ( defined by EJB specification)" and
+ * "JSR-299 related interceptors (defined by interceptor bindings)". Managed
+ * Beans interceptor and decorator stacks are configured after they are
+ * instantiated by the container first time. This method can be found in the
+ * AbstractInjectionTargetBean" class "afterConstructor()" method. Actual
+ * configuration is done by the
+ * {@link DefinitionUtil#defineSimpleWebBeanInterceptorStack(AbstractBean)} and
+ * {@link DefinitionUtil#defineWebBeanDecoratorStack}. In
+ * "DefinitionUtil.defineSimpleWebBeanInterceptorStack", firstly it configures
+ * "EJB spec. interceptors" after that configures "JSR-299 spec. interceptors."
+ * In "DefinitionUtil.defineSimpleWebBeanDecoratorStack", it configures
+ * decorator stack. "EJBInterceptorConfig" class is responsible for finding all
+ * interceptors for given managed bean class according to the EJB Specification.
+ * (But as you said, it may not include AroundInvoke/PostConstruct etc.
+ * disablement scenario!). "WebBeansInterceptorConfig" class is responsible for
+ * finding all interceptors for a given managed bean class according to the
+ * "JSR-299, spec." It adds all interceptors into the bean's interceptor stack.
+ * It first adds "EJB" related interceptors, after that adds "JSR-299" related
+ * interceptors. For "JSR-299" related interceptors, it orders the interceptors
+ * according to the "InterceptorComparator". Basically, it puts interceptors in
+ * order according to how they are ordered in a "beans.xml" configuration file.
+ * Similarly, it configures managed bean's decorator stack according to the
+ * decorator resolution rules. Also, it orders decorators according to the
+ * "beans.xml" configuration file that contains decorator declarations.
+ *
+ *
+ * 3* Invocation of Interceptors and Decorators
+ *
+ * Invocation is handled by the "InterceptorHandler" class (It has an absurd
+ * name, it can be changed to a more meaningful name :)). It works nearly same
+ * as what you have explained. First of all, it checks that calling method is a
+ * business method of a managed bean or not. After that it filters interceptor
+ * stack for calling method (Current design of filtering may not be optimal!).
+ * Firstly it adds EJB interceptor to the list and then adds JSR-299
+ * interceptors. After that, it starts to call all interceptors in order. After
+ * consuming all interceptors it calls decorators. (as you explained, seems that
+ * the logic may not be correct here. Currently, interceptors and decorators are
+ * not related with each other. They are called independently).This must be changed!.
+ *
+ *
+ *
+ *
+ * @version $Rev$ $Date$
+ *
+ * @see WebBeansInterceptorConfig
+ * @see WebBeansDecoratorConfig
+ * @see WebBeansInterceptor
+ * @see WebBeansDecorator
+ * @see EJBInterceptorConfig
+ */
public class InterceptorHandler implements MethodHandler, Serializable
{
private static final long serialVersionUID = 1657109769733323541L;
-
+
private transient static WebBeansLogger logger = WebBeansLogger.getLogger(InterceptorHandler.class);
private AbstractBean> component = null;
@@ -79,13 +173,8 @@
// Run around invoke chain
List stack = component.getInterceptorStack();
- List temp = new ArrayList();
+ List temp = new ArrayList(stack);
- for(InterceptorData data : stack)
- {
- temp.add(data);
- }
-
//EJB specific interceptor stack
filterEJBInterceptorStackList(temp, method);
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
------------------------------------------------------------------------------
svn:keywords = Rev Date