Get your CodeRanch badge!*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes MDB and its strange inheritance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "MDB and its strange inheritance " Watch "MDB and its strange inheritance " New topic
Author

MDB and its strange inheritance

thuy nguyen
Greenhorn

Joined: Aug 02, 2008
Posts: 15
I cut and paste this paragraph from the specification:

The message-driven bean class may have superclasses and/or superinterfaces. If the message-driven
bean has superclasses, the methods of the message listener interface, lifecycle callback interceptor
methods, the timeout method, the ejbCreate method, and the methods of the MessageDriven-
Bean interface may be defined in the message-driven bean class or in any of its superclasses. A message-
driven bean class must not have a superclass that is itself a message-driven bean class

Since a MDB can not subclass another MDB, it can only subclass a POJO. It is strange that a POJO can have
"the methods of the message listener interface, lifecycle callback interceptor methods, the timeout method, the ejbCreate method, and the methods of the MessageDriven-Bean interface"
Michael Antonov
Greenhorn

Joined: Nov 16, 2009
Posts: 11
thuy nguyen wrote:I cut and paste this paragraph from the specification:

The message-driven bean class may have superclasses and/or superinterfaces. If the message-driven
bean has superclasses, the methods of the message listener interface, lifecycle callback interceptor
methods, the timeout method, the ejbCreate method, and the methods of the MessageDriven-
Bean interface may be defined in the message-driven bean class or in any of its superclasses.
A message-
driven bean class must not have a superclass that is itself a message-driven bean class

Since a MDB can not subclass another MDB, it can only subclass a POJO. It is strange that a POJO can have
"the methods of the message listener interface, lifecycle callback interceptor methods, the timeout method, the ejbCreate method, and the methods of the MessageDriven-Bean interface"

That is not strange really. You can create a POJO superclass, which has onMessage method, and which is implementing the appropriate interface, say MessageListener.
That you create just a empty class which subclasses your superclass, has @MessageDriven annotation, and no onMessage method. This is valid. onMessage method for MDB will be picked up from superclass.


JEE Developer.
SCJP 5 - 80%, SCBCD 5 - 90%.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: MDB and its strange inheritance
 
Similar Threads
EJB3 Session bean Superclass
Java Beat Question - Q on transaction attributes
Section 5.5.1 of EJB 3.0 Core Specs
Subclassing rules for Session beans
EJBCore_Spec errata?