users@ejb-spec.java.net

[ejb-spec users] Re: A small interceptor question

From: Jean-Louis MONTEIRO <jeanouii_at_gmail.com>
Date: Wed, 24 Oct 2012 08:46:07 +0200

Hi Mark,

With EJBs the inheritance is pretty new. It was container specific before
EJB 3.1. Since 3.1, there is now a chapter to deal with session beans
inheritance. In the document EJB 3.2 core PD, the chapter is 4.9.2.1
Session Bean Superclass.

It's more or less clear that there is nothing inherited from super classes.
For instance,
"There are no special rules that apply to the processing of annotations or
the deployment descriptor for this case."
and
"In this regard, the use of session bean classes as superclasses merely
represents a convenient use of implementation inheritance but does not have
component inheritance semantics."

So I would say that even 1. is false.
The @TransactionAttribute (not @Transactional for EJBs) does not have
inherited attribute. AFAIR only ApplicationException has an inherited
attribute but it only applies to exceptions not beans.

In regards to the second question, I would answer yes, annotations in the
subclass also apply to inherited methods.

That's how EJBs work for now. No issue to discuss that and refine the
behavior if possible.

Jean-Louis



2012/10/18 Mark Struberg <struberg_at_yahoo.de>

> Dear EJB EG!
>
> We have a small question over in the CDI EG and Apache DeltaSpike regard
> interception of methods of a superclass.
>
> When dealing with multiple class hierarchies of intercepted classes
> (@InterceptorBinding style for now) we have the 2 following use cases:
>
>
> @Transactional
> public class A {
> public void methodA();
> }
>
>
> public class B extends A {
> public void methodB();
> }
>
> Question
> 1: does the @Transactional interceptor get inherited and both methodA()
> and methodB() get intercepted, or will only methodA() get intercepted?
> Let's
> assume the Transactional annotation itself is marked as inherited. Imo it
> should, right? if @Transactional doesn't have @Inherited then methodB()
> will not get intercepted, right?
>
>
> And now for the other (bit more tricky) case:
>
> public class A {
> public void methodA();
> }
>
> @Transactional
> public class B extends A {
> public void methodB();
> }
>
> Question
> 2: does the @Transactional interceptor also affect inherited methods
> and both methodA() and methodB() get intercepted, or will only methodB()
> get intercepted? I found no clear answer in the interceptors spec. From
> the gut feeling we think methodA() should get intercepted as well...
>
> Could you please point us to the paragraph where the behaviour got defined?
> I could only find paragraphs about inherited interceptors itself, but not
> about inheritance behaviour of intercepted classes.
>
> Next question while I'm at it: the behaviour of @InterceptorBinding style
> Interceptors and @Interceptors is the same regarding the scenarios above?
>
>
> Oh and btw, the next revision please with paragraph numbers - makes it lot
> easiers to reference ;)
>
> txs and LieGrue,
> strub
>
>