/*
 * JOnAS: Java(TM) Open Application Server
 * Copyright (C) 1999 Bull S.A.
 * Contact: jonas-team@objectweb.org
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 * USA
 *
 * Initial developer(s): Philippe Durieux
 * Contributor(s):
 *
 * --------------------------------------------------------------------------
 * $Id$
 * --------------------------------------------------------------------------
 */

package org.objectweb.jonas_ejb.container;

import java.rmi.RemoteException;
import javax.ejb.RemoveException;
import org.objectweb.jonas_ejb.deployment.api.SessionDesc;

/**
 * This class is the Standard Home for Session objects
 * It exists only for beans that have declared a Remote Interface.
 * It implements javax.ejb.EJBHome interface (by the inherited class JHome)
 * It implements a pool of EJBObject's
 */
public abstract class JSessionHome extends JHome {

    /**
     * constructor
     */
    public JSessionHome(SessionDesc dd, JSessionFactory bf) throws RemoteException {
	super(dd, bf);
	TraceEjb.debugIc("JSessionHome constructor");
    }

    // ---------------------------------------------------------------
    // EJBHome implementation
    // remove(Handle) method is in the generated part.
    // other methods are in JHome (identical for Sessions and Entities)
    // ---------------------------------------------------------------

    /**
     * remove(pk) is not allowed for session beans
     */
    public void remove(java.lang.Object pk) throws RemoteException, RemoveException {
	throw new RemoveException("remove by PK Cannot be called in a session bean");
    }

    // ---------------------------------------------------------------
    // other public methods, for internal use.
    // ---------------------------------------------------------------

    public RequestCtx preInvoke(int txa, String secu) throws RemoteException {
	TraceEjb.debugIc("JSessionHome preInvoke");
	return bf.preInvokeRemote(txa, secu);
    }

    public void postInvoke(RequestCtx rctx) throws RemoteException {
	TraceEjb.debugIc("JSessionHome postInvoke");
	bf.postInvokeRemote(rctx);
    }

    /**
     * Creates the EJBObject (remote)
     * this is in the generated class because it is mainly "new objectClass()"
     */
    abstract public JSessionRemote createRemoteObject() throws RemoteException;

}
