1

this is ok

@MessageDriven(...)
public class EventMDB implements MessageListener
{    
    @Resource
    private MessageDrivenContext context;

    //onMessage(Message)
    ...

but does it also work, if i put the resource annotation in an abstract parent class?

@MessageDriven(...)
public class EventMDB extend ParentMDB
{
    //onEvent(Event)
    ...

with

public abstract class ParentMDB implements MessageListener
{
    @Resource
    protected MessageDrivenContext context;

    //onMessage(Message) retrieves object of ObjectMessage and invokes onEvent(Event)

    //abstract void onEvent(Event)
    ...
MaDa
  • 10,511
  • 9
  • 46
  • 84
user600148
  • 41
  • 3

1 Answers1

1

I can't see why it wouldn't work (Java EE API):

Even though this annotation is not marked Inherited, deployment tools are required to examine all superclasses of any component class to discover all uses of this annotation in all superclasses. All such annotation instances specify resources that are needed by the application component. Note that this annotation may appear on private fields and methods of superclasses; the container is required to perform injection in these cases as well.

Do you have a use case when it doesn't work, or are you just contemplating the "what-ifs"?

MaDa
  • 10,511
  • 9
  • 46
  • 84
  • No, i got no cases when it doesn't worked. Our local smart guy assumed that it might not work und my Test-MDB didn't deploy for some reason (not related to this issue though) so i thought i'd better ask here. – user600148 Nov 16 '11 at 11:18