/* JFox, the OpenSource J2EE Application Server
 *
 * Copyright (C) 2002 huihoo.com
 * Distributable under GNU LGPL license
 * See the GNU Lesser General Public License for more details.
 */

package org.jfox.ejb;

import java.rmi.RemoteException;
import javax.ejb.Handle;
import javax.ejb.RemoveException;
import javax.ejb.EJBHome;
import javax.ejb.EnterpriseBean;
import javax.ejb.HomeHandle;
import javax.ejb.EJBMetaData;

/**
 * 定义和 EJBObject,EJBHome 相对应的方法
 *
 * EJBHome 的方法可以直接继承,但是 EJBObject 里面的方法需要重新定义
 *
 * @author <a href="mailto:young_yy@hotmail.com">Young Yang</a>
 */

public interface EJBOperation {

  //########### EJBObject 定义的方法
  Object getPrimaryKey(EnterpriseBean obj) throws RemoteException;

  Handle getHandle(EnterpriseBean obj) throws RemoteException;

  boolean isIdentical(ObjectId thisObjectId, ObjectId thatObjectId) throws RemoteException;

  void remove(EnterpriseBean bean) throws RemoteException, RemoveException;

  EJBHome getEJBHome() throws RemoteException;

  void ejbCreate(EnterpriseBean bean, String createMethod, Object[] args) throws RemoteException;

  // ########## EJBHome 定义的方法
  /**
   * Remove an EJB object identified by its handle.
   *
   * @exception RemoveException Thrown if the enterprise Bean or
   *    the container does not allow the client to remove the object.
   *
   * @exception RemoteException Thrown when the method failed due to a
   *    system-level failure.
   */
  void remove(Handle handle) throws RemoteException, RemoveException;

  /**
   * Remove an EJB object identified by its primary key.
   *
   * <p>This method can be used only for an entity bean. An attempt
   * to call this method on a session bean will result in a RemoteException.
   *
   * @exception RemoveException Thrown if the enterprise Bean or
   *    the container does not allow the client to remove the object.
   *
   * @exception RemoteException Thrown when the method failed due to a
   *    system-level failure.
   */
  void remove(Object primaryKey) throws RemoteException, RemoveException;

  /**
   * Obtain the EJBMetaData interface for the enterprise Bean. The
   * EJBMetaData interface allows the client to obtain information about
   * the enterprise Bean.
   *
   * <p> The information obtainable via the EJBMetaData interface is
   * intended to be used by tools.
   *
   * @return The enterprise Bean's EJBMetaData interface.
   *
   * @exception RemoteException Thrown when the method failed due to a
   *    system-level failure.
   */
  EJBMetaData getEJBMetaData() throws RemoteException;

  /**
   * Obtain a handle for the remote home object. The handle can be used at
   * later time to re-obtain a reference to the remote home object, possibly
   * in a different Java Virtual Machine.
   *
   * @return A handle for the remote home object.
   *
   * @exception RemoteException Thrown when the method failed due to a
   *    system-level failure.
   */
  HomeHandle getHomeHandle() throws RemoteException;

}