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 EntityBean interface is implemented by every entity enterprise Bean
  9. * class. The container uses the EntityBean methods to notify the enterprise
  10. * Bean instances of the instance's life cycle events.
  11. */
  12. public interface EntityBean extends EnterpriseBean {
  13. /**
  14. * Set the associated entity context. The container invokes this method
  15. * on an instance after the instance has been created.
  16. *
  17. * <p> This method is called in an unspecified transaction context.
  18. *
  19. * @param ctx An EntityContext interface for the instance. The instance
  20. * should store the reference to the context in an instance variable.
  21. *
  22. * @exception EJBException Thrown by the method to indicate a failure
  23. * caused by a system-level error.
  24. *
  25. * @exception RemoteException This exception is defined in the method
  26. * signature to provide backward compatibility for enterprise beans
  27. * written for the EJB 1.0 specification. Enterprise beans written
  28. * for the EJB 1.1 specification should throw the
  29. * javax.ejb.EJBException instead of this exception.
  30. * Enterprise beans written for the EJB2.0 and higher specifications
  31. * must throw the javax.ejb.EJBException instead of this exception.
  32. */
  33. public void setEntityContext(EntityContext ctx) throws EJBException,
  34. RemoteException;
  35. /**
  36. * Unset the associated entity context. The container calls this method
  37. * before removing the instance.
  38. *
  39. * <p> This is the last method that the container invokes on the instance.
  40. * The Java garbage collector will eventually invoke the finalize() method
  41. * on the instance.
  42. *
  43. * <p> This method is called in an unspecified 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. public void unsetEntityContext() throws EJBException, RemoteException;
  57. /**
  58. * A container invokes this method before it removes the EJB object
  59. * that is currently associated with the instance. This method
  60. * is invoked when a client invokes a remove operation on the
  61. * enterprise Bean's home interface or the EJB object's remote interface.
  62. * This method transitions the instance from the ready state to the pool
  63. * of available instances.
  64. *
  65. * <p> This method is called in the transaction context of the remove
  66. * operation.
  67. *
  68. * @exception RemoveException The enterprise Bean does not allow
  69. * destruction of the object.
  70. *
  71. * @exception EJBException Thrown by the method to indicate a failure
  72. * caused by a system-level error.
  73. *
  74. * @exception RemoteException This exception is defined in the method
  75. * signature to provide backward compatibility for enterprise beans
  76. * written for the EJB 1.0 specification. Enterprise beans written
  77. * for the EJB 1.1 specification should throw the
  78. * javax.ejb.EJBException instead of this exception.
  79. * Enterprise beans written for the EJB2.0 and higher specifications
  80. * must throw the javax.ejb.EJBException instead of this exception.
  81. */
  82. public void ejbRemove() throws RemoveException, EJBException,
  83. RemoteException;
  84. /**
  85. * A container invokes this method when the instance
  86. * is taken out of the pool of available instances to become associated
  87. * with a specific EJB object. This method transitions the instance to
  88. * the ready state.
  89. *
  90. * <p> This method executes in an unspecified transaction context.
  91. *
  92. * @exception EJBException Thrown by the method to indicate a failure
  93. * caused by a system-level error.
  94. *
  95. * @exception RemoteException This exception is defined in the method
  96. * signature to provide backward compatibility for enterprise beans
  97. * written for the EJB 1.0 specification. Enterprise beans written
  98. * for the EJB 1.1 specification should throw the
  99. * javax.ejb.EJBException instead of this exception.
  100. * Enterprise beans written for the EJB2.0 and higher specifications
  101. * must throw the javax.ejb.EJBException instead of this exception.
  102. */
  103. public void ejbActivate() throws EJBException, RemoteException;
  104. /**
  105. * A container invokes this method on an instance before the instance
  106. * becomes disassociated with a specific EJB object. After this method
  107. * completes, the container will place the instance into the pool of
  108. * available instances.
  109. *
  110. * <p> This method executes in an unspecified transaction context.
  111. *
  112. * @exception EJBException Thrown by the method to indicate a failure
  113. * caused by a system-level error.
  114. *
  115. * @exception RemoteException This exception is defined in the method
  116. * signature to provide backward compatibility for enterprise beans
  117. * written for the EJB 1.0 specification. Enterprise beans written
  118. * for the EJB 1.1 specification should throw the
  119. * javax.ejb.EJBException instead of this exception.
  120. * Enterprise beans written for the EJB2.0 and higher specifications
  121. * must throw the javax.ejb.EJBException instead of this exception.
  122. */
  123. public void ejbPassivate() throws EJBException, RemoteException;
  124. /**
  125. * A container invokes this method to instruct the
  126. * instance to synchronize its state by loading it state from the
  127. * underlying database.
  128. *
  129. * <p> This method always executes in the transaction context determined
  130. * by the value of the transaction attribute in the deployment descriptor.
  131. *
  132. * @exception EJBException Thrown by the method to indicate a failure
  133. * caused by a system-level error.
  134. *
  135. * @exception RemoteException This exception is defined in the method
  136. * signature to provide backward compatibility for enterprise beans
  137. * written for the EJB 1.0 specification. Enterprise beans written
  138. * for the EJB 1.1 specification should throw the
  139. * javax.ejb.EJBException instead of this exception.
  140. * Enterprise beans written for the EJB2.0 and higher specifications
  141. * must throw the javax.ejb.EJBException instead of this exception.
  142. */
  143. public void ejbLoad() throws EJBException, RemoteException;
  144. /**
  145. * A container invokes this method to instruct the
  146. * instance to synchronize its state by storing it to the underlying
  147. * database.
  148. *
  149. * <p> This method always executes in the transaction context determined
  150. * by the value of the transaction attribute in the deployment descriptor.
  151. *
  152. * @exception EJBException Thrown by the method to indicate a failure
  153. * caused by a system-level error.
  154. *
  155. * @exception RemoteException This exception is defined in the method
  156. * signature to provide backward compatibility for enterprise beans
  157. * written for the EJB 1.0 specification. Enterprise beans written
  158. * for the EJB 1.1 specification should throw the
  159. * javax.ejb.EJBException instead of this exception.
  160. * Enterprise beans written for the EJB2.0 and higher specifications
  161. * must throw the javax.ejb.EJBException instead of this exception.
  162. */
  163. public void ejbStore() throws EJBException, RemoteException;
  164. }