1. /*
  2. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  3. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  4. */
  5. package javax.ejb;
  6. import java.rmi.RemoteException;
  7. /**
  8. * The SessionBean interface is implemented by every session enterprise Bean
  9. * class. The container uses the SessionBean methods to notify the enterprise
  10. * Bean instances of the instance's life cycle events.
  11. */
  12. public interface SessionBean extends EnterpriseBean {
  13. /**
  14. * Set the associated session context. The container calls this method
  15. * after the instance creation.
  16. *
  17. * <p> The enterprise Bean instance should store the reference to the
  18. * context object in an instance variable.
  19. *
  20. * <p> This method is called with no transaction context.
  21. *
  22. * @param ctx A SessionContext interface for the instance.
  23. *
  24. * @exception EJBException Thrown by the method to indicate a failure
  25. * caused by a system-level error.
  26. *
  27. * @exception RemoteException This exception is defined in the method
  28. * signature to provide backward compatibility for applications written
  29. * for the EJB 1.0 specification. Enterprise beans written for the
  30. * EJB 1.1 specification should throw the
  31. * javax.ejb.EJBException instead of this exception.
  32. * Enterprise beans written for the EJB2.0 and higher specifications
  33. * must throw the javax.ejb.EJBException instead of this exception.
  34. */
  35. void setSessionContext(SessionContext ctx) throws EJBException,
  36. RemoteException;
  37. /**
  38. * A container invokes this method before it ends the life of the session
  39. * object. This happens as a result of a client's invoking a remove
  40. * operation, or when a container decides to terminate the session object
  41. * after a timeout.
  42. *
  43. * <p> This method is called with no transaction context.
  44. *
  45. * @exception EJBException Thrown by the method to indicate a failure
  46. * caused by a system-level error.
  47. *
  48. * @exception RemoteException This exception is defined in the method
  49. * signature to provide backward compatibility for enterprise beans
  50. * written for the EJB 1.0 specification. Enterprise beans written
  51. * for the EJB 1.1 specification should throw the
  52. * javax.ejb.EJBException instead of this exception.
  53. * Enterprise beans written for the EJB2.0 and higher specifications
  54. * must throw the javax.ejb.EJBException instead of this exception.
  55. */
  56. void ejbRemove() throws EJBException, RemoteException;
  57. /**
  58. * The activate method is called when the instance is activated
  59. * from its "passive" state. The instance should acquire any resource
  60. * that it has released earlier in the ejbPassivate() method.
  61. *
  62. * <p> This method is called with no transaction context.
  63. *
  64. * @exception EJBException Thrown by the method to indicate a failure
  65. * caused by a system-level error.
  66. *
  67. * @exception RemoteException This exception is defined in the method
  68. * signature to provide backward compatibility for enterprise beans
  69. * written for the EJB 1.0 specification. Enterprise beans written
  70. * for the EJB 1.1 specification should throw the
  71. * javax.ejb.EJBException instead of this exception.
  72. * Enterprise beans written for the EJB2.0 and higher specifications
  73. * must throw the javax.ejb.EJBException instead of this exception.
  74. */
  75. void ejbActivate() throws EJBException, RemoteException;
  76. /**
  77. * The passivate method is called before the instance enters
  78. * the "passive" state. The instance should release any resources that
  79. * it can re-acquire later in the ejbActivate() method.
  80. *
  81. * <p> After the passivate method completes, the instance must be
  82. * in a state that allows the container to use the Java Serialization
  83. * protocol to externalize and store away the instance's state.
  84. *
  85. * <p> This method is called with no transaction context.
  86. *
  87. * @exception EJBException Thrown by the method to indicate a failure
  88. * caused by a system-level error.
  89. *
  90. * @exception RemoteException This exception is defined in the method
  91. * signature to provide backward compatibility for enterprise beans
  92. * written for the EJB 1.0 specification. Enterprise beans written
  93. * for the EJB 1.1 specification should throw the
  94. * javax.ejb.EJBException instead of this exception.
  95. * Enterprise beans written for the EJB2.0 and higher specifications
  96. * must throw the javax.ejb.EJBException instead of this exception.
  97. */
  98. void ejbPassivate() throws EJBException, RemoteException;
  99. }