You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by ge...@apache.org on 2009/10/24 00:22:05 UTC
svn commit: r829265 -
/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
Author: gerdogdu
Date: Fri Oct 23 22:22:04 2009
New Revision: 829265
URL: http://svn.apache.org/viewvc?rev=829265&view=rev
Log:
[OWB-145] Refactor InterceptorHandler filter methods, thanks to Joe Bergmark!
Modified:
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
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=829265&r1=829264&r2=829265&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 23 22:22:04 2009
@@ -175,12 +175,9 @@
List<InterceptorData> temp = new ArrayList<InterceptorData>(stack);
- //EJB specific interceptor stack
- filterEJBInterceptorStackList(temp, method);
+ //Filter both EJB and WebBeans interceptors
+ filterCommonInterceptorStackList(temp, method);
- //WebBeans specific interceptor stack
- filterWebBeansInterceptorStackList(temp, method);
-
//Call Around Invokes
if (WebBeansUtil.isContainsInterceptorMethod(temp, InterceptorType.AROUND_INVOKE))
{
@@ -301,121 +298,76 @@
}
- private void filterEJBInterceptorStackList(final List<InterceptorData> stack, Method method)
+ private boolean shouldRemoveInterceptorCommon(InterceptorData id, Method method)
{
boolean isMethodAnnotatedWithInterceptorClass = false;
+
boolean isMethodAnnotatedWithExcludeInterceptorClass = false;
- if (AnnotationUtil.hasMethodAnnotation(method, Interceptors.class))
- isMethodAnnotatedWithInterceptorClass = true;
+ if (id.isDefinedWithWebBeansInterceptor())
+ {
+ if (AnnotationUtil.hasInterceptorBindingMetaAnnotation(method.getDeclaredAnnotations()))
+ {
+ isMethodAnnotatedWithInterceptorClass = true;
+ }
+
+ if (AnnotationUtil.hasMethodAnnotation(method, ExcludeClassInterceptors.class))
+ {
+ isMethodAnnotatedWithExcludeInterceptorClass = true;
+ }
+ }
+ else
+ {
+ if (AnnotationUtil.hasMethodAnnotation(method, Interceptors.class))
+ {
+ isMethodAnnotatedWithInterceptorClass = true;
+ }
- if (AnnotationUtil.hasMethodAnnotation(method, ExcludeClassInterceptors.class))
- isMethodAnnotatedWithExcludeInterceptorClass = true;
+ if (AnnotationUtil.hasMethodAnnotation(method, ExcludeClassInterceptors.class))
+ {
+ isMethodAnnotatedWithExcludeInterceptorClass = true;
+ }
+ }
- Iterator<InterceptorData> it = stack.iterator();
- while (it.hasNext())
+ if (isMethodAnnotatedWithInterceptorClass)
{
- InterceptorData data = it.next();
-
- if(!data.isDefinedWithWebBeansInterceptor())
+
+ if (isMethodAnnotatedWithExcludeInterceptorClass)
{
- if (isMethodAnnotatedWithInterceptorClass)
+ // If the interceptor is defined at the class level it should be
+ // removed due to ExcludeClassInterceptors method annotation
+ if (!id.isDefinedInMethod() && id.isDefinedInInterceptorClass())
{
- if (isMethodAnnotatedWithExcludeInterceptorClass)
- {
- if (!data.isDefinedInMethod() && data.isDefinedInInterceptorClass())
- {
- it.remove();
- }
- else if (data.isDefinedInMethod())
- {
- if (!data.getAnnotatedMethod().equals(method))
- {
- it.remove();
- }
- }
- }
- else
- {
- if (data.isDefinedInMethod())
- {
- if (!data.getAnnotatedMethod().equals(method))
- {
- it.remove();
- }
- }
- }
- }
- else
- {
- if (data.isDefinedInMethod())
- {
- it.remove();
- }
+ return true;
}
-
}
-
+ // If the interceptor is defined in a different method, remove it
+ if (id.isDefinedInMethod() && !id.getAnnotatedMethod().equals(method))
+ {
+ return true;
+ }
}
-
- }
-
- private void filterWebBeansInterceptorStackList(final List<InterceptorData> stack, Method method)
- {
- boolean isMethodAnnotatedWithInterceptorClass = false;
- boolean isMethodAnnotatedWithExcludeInterceptorClass = false;
-
- if (AnnotationUtil.hasInterceptorBindingMetaAnnotation(method.getDeclaredAnnotations()))
+ else if (id.isDefinedInMethod())
{
- isMethodAnnotatedWithInterceptorClass = true;
+ return true;
}
- if (AnnotationUtil.hasMethodAnnotation(method, ExcludeClassInterceptors.class))
- {
- isMethodAnnotatedWithExcludeInterceptorClass = true;
- }
+ return false;
+ }
+ private void filterCommonInterceptorStackList(final List<InterceptorData> stack, Method method)
+ {
Iterator<InterceptorData> it = stack.iterator();
while (it.hasNext())
{
InterceptorData data = it.next();
- if (isMethodAnnotatedWithInterceptorClass)
- {
- if (isMethodAnnotatedWithExcludeInterceptorClass)
- {
- if (!data.isDefinedInMethod() && data.isDefinedInInterceptorClass() && data.isDefinedWithWebBeansInterceptor())
- {
- it.remove();
- }
- else if (data.isDefinedInMethod() && data.isDefinedWithWebBeansInterceptor())
- {
- if (!data.getAnnotatedMethod().equals(method))
- {
- it.remove();
- }
- }
- }
- else
- {
- if (data.isDefinedInMethod() && data.isDefinedWithWebBeansInterceptor())
- {
- if (!data.getAnnotatedMethod().equals(method))
- {
- it.remove();
- }
- }
- }
- }
- else
+
+ if (shouldRemoveInterceptorCommon(data, method))
{
- if (data.isDefinedInMethod() && data.isDefinedWithWebBeansInterceptor())
- {
- it.remove();
- }
+ it.remove();
}
}
-
}
}