users@javaee-spec.java.net

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

From: Pete Muir <pmuir_at_bleepbleep.org.uk>
Date: Wed, 13 Mar 2013 12:05:43 +0000

Thanks Bill, that does help me be absolutely sure I'm going to propose the right text for the interceptors spec :-)

On 12 Mar 2013, at 20:25, Bill Shannon <bill.shannon_at_oracle.com> wrote:

> 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.)