Share on Google+Share on Google+

Identify the use and behavior of the MessageDrivenContext interface methods.

Advertisement
This page discusses - Identify the use and behavior of the MessageDrivenContext interface methods.

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).

package javax.ejb;

public interface MessageDrivenContext extends EJBContext {
}

public interface EJBContext {
	EJBHome getEJBHome();
	EJBLocalHome getEJBLocalHome();
	java.security.Principal getCallerPrincipal();
	boolean isCallerInRole(String roleName);
	UserTransaction getUserTransaction() throws IllegalStateException;
	void setRollbackOnly() throws IllegalStateException;
	boolean getRollbackOnly() throws IllegalStateException;
}
					

Advertisements

Posted on: April 18, 2011 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Discuss: Identify the use and behavior of the MessageDrivenContext interface methods.  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0