You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by og0815 <ol...@gg-net.de> on 2012/02/11 09:07:56 UTC
Wrong CDI Interception in OpenEJB
Hi everybody,
again I'm not 100% sure if I'm getting the spec right or found some bug.
Assume the following code.
@Inherited
@InterceptorBinding
@Retention(RUNTIME)
@Target({METHOD, TYPE})
public @interface MarkInterception {
}
---
@Interceptor
@MarkInterception
public class MarkedInterceptor {
@AroundInvoke
public Object manageTransaction(InvocationContext invocationContext)
throws Exception {
System.out.println("Beginning Interceptor " + invocationContext);
Object o = invocationContext.proceed();
System.out.println("Ending Interceptor " + invocationContext);
return o;
}
}
---
@Stateless
public class BeanOne {
@MarkInterception
public void something() {
System.out.println("BeanOne.something");
}
}
---
@Stateless
public class BeanTwo {
@Inject
private BeanOne one;
public void callOne() {
one.something();
}
}
---
Now if I call BeanTwo.callOne in a client I get the following expected
output:
Beginning Interceptor InvocationContext(operation=BUSINESS, target=BeanOne,
method=something)
BeanOne.something
Ending Interceptor InvocationContext(operation=BUSINESS, target=BeanOne,
method=something)
But, if I change the BeanTwo like this
@Stateless
public class BeanTwo {
@Inject
private BeanOne one;
@MarkInterception
public void doNothing() {
}
public void callOne() {
one.something();
}
}
the following happens:
Beginning Interceptor InvocationContext(operation=BUSINESS, target=BeanTwo,
method=callOne)
Beginning Interceptor InvocationContext(operation=BUSINESS, target=BeanOne,
method=something)
BeanOne.something
Ending Interceptor InvocationContext(operation=BUSINESS, target=BeanOne,
method=something)
Ending Interceptor InvocationContext(operation=BUSINESS, target=BeanTwo,
method=callOne)
Which means that also the callOne is now Intercepted. From my understanding
the Interceptor annotation at method level should only intercept the
selected method but in this case it looks like it has become a interceptor
for all methods.
Again am I doing something weird or is this a bug ?
Thanks,
Olli
--
View this message in context: http://openejb.979440.n4.nabble.com/Wrong-CDI-Interception-in-OpenEJB-tp4378499p4378499.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.