EJBContext (Java EE 5 SDK)

Java

Java EE 5 SDK

深圳电信培训中心.徐海蛟老师.


javax.ejb Interface EJBContext

所有已知子接口:
EntityContext, MessageDrivenContext, SessionContext

public interface EJBContext

The EJBContext interface provides an instance with access to the container-provided runtime context of an enterprise Bean instance.

This interface is extended by the SessionContext, EntityContext, and MessageDrivenContext interfaces to provide additional methods specific to the enterprise interface Bean type.


方法摘要
 Identity getCallerIdentity()
          Deprecated. Use Principal getCallerPrincipal() instead.
 Principal getCallerPrincipal()
          Obtain the java.security.Principal that identifies the caller.
 EJBHome getEJBHome()
          Obtain the enterprise bean's remote home interface.
 EJBLocalHome getEJBLocalHome()
          Obtain the enterprise bean's local home interface.
 Properties getEnvironment()
          Deprecated. Use the JNDI naming context java:comp/env to access enterprise bean's environment.
 boolean getRollbackOnly()
          Test if the transaction has been marked for rollback only.
 TimerService getTimerService()
          Get access to the EJB Timer Service.
 UserTransaction getUserTransaction()
          Obtain the transaction demarcation interface.
 boolean isCallerInRole(Identity role)
          Deprecated. Use boolean isCallerInRole(String roleName) instead.
 boolean isCallerInRole(String roleName)
          Test if the caller has a given security role.
 Object lookup(String name)
          Lookup a resource within the component's private naming context.
 void setRollbackOnly()
          Mark the current transaction for rollback.
 

方法详细信息

getEJBHome

EJBHome getEJBHome()
Obtain the enterprise bean's remote home interface.

返回:
The enterprise bean's remote home interface.
抛出异常:
IllegalStateException - if the enterprise bean does not have a remote home interface.

getEJBLocalHome

EJBLocalHome getEJBLocalHome()
Obtain the enterprise bean's local home interface.

返回:
The enterprise bean's local home interface.
抛出异常:
IllegalStateException - if the enterprise bean does not have a local home interface.

getEnvironment

Properties getEnvironment()
Deprecated. Use the JNDI naming context java:comp/env to access enterprise bean's environment.

Obtain the enterprise bean's environment properties.

Note: If the enterprise bean has no environment properties this method returns an empty java.util.Properties object. This method never returns null.

返回:
The environment properties for the enterprise bean.

getCallerIdentity

Identity getCallerIdentity()
Deprecated. Use Principal getCallerPrincipal() instead.

Obtain the java.security.Identity of the caller. This method is deprecated in EJB 1.1. The Container is allowed to return alway null from this method. The enterprise bean should use the getCallerPrincipal method instead.

返回:
The Identity object that identifies the caller.

getCallerPrincipal

Principal getCallerPrincipal()
Obtain the java.security.Principal that identifies the caller.

返回:
The Principal object that identifies the caller. This method never returns null.
抛出异常:
IllegalStateException - The Container throws the exception if the instance is not allowed to call this method.

isCallerInRole

boolean isCallerInRole(Identity role)
Deprecated. Use boolean isCallerInRole(String roleName) instead.

Test if the caller has a given role.

This method is deprecated in EJB 1.1. The enterprise bean should use the isCallerInRole(String roleName) method instead.

参数:
role - The java.security.Identity of the role to be tested.
返回:
True if the caller has the specified role.

isCallerInRole

boolean isCallerInRole(String roleName)
Test if the caller has a given security role.

参数:
roleName - The name of the security role. The role must be one of the security roles that is defined in the deployment descriptor.
返回:
True if the caller has the specified role.
抛出异常:
IllegalStateException - The Container throws the exception if the instance is not allowed to call this method.

getUserTransaction

UserTransaction getUserTransaction()
                                   throws IllegalStateException
Obtain the transaction demarcation interface. Only enterprise beans with bean-managed transactions are allowed to to use the 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.

返回:
The UserTransaction interface that the enterprise bean instance can use for transaction demarcation.
抛出异常:
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).

setRollbackOnly

void setRollbackOnly()
                     throws IllegalStateException
Mark the current transaction for rollback. The transaction will become permanently marked for rollback. A transaction marked for rollback can never commit. Only enterprise beans with container-managed transactions are allowed to use this method.

抛出异常:
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).

getRollbackOnly

boolean getRollbackOnly()
                        throws IllegalStateException
Test if the transaction has been marked for rollback only. An enterprise bean instance can use this operation, for example, to test after an exception has been caught, whether it is fruitless to continue computation on behalf of the current transaction. Only enterprise beans with container-managed transactions are allowed to use this method.

返回:
True if the current transaction is marked for rollback, false otherwise.
抛出异常:
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).

getTimerService

TimerService getTimerService()
                             throws IllegalStateException
Get access to the EJB Timer Service.

抛出异常:
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)

lookup

Object lookup(String name)
Lookup a resource within the component's private naming context.

参数:
name - Name of the entry (relative to java:comp/env).
抛出异常:
IllegalArgumentException - The Container throws the exception if the given name does not match an entry within the component's environment.

Java EE 5 SDK

深圳电信培训中心.徐海蛟老师.


提交错误或意见

版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。深圳电信培训中心.徐海蛟老师教学参考.