Java Reference
In-Depth Information
SessionContext
SessionContext is an implementation that adds methods specific to the session bean
environment. Table 5.2 describes these methods. Although these methods have their use
cases, they're rarely used.
Table 5.2. Additional methods added by javax.ejb.SessionContext
Methods
Description
Get an object as either the current bean's no-interface view or as one
of its business interfaces (local or remote).
getBusinessObject
Get the local or remote object for the current bean instance. Only val-
id for use with EJB 2 beans. An exception is generated if used with
EJB 3.
getEJBLocalObject getEJBObject
The interface or no-interface view used to invoke the business meth-
od for the current bean.
getInvokedBusinessInterface
If the bean is accessed through a web service, this method returns the
MessageContext associated with that request.
getMessageContext
Get if the user wants to cancel a long-running asynchronous method
call.
wasCancelCalled
The wasCancelCalled() method was added for EJB 3.1. It works with asynchronous
method calls discussed in chapter 3 . When an asynchronous method call occurs, a Fu-
ture<V> object is returned. The client may then call the Future<V>.cancel() meth-
od to stop the long-running process. It's good practice for long-running processes to regu-
larly check a sentinel value to determine if the process should terminate. Your EJB can use
wasCancelCalled() as a sentinel value to determine if the user decided to stop the
process.
MessageDrivenContext
MessageDrivenContext is an implementation specifically for the MDB environment.
Unlike SessionContext , this implementation adds no new methods. Instead, it over-
rides the following methods, throwing exceptions if they're called: isCallerInRole ,
getEJBHome , or getEJBLocalHome . Recall that these methods are part of the Ses-
sionContext interface, but they make no sense in a messaging-based environment be-
cause a MDB has no business interface and is never invoked directly by a client.
 
Search WWH ::




Custom Search