public interface EJBContext
This interface is extended by the SessionContext
, EntityContext
, and
MessageDrivenContext
interfaces to provide additional methods specific to the enterprise interface bean
type.
SessionContext
,
MessageDrivenContext
,
EntityContext
Modifier and Type | Method and Description |
---|---|
java.security.Principal |
getCallerPrincipal()
Obtain the
java.security.Principal that identifies the caller. |
java.util.Map<java.lang.String,java.lang.Object> |
getContextData()
The
getContextData method enables a business method, lifecycle callback method, or timeout method to
retrieve any interceptor/webservices context associated with its invocation. |
EJBHome |
getEJBHome()
Obtain the enterprise bean's remote home interface.
|
EJBLocalHome |
getEJBLocalHome()
Obtain the enterprise bean's local home interface.
|
boolean |
getRollbackOnly()
Test if the transaction has been marked for rollback only.
|
TimerService |
getTimerService()
Get access to the enterprise bean Timer Service.
|
UserTransaction |
getUserTransaction()
Obtain the transaction demarcation interface.
|
boolean |
isCallerInRole(java.lang.String roleName)
Test if the caller has a given security role.
|
java.lang.Object |
lookup(java.lang.String name)
Lookup a resource within the
java: namespace. |
void |
setRollbackOnly()
Mark the current transaction for rollback.
|
EJBHome getEJBHome() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- if the enterprise bean does not have a remote home interface.EJBLocalHome getEJBLocalHome() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- if the enterprise bean does not have a local home interface.java.security.Principal getCallerPrincipal() throws java.lang.IllegalStateException
java.security.Principal
that identifies the caller.Principal
object that identifies the caller. This method never returns null
.java.lang.IllegalStateException
- The Container throws the exception if the instance is not allowed to call this
method.boolean isCallerInRole(java.lang.String roleName) throws java.lang.IllegalStateException
roleName
- The name of the security role. The role must be one of the security roles that is defined in the
deployment descriptor.java.lang.IllegalStateException
- The Container throws the exception if the instance is not allowed to call this
method.UserTransaction getUserTransaction() throws java.lang.IllegalStateException
UserTransaction
interface. As entity beans must always use container-managed transactions, only session beans or message-driven beans
with bean-managed transactions are allowed to invoke this method.UserTransaction
interface that the enterprise bean instance can use for transaction
demarcation.java.lang.IllegalStateException
- The Container throws the exception if the instance is not allowed to use the
UserTransaction
interface (i.e. the instance is of a bean with container-managed transactions).void setRollbackOnly() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- The Container throws the exception if the instance is not allowed to use this method
(i.e. the instance is of a bean with bean-managed transactions).boolean getRollbackOnly() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- The Container throws the exception if the instance is not allowed to use this method
(i.e. the instance is of a bean with bean-managed transactions).TimerService getTimerService() throws java.lang.IllegalStateException
TimerService
object.java.lang.IllegalStateException
- The Container throws the exception if the instance is not allowed to use this method
(e.g. if the bean is a stateful session bean)java.lang.Object lookup(java.lang.String name) throws java.lang.IllegalArgumentException
java:
namespace. Names referring to entries within the private component
namespace can be passed as unqualified strings. In that case the lookup will be relative to
"java:comp/env/"
.
For example, assuming an enterprise bean defines an ejb-local-ref
with ejb-ref-name
"ejb/BarRef"
the following two calls to EJBContext.lookup
are equivalent :
ejbContext.lookup("ejb/BarRef")
; ejbContext.lookup("java:comp/env/ejb/BarRef")
;name
- Name of the entryObject
object.java.lang.IllegalArgumentException
- The Container throws the exception if the given name does not match an entry
within the component's environment.java.util.Map<java.lang.String,java.lang.Object> getContextData()
getContextData
method enables a business method, lifecycle callback method, or timeout method to
retrieve any interceptor/webservices context associated with its invocation.Map<String,Object>
object will be returned.