Author: struberg
Date: Tue Jan 15 22:46:51 2013
New Revision: 1433721
URL: http://svn.apache.org/viewvc?rev=1433721&view=rev
Log:
OWB-344 fix Interceptors which don't handle some InterceptionType
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorBean.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/LifecycleInterceptorInvocationContext.java
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorBean.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorBean.java?rev=1433721&r1=1433720&r2=1433721&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorBean.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorBean.java
Tue Jan 15 22:46:51 2013
@@ -19,7 +19,6 @@
package org.apache.webbeans.component;
import javax.enterprise.context.Dependent;
-import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.AnnotatedType;
import javax.enterprise.inject.spi.InterceptionType;
import javax.enterprise.inject.spi.Interceptor;
@@ -33,7 +32,6 @@ import java.util.Map;
import java.util.Set;
import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.exception.WebBeansException;
import org.apache.webbeans.util.ExceptionUtil;
/**
@@ -125,12 +123,7 @@ public abstract class InterceptorBean<T>
*/
public Method[] getInterceptorMethods(InterceptionType interceptionType)
{
- Method[] methods = interceptionMethods.get(interceptionType);
- if (methods == null || methods.length == 0)
- {
- throw new WebBeansException("InterceptionType not yet supported: "
+ interceptionType);
- }
- return methods;
+ return interceptionMethods.get(interceptionType);
}
@@ -151,7 +144,14 @@ public abstract class InterceptorBean<T>
}
Method[] interceptorMethods =
getInterceptorMethods(interceptionType);
- if (interceptorMethods.length == 1)
+ if (interceptorMethods == null || interceptorMethods.length == 0)
+ {
+ // this very interceptor doesn't support this interception
type.
+ // this might happen for lifecycle callback methods
+ // let's continue with the next interceptor
+ return invocationContext.proceed();
+ }
+ else if (interceptorMethods.length == 1)
{
// directly invoke the interceptor method with the given
InvocationContext
return interceptorMethods[0].invoke(instance,
invocationContext);
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java?rev=1433721&r1=1433720&r2=1433721&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java
Tue Jan 15 22:46:51 2013
@@ -100,7 +100,6 @@ public class InterceptorResolutionServic
Set<Annotation> classInterceptorBindings =
annotationManager.getInterceptorAnnotations(annotatedType.getAnnotations());
// pick up EJB-style interceptors from a class level
- Set<Interceptor<?>> allUsedEjbInterceptors = new
HashSet<Interceptor<?>>();
List<Interceptor<?>> classLevelEjbInterceptors = new
ArrayList<Interceptor<?>>();
collectEjbInterceptors(classLevelEjbInterceptors, annotatedType);
@@ -112,7 +111,7 @@ public class InterceptorResolutionServic
decorators = null; // less to store
}
- Set<Interceptor<?>> allUsedCdiInterceptors = new
HashSet<Interceptor<?>>();
+ Set<Interceptor<?>> allUsedInterceptors = new
HashSet<Interceptor<?>>();
Map<Method, BusinessMethodInterceptorInfo>
businessMethodInterceptorInfos = new HashMap<Method,
BusinessMethodInterceptorInfo>();
List<Method> nonInterceptedMethods = new ArrayList<Method>();
@@ -124,9 +123,9 @@ public class InterceptorResolutionServic
Set<InterceptionType> interceptionTypes =
collectInterceptionTypes(annotatedMethod);
BusinessMethodInterceptorInfo methodInterceptorInfo = new
BusinessMethodInterceptorInfo(interceptionTypes);
- calculateEjbMethodInterceptors(methodInterceptorInfo,
allUsedEjbInterceptors, classLevelEjbInterceptors, annotatedMethod);
+ calculateEjbMethodInterceptors(methodInterceptorInfo,
allUsedInterceptors, classLevelEjbInterceptors, annotatedMethod);
- calculateCdiMethodInterceptors(methodInterceptorInfo,
allUsedCdiInterceptors, annotatedMethod, classInterceptorBindings);
+ calculateCdiMethodInterceptors(methodInterceptorInfo,
allUsedInterceptors, annotatedMethod, classInterceptorBindings);
calculateCdiMethodDecorators(methodInterceptorInfo, decorators,
annotatedMethod);
@@ -147,9 +146,8 @@ public class InterceptorResolutionServic
annotatedType,
InterceptionType.POST_CONSTRUCT,
PostConstruct.class,
- allUsedEjbInterceptors,
+ allUsedInterceptors,
classLevelEjbInterceptors,
- allUsedCdiInterceptors,
classInterceptorBindings,
true);
@@ -158,22 +156,20 @@ public class InterceptorResolutionServic
annotatedType,
InterceptionType.PRE_DESTROY,
PreDestroy.class,
- allUsedEjbInterceptors,
+ allUsedInterceptors,
classLevelEjbInterceptors,
- allUsedCdiInterceptors,
classInterceptorBindings,
true);
- return new BeanInterceptorInfo(decorators, allUsedCdiInterceptors,
businessMethodInterceptorInfos, nonInterceptedMethods,
lifecycleMethodInterceptorInfos);
+ return new BeanInterceptorInfo(decorators, allUsedInterceptors,
businessMethodInterceptorInfos, nonInterceptedMethods,
lifecycleMethodInterceptorInfos);
}
private void addLifecycleMethods(Map<InterceptionType,
LifecycleMethodInfo> lifecycleMethodInterceptorInfos,
AnnotatedType<?> annotatedType,
InterceptionType interceptionType,
Class<? extends Annotation> annotation,
- Set<Interceptor<?>>
allUsedEjbInterceptors,
+ Set<Interceptor<?>> allUsedInterceptors,
List<Interceptor<?>>
classLevelEjbInterceptors,
- Set<Interceptor<?>>
allUsedCdiInterceptors,
Set<Annotation> classInterceptorBindings,
boolean parentFirst)
{
@@ -189,9 +185,9 @@ public class InterceptorResolutionServic
if (lifecycleMethod.getParameters().size() == 0)
{
foundMethods.add(lifecycleMethod);
- calculateEjbMethodInterceptors(methodInterceptorInfo,
allUsedEjbInterceptors, classLevelEjbInterceptors, lifecycleMethod);
+ calculateEjbMethodInterceptors(methodInterceptorInfo,
allUsedInterceptors, classLevelEjbInterceptors, lifecycleMethod);
- calculateCdiMethodInterceptors(methodInterceptorInfo,
allUsedCdiInterceptors, lifecycleMethod, classInterceptorBindings);
+ calculateCdiMethodInterceptors(methodInterceptorInfo,
allUsedInterceptors, lifecycleMethod, classInterceptorBindings);
}
}
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/LifecycleInterceptorInvocationContext.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/LifecycleInterceptorInvocationContext.java?rev=1433721&r1=1433720&r2=1433721&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/LifecycleInterceptorInvocationContext.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/LifecycleInterceptorInvocationContext.java
Tue Jan 15 22:46:51 2013
@@ -70,7 +70,15 @@ public class LifecycleInterceptorInvocat
if (interceptors != null && interceptorIndex < interceptors.size())
{
Interceptor interceptor = interceptors.get(interceptorIndex++);
- return interceptor.intercept(type, instances.get(interceptor),
this);
+
+ if (interceptor.intercepts(type))
+ {
+ return interceptor.intercept(type, instances.get(interceptor),
this);
+ }
+ else
+ {
+ return proceed();
+ }
}
else
{