SessionBean (Java EE 5)

Java EE API


javax.ejb Interface SessionBean

All Superinterfaces:
EnterpriseBean, Serializable

public interface SessionBean
extends EnterpriseBean

Implements: EnterpriseBean

SessionBean 接口由每个会话企业 Bean 类实现。容器使用 SessionBean 方法将实例的生命周期事件通知给企业 Bean 实例。
英文文档:

The SessionBean interface is implemented by every session enterprise Bean class. The container uses the SessionBean methods to notify the enterprise Bean instances of the instance's life cycle events.


Method Summary
 void
 void
 void
 void
 

Method Detail

public void setSessionContext(SessionContext ctx) throws EJBException, java.rmi.RemoteException
设置相关会话上下文。容器在创建实例之后调用此方法。

企业 Bean 实例应该在实例变量中存储对上下文对象的引用。

在无事务上下文的情况下调用此方法。

ctx 实例的 SessionContext 接口。
ThrowsEJBException: 该方法抛出此异常指示由于系统级错误导致的失败。
Throwsjava.rmi.RemoteException: 此异常在方法签名中定义,以提供对根据 EJB 1.0 规范编写的应用程序的向后兼容。根据 EJB 1.1 规范编写的企业 Bean 应该抛出 javax.ejb.EJBException,而不是此异常。根据 EJB2.0 及更高规范编写的企业 Bean 必须抛出 javax.ejb.EJBException,而不是此异常。

英文文档:

setSessionContext

void setSessionContext(SessionContext ctx)
                       throws EJBException,
                              RemoteException
Set the associated session context. The container calls this method after the instance creation.

The enterprise Bean instance should store the reference to the context object in an instance variable.

This method is called with no transaction context.

Parameters:
ctx - A SessionContext interface for the instance.
Throws:
EJBException - Thrown by the method to indicate a failure caused by a system-level error.
RemoteException - This exception is defined in the method signature to provide backward compatibility for applications written for the EJB 1.0 specification. Enterprise beans written for the EJB 1.1 specification should throw the javax.ejb.EJBException instead of this exception. Enterprise beans written for the EJB2.0 and higher specifications must throw the javax.ejb.EJBException instead of this exception.

public void ejbRemove() throws EJBException, java.rmi.RemoteException
容器在结束会话对象生命周期之前调用此方法。这在客户端调用移除操作,或者容器决定在超时后终止会话对象时发生。

在无事务上下文的情况下调用此方法。

ThrowsEJBException: 该方法抛出此异常指示由于系统级错误导致的失败。
Throwsjava.rmi.RemoteException: 此异常在方法签名中定义,以提供对根据 EJB 1.0 规范编写的企业 Bean 的向后兼容。根据 EJB 1.1 规范编写的企业 Bean 应该抛出 javax.ejb.EJBException,而不是此异常。根据 EJB2.0 及更高规范编写的企业 Bean 必须抛出 javax.ejb.EJBException,而不是此异常。

英文文档:

ejbRemove

void ejbRemove()
               throws EJBException,
                      RemoteException
A container invokes this method before it ends the life of the session object. This happens as a result of a client's invoking a remove operation, or when a container decides to terminate the session object after a timeout.

This method is called with no transaction context.

Throws:
EJBException - Thrown by the method to indicate a failure caused by a system-level error.
RemoteException - This exception is defined in the method signature to provide backward compatibility for enterprise beans written for the EJB 1.0 specification. Enterprise beans written for the EJB 1.1 specification should throw the javax.ejb.EJBException instead of this exception. Enterprise beans written for the EJB2.0 and higher specifications must throw the javax.ejb.EJBException instead of this exception.

public void ejbActivate() throws EJBException, java.rmi.RemoteException
将实例从“钝化”状态激活时,调用该激活方法。实例应获得之前在 ejbPassivate() 方法中释放的所有资源。

在无事务上下文的情况下调用此方法。

ThrowsEJBException: 该方法抛出此异常指示由于系统级错误导致的失败。
Throwsjava.rmi.RemoteException: 此异常在方法签名中定义,以提供对根据 EJB 1.0 规范编写的企业 Bean 的向后兼容。根据 EJB 1.1 规范编写的企业 Bean 应该抛出 javax.ejb.EJBException,而不是此异常。根据 EJB2.0 及更高规范编写的企业 Bean 必须抛出 javax.ejb.EJBException,而不是此异常。

英文文档:

ejbActivate

void ejbActivate()
                 throws EJBException,
                        RemoteException
The activate method is called when the instance is activated from its "passive" state. The instance should acquire any resource that it has released earlier in the ejbPassivate() method.

This method is called with no transaction context.

Throws:
EJBException - Thrown by the method to indicate a failure caused by a system-level error.
RemoteException - This exception is defined in the method signature to provide backward compatibility for enterprise beans written for the EJB 1.0 specification. Enterprise beans written for the EJB 1.1 specification should throw the javax.ejb.EJBException instead of this exception. Enterprise beans written for the EJB2.0 and higher specifications must throw the javax.ejb.EJBException instead of this exception.

public void ejbPassivate() throws EJBException, java.rmi.RemoteException
在实例进入“钝化”状态之前调用该钝化方法。实例应释放它稍后可以在 ejbActivate() 方法中重新获得的所有资源。

钝化方法完成后,实例必须处于允许容器使用 Java 序列化协议来具体化和存储实例状态的状态。

在无事务上下文的情况下调用此方法。

ThrowsEJBException: 该方法抛出此异常指示由于系统级错误导致的失败。
Throwsjava.rmi.RemoteException: 此异常在方法签名中定义,以提供对根据 EJB 1.0 规范编写的企业 Bean 的向后兼容。根据 EJB 1.1 规范编写的企业 Bean 应该抛出 javax.ejb.EJBException,而不是此异常。根据 EJB2.0 及更高规范编写的企业 Bean 必须抛出 javax.ejb.EJBException,而不是此异常。

英文文档:

ejbPassivate

void ejbPassivate()
                  throws EJBException,
                         RemoteException
The passivate method is called before the instance enters the "passive" state. The instance should release any resources that it can re-acquire later in the ejbActivate() method.

After the passivate method completes, the instance must be in a state that allows the container to use the Java Serialization protocol to externalize and store away the instance's state.

This method is called with no transaction context.

Throws:
EJBException - Thrown by the method to indicate a failure caused by a system-level error.
RemoteException - This exception is defined in the method signature to provide backward compatibility for enterprise beans written for the EJB 1.0 specification. Enterprise beans written for the EJB 1.1 specification should throw the javax.ejb.EJBException instead of this exception. Enterprise beans written for the EJB2.0 and higher specifications must throw the javax.ejb.EJBException instead of this exception.


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!