Identify the interface and method for each of the following: retrieve the session bean's remote home interface, retrieve the session bean's local component interface, determine if the sessio

This page discusses - Identify the interface and method for each of the following: retrieve the session bean's remote home interface, retrieve the session bean's local component interface, determine if the sessio

Ads

Tutorials   
Chapter 5. Client View of an Entity Identify correct and incorrect statements about the Application Assembler's responsibilities, including the use of deployment descriptor elements related to transactions and the identifica Given a list of responsibilities, identify whose which are the Container's with respect to transactions, including the handling of getRollbackOnly, setRollbackOnly, getUserTransacti EJB Transactional Attributes Chapter 11. Transactions Given a list of scenarios, identify which will result in an ejbRemove method not being called on a bean instance. Given a list of responsibilities related to session beans, identify those which are the responsibility of the session bean provider and those which are the responsibility of the EJB contai Given a list of methods for a stateful or stateless session bean class, define which of the following operations can be performed from each of those methods: SessionContext interface metho Chapter 4. Session Bean Life Cycle Identify correct and incorrect statements or examples about the client view of a session bean's local and remote component interfaces. Identify the interface and method for each of the following: retrieve the session bean's remote home interface, retrieve the session bean's local component interface, determine if the sessio Match the correct description about purpose and function to which session bean type they apply: stateless, stateful, or both. Chapter 14. Security Management Given a security-related deployment descriptor tag, identify correct and incorrect statements and code related to that tag. Given a list of responsibilities, identify which belong to the deployer, bean provider, application assembler, container provider, system administrator, or any combination. From a list of responsibilities, identify which belong to the application assembler, bean provider, deployer, container provider, or system administrator. Part I. Exam Objectives Preface Identify the interfaces and methods a JMS message-driven bean must implement. Identify the use and behavior of the MessageDrivenContext interface methods. SCBCD Study Guide Given a list of responsibilities related to exceptions, identify those which are the bean provider's, and those which are the responsibility of the container provider. Be prepared to recog Given a particular method condition, identify the following: whether an exception will be thrown, the type of exception thrown, the container's action, and the client's view. Identify correct and incorrect statements or examples about application exceptions and system exceptions in entity beans, session beans, and message-driven beans. Identify correct and incorrect statements or examples about the client's view of exceptions received from an enterprise bean invocation. Identify correct and incorrect statements or examples about an entity bean's primary key and object identity. Identify the use, syntax, and behavior of, the following entity bean home method types, for Container-Managed Persistence (CMP); finder methods, create methods, remove methods, and home me Chapter 8. Entity Beans Chapter 13. Enterprise Bean Environment Chapter 2. Client View of a Session Bean Match EJB roles with the corresponding description of the role's responsibilities, where the description may include deployment descriptor information. Given a list, identify which are requirements for an EJB-jar file. Identify correct and incorrect statements or examples about the client view of a entity bean's remote component interface (EJBObject). Identify correct and incorrect conditional expressions, BETWEEN expressions, IN expressions, LIKE expressions, and comparison expressions. Identify correct and incorrect statements or examples about the purpose and use of EJB QL. Chapter 9. EJB-QL Identify correct and incorrect statements or examples about EJB programming restrictions. Chapter 1. EJB Overview Identify EJB 2.0 container requirements. Identify correct and incorrect statements or examples about the client view of an entity bean's local component interface (EJBLocalObject). Chapter 12. Exceptions Identify the use and the behavior of the ejbPassivate method in a session bean, including the responsibilities of both the container and the bean provider. Identify correct and incorrect statements about the purpose and use of the deployment descriptor elements for environment entries, EJB references, and resource manager connection factory r Chapter 10. Message-Driven Bean Component Contract Given a code listing, determine whether it is a legal and appropriate way to programmatically access a caller's security context. From a list, identify the responsibility of the container for a CMP entity bean, including but not limited to: setEntityContext, unsetEntityContext, ejbCreate, ejbPostCreate, ejbActi Identify correct and incorrect statements or examples about the rules and semantics for relationship assignment and relationship updating in a CMP bean. Chapter 7. CMP Entity Bean Life Cycle From a list, identify the purpose, behavior, and responsibilities of the bean provider for a CMP entity bean, including but not limited to: setEntityContext, unsetEntityContext, ejbC Identify correctly-implemented deployment descriptor elements for a CMP bean (including container-managed relationships).
Ads

Identify the interface and method for each of the following: retrieve the session bean's remote home interface, retrieve the session bean's local component interface, determine if the session bean's caller has a particular role, allow the instance to mark the current transaction as a rollback, retrieve the UserTransaction interface, prepare the instance for reuse following passivation, release resources prior to removal, identify the invoker of the bean instance's component interface, be notified that a new transaction has begun, and be notified that the current transaction has completed.

A container provides the session bean instances with a SessionContext, which gives the session bean instance access to the instance’s context maintained by the container. The SessionContext interface has the following methods:

  • The getEJBObject method returns the session bean’s remote interface.

  • The getEJBHome method returns the session bean’s remote home interface.

  • The getEJBLocalObject method returns the session bean’s local interface.

  • The getEJBLocalHome method returns the session bean’s local home interface.

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

  • The isCallerInRole method tests if the session 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. ONLY instances of a session 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 session bean with CONTAINER-managed transaction (CMT) demarcation can use this method.

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

public interface SessionContext extends EJBContext {
	EJBLocalObject getEJBLocalObject() throws IllegalStateException;
	EJBObject getEJBObject() throws IllegalStateException;	
}					

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;
}

/**
 * This interface represents the abstract notion of a principal, which
 * can be used to represent any entity, such as an individual, a
 * corporation, and a login id.
 */
public interface Principal {
    public String getName();
}
					

The ejbRemove notification signals that the instance is in the process of being removed by the container. In the ejbRemove method, the instance typically releases the same resources that it releases in the ejbPassivate method.

The Bean Provider CANNOT assume that the Container will always invoke the ejbRemove() method on a session bean instance. The following scenarios result in ejbRemove() NOT being called on an instance:

  • A crash of the EJB Container.

  • A SYSTEM exception thrown from the instance’s method to the Container.

  • A timeout of client inactivity while the instance is in the passive state. The timeout is specified by the Deployer in an EJB Container implementation specific way.

If the session bean instance allocates resources in the ejbCreate<METHOD>(...) method and/or in the business methods, and normally releases the resources in the ejbRemove() method, these resources will not be automatically released in the above scenarios. The application using the session bean should provide some clean up mechanism to periodically clean up the unreleased resources.

The ejbPassivate notification signals the intent of the container to passivate the instance. The ejbActivate notification signals the instance it has just been reactivated. Because containers automatically maintain the conversational state of a session bean instance when it is passivated, most session beans can ignore these notifications. Their purpose is to allow session beans to maintain those open resources that need to be closed prior to an instance’s passivation and then reopened during an instance’s activation (for example, DB connections).

A STATEFUL session bean class (CMT only) can optionally implement the javax.ejb.SessionSynchronization interface. This interface provides the session bean instances with transaction synchronization notifications. The instances can use these notifications, for example, to manage database data they may cache within transactions :

  • The afterBegin notification signals a session bean instance that a new transaction has begun. The container invokes this method before the first business method within a transaction (which is not necessarily at the beginning of the transaction). The afterBegin notification is invoked with the transaction context. The instance may do any database work it requires within the scope of the transaction.

  • The beforeCompletion notification is issued when a session bean instance’s client has completed work on its current transaction but prior to committing the resource managers used by the instance. At this time, the instance should write out any database updates it has cached. The instance can cause the transaction to roll back by invoking the setRollbackOnly method on its session context.

  • The afterCompletion notification signals that the current transaction has completed. A completion status of true indicates that the transaction has committed; a status of false indicates that a rollback has occurred. Since a session bean instance’s conversational state is not transactional, it may need to manually reset its state if a rollback occurred.

public interface SessionSynchronization {
	void afterBegin() throws EJBException, RemoteException;
	void afterCompletion(boolean committed) throws EJBException, RemoteException;
	void beforeCompletion() throws EJBException, RemoteException;
}
					
ONLY a STATEFUL Session bean with CONTAINER-managed transaction (CMT) demarcation may implement the SessionSynchronization interface. A stateless Session bean MUST NOT implement the SessionSynchronization interface.

Visit http://java.boot.by  for the updates.

Advertisements

Share on Google+Share on Google+

Identify the interface and method for each of the following: retrieve the session bean's remote home interface, retrieve the session bean's local component interface, determine if the sessio

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

Advertisements

Ads
 
Comments:0

Ads

 

Ads