/* JFox, the OpenSource J2EE Application Server
 *
 * Distributable under GNU LGPL license by gun.org
 * more details please visit http://www.huihoo.org/jfox
 */

package org.jfox.ejb;

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

/**
 * 定义和 EJBObject,EJBHome 相对应的方法
 * <p/>
 * 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(EJBObjectId thisObjectId, EJBObjectId 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.
     *
     * @throws RemoveException Thrown if the enterprise Bean or
     *                         the container does not allow the client to remove the object.
     * @throws 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/>
     * <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.
     *
     * @throws RemoveException Thrown if the enterprise Bean or
     *                         the container does not allow the client to remove the object.
     * @throws 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/>
     * <p> The information obtainable via the EJBMetaData interface is
     * intended to be used by tools.
     *
     * @return The enterprise Bean's EJBMetaData interface.
     * @throws 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.
     * @throws RemoteException Thrown when the method failed due to a
     *                         system-level failure.
     */
    HomeHandle getHomeHandle() throws RemoteException;

}
