Exforsys.com
 

Sponsored Links

 

SCBCD Tutorials

 
Home Certification SCBCD
 

SCBCD Study Notes : Chapter 10 : Message-Driven Bean Component Contract (Part 2)

 

SCBCD Study Notes : Chapter 10 : Message-Driven Bean Component Contract (Part 2)

Please find the Study Notes and resources which covers 2nd Part of Chapter 10 : Message-Driven Bean Component Contract, as part of the Sun Certified Business Component Developer exam CX-310-090.


3. Identify the use and behavior of the MessageDrivenContext interface methods.
4. From a list, identify the responsibility of the bean provider and the responsibility of the container provider for a message-driven bean.


 



 


Chapter 10 : Message-Driven Bean Component Contract (Part 2)

 


Identify the use and behavior of the MessageDrivenContext interface methods.

 


The container provides the message-driven bean instance with a MessageDrivenContext. This gives the message-driven bean instance access to the instance's context maintained by the container. The MessageDrivenContext interface has the following methods:

 



 


  • The setRollbackOnly method allows the instance to mark the current transaction such that the only outcome of the transaction is a rollback. ONLY instances of a message-driven bean with container-managed transaction (CMT) demarcation can use this method.

     


  • The getRollbackOnly method allows the instance to test if the current transaction has been marked for rollback. ONLY instances of a message-driven bean with container-managed transaction (CMT) demarcation can use this method.

     


  • The getUserTransaction method returns the javax.transaction.UserTransaction interface that the instance can use to demarcate transactions, and to obtain transaction status. ONLY instances of a message-driven bean with bean-managed transaction (BMT) demarcation can use this method.

     


  • The getCallerPrincipal method is inherited from the EJBContext interface. Message-driven bean instances MUST NOT call this method (caller is unknown for MDB).

     


  • The isCallerInRole method is inherited from the EJBContext interface. Message-driven bean instances MUST NOT call this method (caller is unknown for MDB).

     


  • The getEJBHome and getEJBLocalHome methods are inherited from the EJBContext interface. Message-driven bean instances MUST NOT call these methods (MDB has no home/local-home interfaces, as well do not have component interfaces).

     


 



 


From a list, identify the responsibility of the bean provider and the responsibility of the container provider for a message-driven bean.

 


Bean Provider responsibility

 


The message-driven bean provider is responsible for providing message-driven bean class. The following are the requirements for the message-driven bean class:

 



 


  • The class MUST implement, directly or indirectly, the javax.ejb.MessageDrivenBean interface.

     


  • The class MUST implement, directly or indirectly, the javax.jms.MessageListener interface.

     


  • The class MUST be defined as public, MUST NOT be final, and MUST NOT be abstract.

     


  • The class MUST HAVE a public constructor that takes no arguments. The Container uses this constructor to create instances of the message-driven bean class.

     


  • The class MUST NOT define the finalize() method.

     


  • The class MUST implement the ejbCreate() method (it can be empty).

     


  • The message-driven bean class may have superclasses and/or superinterfaces. If the message-driven bean has superclasses, the ejbCreate method, and the methods of the MessageDrivenBean and MessageListener interfaces may be defined in the message-driven bean class or in any of its superclasses.

     


  • The message-driven bean class is allowed to implement other methods (for example, helper methods invoked internally by the onMessage method) in addition to the methods required by the EJB specification.

     


The message-driven bean class MUST define ONE ejbCreate() method whose signature must follow these rules:

 



 


  • The method name MUST be ejbCreate.

     


  • The method MUST be declared as public.

     


  • The method MUST NOT be declared as final or static.

     


  • The return type MUST be void.

     


  • The method MUST HAVE NO arguments.

     


  • The throws clause MUST NOT define any APPLICATION exceptions.

     


The message-driven bean class MUST define ONE onMessage method whose signature must follow these rules:

 



 


  • The method MUST be declared as public.

     


  • The method MUST NOT be declared as final or static.

     


  • The return type MUST be void.

     


  • The method MUST HAVE a single argument of type javax.jms.Message.

     


  • The throws clause MUST NOT define any APPLICATION exceptions.

     


The message-driven bean class MUST define ONE ejbRemove() method whose signature must follow these rules:

 



 


  • The method name MUST be ejbRemove.

     


  • The method MUST be declared as public.

     


  • The method MUST NOT be declared as final or static.

     


  • The return type MUST be void.

     


  • The method MUST HAVE NO arguments.

     


  • The throws clause MUST NOT define any APPLICATION exceptions.

     


 


Container Provider responsibility

 


The container provider must support the deployment of a message-driven bean as the consumer of a JMS queue or a durable subscription.

 



 


The container must ensure that ONLY ONE thread can be executing an instance at any time.

 



 


The container must follow the rules with respect to transaction scoping, security checking, and exception handling.

 



 


________________
A
uthor: Mikalai Zaikin. Please Click Here to visit Authors site for any updates and changes to the study notes.



Read Next: SCBCD Study Notes : Chapter 11 : Transactions (Part 1)



 

 

Comments



Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2010 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape