Share on Google+Share on Google+

Chapter 8. Entity Beans

This page discusses - Chapter 8. Entity Beans

Chapter 8. Entity Beans

From a list of behaviors, match them with the appropriate EntityContext method responsible for that behavior.

A CONTAINER provides the entity bean instances with an EntityContext, which gives the entity bean instance access to the instance’s context maintained by the container. The EntityContext interface has the following methods:

  • The getEJBObject method returns the entity bean’s REMOTE [component] interface.

  • The getEJBHome method returns the entity bean’s REMOTE HOME interface.

  • The getEJBLocalObject method returns the entity bean’s LOCAL [component] interface.

  • The getEJBLocalHome method returns the entity bean’s LOCAL HOME interface.

  • The getCallerPrincipal method returns the that identifies the invoker of the bean instance’s EJB object.

  • The isCallerInRole method tests if the entity bean instance’s caller has a particular role.

  • The setRollbackOnly method allows the instance to mark the current transaction such that the only outcome of the transaction is a rollback (EntityBeans support ONLY CMT).

  • The getRollbackOnly method allows the instance to test if the current transaction has been marked for rollback. (EntityBeans support ONLY CMT).

  • The getPrimaryKey method returns the entity bean’s primary key.

  • The getUserTransaction method returns the javax.transaction.UserTransaction interface. Entity bean instances MUST NOT call this method. It is derived from EJBContext interface, which is parent for contexts for all 3 types of EJB, but it is used ONLY with BMT in Session Beans and Messages Driven Beans.

public interface EntityContext extends EJBContext {
	EJBLocalObject getEJBLocalObject() throws IllegalStateException;
	EJBObject getEJBObject() throws IllegalStateException;
	Object getPrimaryKey() throws IllegalStateException;
public interface EJBContext {
	EJBHome getEJBHome();
	EJBLocalHome getEJBLocalHome();
	Principal getCallerPrincipal();
	boolean isCallerInRole(String roleName);
	UserTransaction getUserTransaction() throws IllegalStateException;
	void setRollbackOnly() throws IllegalStateException;
	boolean getRollbackOnly() throws IllegalStateException;



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: Chapter 8. Entity Beans  

Post your Comment

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