• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why can't an MDB be a subclass of another MDB?

 
Mark Garland
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

pg. 124 of EJB3 In Action says
"The MDB much be a POJO class and not a subclass of another MDB".


I just wondered why that was? Especially if we haven't declared them as final...

Thanks,

MG
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
MDBs are message listeners, if you do that, the container will call super class MDB, and subclass MDB, I think that is why the specification doesn't allow, because it doesn't make sense.
 
Reza Rahman
author
Ranch Hand
Posts: 580
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark,

We're trying to get this dropped in EJB 3.1. It is overly restrictive and unnecessary IMO.

Regards,
Reza
 
Mark Garland
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thank you both for your kind answers.

I agree - it does feel overly restrictive.
I say this though as I'm not 100% sure that I understand the reasons why it was there in the first place.

Surely you could just write
- parentMDB which implements MessageListener and is assigned to Queue1
and
- childMDB which extends parentMDB, overrides the onMessage (or not if happy with parents functionality), and through ActivationConfigProperties specify a different Queue - Queue2.

Can't see an issue there?

MG
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Agreed.
onMessage method in Subclass MDBs may call super.onMessage() and do more. But if a subclass overrides onMessage without calling super.onMessage, I think it doesn't make sense.

Subclass MDBs can also override superclass's protected methods.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!