users@javaee-spec.java.net

[javaee-spec users] [jsr342-experts] Re: transactional interceptors and lifecycle methods

From: Bill Shannon <bill.shannon_at_oracle.com>
Date: Tue, 12 Mar 2013 13:25:32 -0700

Pete Muir wrote on 03/12/13 12:52:
>
> On 12 Mar 2013, at 19:46, Bill Shannon <bill.shannon_at_oracle.com> wrote:
>
>> As I understand it, interceptor bindings don't depend on whether the
>> interceptor is intercepting regular methods with @AroundInvoke or is
>> intercepting lifecycle methods with @PostConstruct/_at_PreDestroy. (Maybe it's
>> an error to bind an interceptor to a postConstruct method if it doesn't
>> include a @PostConstruct interceptor? Similarly @AroundInvoke?)
>
> Implicitly I guess the spec allows you to do this, but I don't think it's
> very clear. I would like to add at least an example to the interceptors spec
> to show how you do this. Could you outline what you think the interceptor
> definition will look like in this case?

@Transactional
@Interceptor
public class TransactionalInterceptor {
    @AroundInvoke
    public Object aroundInvoke(InvocationContext ctx) throws Exception { ... }

    @PostConstruct
    public void postConstruct(InvocationContext ctx) throws Exception { ... }
}

(Assuming I got that approximately right without looking at the spec.)