-
1. Interceptor sub classing
jaikiran Jan 11, 2011 9:09 AM (in response to blep)The spec doesn't allow that:
Interceptors spec, section "Multiple Callback Interceptor Methods for a Life Cycle Callback Event" :
If a lifecycle callback interceptor method is overridden by another method (regardless of whether that method is itself a lifecycle callback interceptor method (of the same or different type)), it will not be invoked.
-
2. Re: Interceptor sub classing
blep Jan 11, 2011 10:03 AM (in response to jaikiran)Ok maybe I was not clear, but the override is a workaround to make the superclass init method beeing invoked.
If the init method is not called by the subclass, then the annotated init method in the superclass is not invoked. So with the following code, the PostConstruct method is not invoked:
{code}public abstract class AbstractServiceInitializer<T> {
@PostConstruct
public void init(InvocationContext ctx) {
Object o = ctx.getTarget();
try {
T service = (T) o;
init(service);
} catch (ClassCastException e) {
log.warn("Class {} is not supported... doing nothing", o.getClass().getName());
return;
}
}
public abstract void init(T service);
}{code}{code}public class MyEjbImplInitializer extends AbstractServiceInitializer<MyEjbImpl>{
@Override
public void init(MyEjbImpl service) {
// specific init stuff
}
}{code}Is this still uncompatible with the spec?
-
3. Re: Interceptor sub classing
jaikiran Jan 11, 2011 10:24 AM (in response to blep)This one looks OK, assuming you have configured the interceptor for the bean. Does it work if you leave out the generics part?
-
4. Re: Interceptor sub classing
blep Jan 11, 2011 10:57 AM (in response to jaikiran)Yes it works without the generic stuff.
I joined the POC to the post to show you with the generified initializer.
Regards
-
interceptor-subclass.zip 5.7 KB
-
-
5. Re: Interceptor sub classing
jaikiran Jan 11, 2011 11:35 AM (in response to blep)Just to be sure - this is JBoss AS 6.0.0.Final, right?
-
-