This is something I've been meaning to bring up. Currently the rules are interceptor signatures for callbacks are not allowed to return Object or throw Exception. Blogged about it here:
http://blog.dblevins.com/2010/09/ejbnext-interceptor-improvements-method.html
We chose that altered method signature because it effectively matched the method signature of the callback itself, but it has some terrible consequences. The worst is that InvocationContext.proceed() method signature is always the same:
public Object proceed() throws Exception
When the Interceptor isn't allowed to have the same method signature it creates awkward and unfortunately unavoidable boiler plate:
@PostConstruct
@PreDestroy
@PrePassivate
@PostActivate
@AroundTimeout
public void callback(InvocationContext context) {
try {
intercept(context);
} catch (Exception e) {
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
} else{
throw new RuntimeException(e);
}
}
}
We should update the spec rules so that interceptor method signatures for callbacks are allowed to be the same and let the container handle the possible undeclared exception issues rather than force that upon the application code in every single callback interceptor they create.
-David
On Jan 8, 2013, at 6:36 AM, Mark Struberg <struberg_at_yahoo.de> wrote:
> Hi folks!
>
> The method signatures for @AroundInvoke and @PostConstruct _interceptors_ (not the postconstruct lifecycle methods, but the interceptors for them!) are well defined in the interceptors spec.
>
>
>
> But what about the method signatures for an interceptor for @PostActivate and the others which are defined in InterceptionType [1]?
> I didn't find anything about them in the interceptors spec. Where can I find this info?
>
>
> txs and LieGrue,
> strub
>
> [1] http://docs.oracle.com/javaee/6/api/javax/enterprise/inject/spi/InterceptionType.html
>