|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
javax.ejb Interface EntityContext
- All Superinterfaces:
- EJBContext
public interface EntityContext
- extends EJBContext
EntityContext 接口提供了一个实例来访问容器提供的实体企业 Bean 实例的运行时上下文。容器在实例创建后将 EntityContext 接口传递给实体企业 Bean 实例。
EntityContext 接口在实例的生命周期内保持与实例关联。注意实例使用 EntityContext 接口获得的信息(比如 getPrimaryKey() 方法的结果)可能会变化,因为容器在实例的生命周期内会将实例分配给不同的 EJB 对象。
The EntityContext interface provides an instance with access to the container-provided runtime context of an entity enterprise Bean instance. The container passes the EntityContext interface to an entity enterprise Bean instance after the instance has been created.
The EntityContext interface remains associated with the instance for the lifetime of the instance. Note that the information that the instance obtains using the EntityContext interface (such as the result of the getPrimaryKey() method) may change, as the container assigns the instance to different EJB objects during the instance's life cycle.
Method Summary | |
---|---|
EJBLocalObject |
getEJBLocalObject()
Obtain a reference to the EJB local object that is currently associated with the instance. |
EJBObject |
getEJBObject()
Obtain a reference to the EJB object that is currently associated with the instance. |
Object |
getPrimaryKey()
Obtain the primary key of the EJB object that is currently associated with this instance. |
Methods inherited from interface javax.ejb.EJBContext |
---|
getCallerIdentity, getCallerPrincipal, getEJBHome, getEJBLocalHome, getEnvironment, getRollbackOnly, getTimerService, getUserTransaction, isCallerInRole, isCallerInRole, lookup, setRollbackOnly |
Method Detail |
---|
public EJBLocalObject
getEJBLocalObject() throws IllegalStateException
获得对当前与实例关联的 EJB 本地对象的引用。
仅当实体企业 Bean 的实例与 EJB 本地对象身份关联时(即 ejbActivate、ejbPassivate、ejbPostCreate、ejbRemove、ejbLoad、ejbStore 和业务方法),它才可以调用此方法。
例如,如果实例希望在方法参数或结果中传递对本身的引用时,它可以使用此方法。
return | 当前与实例关联的 EJB 本地对象。 |
Throws | IllegalStateException: 如果在实例不允许调用此方法的情况下,或者实例没有本地接口的情况下调用此方法,则抛出该异常。 |
getEJBLocalObject
EJBLocalObject getEJBLocalObject() throws IllegalStateException
- Obtain a reference to the EJB local object that is currently
associated with the instance.
An instance of an entity enterprise Bean can call this method only when the instance is associated with an EJB local object identity, i.e. in the ejbActivate, ejbPassivate, ejbPostCreate, ejbRemove, ejbLoad, ejbStore, and business methods.
An instance can use this method, for example, when it wants to pass a reference to itself in a method argument or result.
- Returns:
- The EJB local object currently associated with the instance.
- Throws:
IllegalStateException
- if the instance invokes this method while the instance is in a state that does not allow the instance to invoke this method, or if the instance does not have a local interface.
public EJBObject
getEJBObject() throws IllegalStateException
获得对当前与实例关联的 EJB 对象的引用。
仅当实体企业 Bean 的实例与 EJB 对象身份关联时(即 ejbActivate、ejbPassivate、ejbPostCreate、ejbRemove、ejbLoad、ejbStore 和业务方法),它才可以调用此方法。
例如,如果实例希望在方法参数或结果中传递对本身的引用时,它可以使用此方法。
return | 当前与实例关联的 EJB 对象。 |
Throws | IllegalStateException: 如果在实例不允许调用此方法的情况下,或者实例没有远程接口的情况下调用此方法,则抛出该异常。 |
getEJBObject
EJBObject getEJBObject() throws IllegalStateException
- Obtain a reference to the EJB object that is currently associated with
the instance.
An instance of an entity enterprise Bean can call this method only when the instance is associated with an EJB object identity, i.e. in the ejbActivate, ejbPassivate, ejbPostCreate, ejbRemove, ejbLoad, ejbStore, and business methods.
An instance can use this method, for example, when it wants to pass a reference to itself in a method argument or result.
- Returns:
- The EJB object currently associated with the instance.
- Throws:
IllegalStateException
- Thrown if the instance invokes this method while the instance is in a state that does not allow the instance to invoke this method, or if the instance does not have a remote interface.
public Object
getPrimaryKey() throws IllegalStateException
获得当前与实例关联的 EJB 对象的主键。
仅当实体企业 Bean 的实例与 EJB 对象身份关联时(即 ejbActivate、ejbPassivate、ejbPostCreate、ejbRemove、ejbLoad、ejbStore 和业务方法),它才可以调用此方法。
注:此方法的结果与 getEJBObject().getPrimaryKey() 的结果相同。
return | 当前与实例关联的主键。 |
Throws | IllegalStateException: 如果在实例不允许调用此方法的情况下调用此方法,则抛出该异常。 |
getPrimaryKey
Object getPrimaryKey() throws IllegalStateException
- Obtain the primary key of the EJB object that is currently
associated with this instance.
An instance of an entity enterprise Bean can call this method only when the instance is associated with an EJB object identity, i.e. in the ejbActivate, ejbPassivate, ejbPostCreate, ejbRemove, ejbLoad, ejbStore, and business methods.
Note: The result of this method is that same as the result of getEJBObject().getPrimaryKey().
- Returns:
- The primary key currently associated with the instance.
- Throws:
IllegalStateException
- Thrown if the instance invokes this method while the instance is in a state that does not allow the instance to invoke this method.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Submit a bug or feature
Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!