## ---------------------------------------------------------------------------
## JOnAS: Java(TM) Open Application Server
## Copyright (C) 1999-2004 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, Helene Joanin.
## Contributor(s): ______________________________________.
##
## ---------------------------------------------------------------------------
## $Id: JStatelessHome.vm 11874 2007-10-28 11:46:45Z loris $
## ---------------------------------------------------------------------------

// This class is the bean specific part of JSessionHome for Stateless Sessions
// Generated by GenIC via Velocity. Do not edit directly this file.
// Start: $Id: JStatelessHome.vm 11874 2007-10-28 11:46:45Z loris $

#if ($package.length() != 0)
package $package;
#end

import java.lang.Error;
import java.rmi.RemoteException;

import javax.ejb.Handle;
import javax.ejb.RemoveException;
import javax.ejb.SessionBean;

import org.ow2.jonas.lib.ejb21.RequestCtx;
import org.ow2.jonas.lib.ejb21.JFactory;
import org.ow2.jonas.lib.ejb21.JSessionContext;
import org.ow2.jonas.lib.ejb21.JSessionFactory;
import org.ow2.jonas.lib.ejb21.JSessionHome;
import org.ow2.jonas.lib.ejb21.JSessionRemote;
import org.ow2.jonas.lib.ejb21.JSessionSwitch;
import org.ow2.jonas.lib.ejb21.JStatelessFactory;
import org.ow2.jonas.lib.ejb21.TraceEjb;
import org.ow2.jonas.deployment.ejb.MethodDesc;
import org.ow2.jonas.deployment.ejb.SessionDesc;
import org.ow2.jonas.lib.ejb21.EJBInvocation;

import org.ow2.carol.rmi.exception.RmiUtility;
import org.objectweb.util.monolog.api.BasicLevel;


public class $class extends JSessionHome implements $home {

    // JOnAS version used to deploy
    public static final String JONAS_VERSION = "$jVersion";

    /**
     * Created by JSessionFactory (by newInstance)
     */
    public $class(SessionDesc dd, JSessionFactory bf) throws RemoteException {

        super(dd, bf);
    }

#foreach ($M in $methodList)

#if ($M.isCreate())

    /**
     * create method (unique for stateless session beans)
     */
    public $M.getReturnType() create() throws $M.getExceptionList() {

        //TraceEjb.interp.log(BasicLevel.DEBUG, "");

        #beforeThrowRemoteException()

        EJBInvocation ejbInv = new EJBInvocation();
        ejbInv.methodPermissionSignature = "$M.getSecuritySignature()";
        ejbInv.arguments = $M.getArrayObjectParameters();
        RequestCtx rctx = preInvoke(MethodDesc.TX_NOT_SET);
        checkSecurity(ejbInv);
        JSessionSwitch bs = null;
        try {
            rctx.bmcalled = true;
            bs = ((JSessionFactory) bf).createEJB();
        } catch (javax.ejb.AccessLocalException e) {
            throw new RemoteException("Security Exception thrown by an enterprise Bean", e);
        } catch (RuntimeException e) {
            rctx.sysExc = e;
            throw new RemoteException("RuntimeException thrown by an enterprise Bean", e);
        } catch (Error e) {
            rctx.sysExc = e;
            throw new RemoteException("Error thrown by an enterprise Bean", e);
        } catch (RemoteException e) {
            rctx.sysExc = e;
            throw e;
        } finally {
            postInvoke(rctx);
        }

        return ($remote) bs.getRemote();

        #afterThrowRemoteException()

    }

#elseif ($M.isRemoveHandle())

    /**
     * Remove by Handle
     */
    public void remove(Handle p1) throws $M.getExceptionList() {

        //TraceEjb.interp.log(BasicLevel.DEBUG, "");

        #beforeThrowRemoteException()

        EJBInvocation ejbInv = new EJBInvocation();
        ejbInv.methodPermissionSignature = "$M.getSecuritySignature()";
        ejbInv.arguments = $M.getArrayObjectParameters();
        RequestCtx rctx = preInvoke(MethodDesc.TX_NOT_SET);
        checkSecurity(ejbInv);
        javax.ejb.EJBObject ejbobj = null;
        try {
            ejbobj = p1.getEJBObject();
            rctx.bmcalled = true;
            ejbobj.remove();
        } catch (javax.ejb.AccessLocalException e) {
            throw new RemoteException("Security Exception thrown by an enterprise Bean", e);
        } catch (RuntimeException e) {
            rctx.sysExc = e;
            throw new RemoteException("RuntimeException thrown by an enterprise Bean", e);
        } catch (Error e) {
            rctx.sysExc = e;
            throw new RemoteException("Error thrown by an enterprise Bean", e);
        } catch (RemoteException e) {
            rctx.sysExc = e;
            throw e;
        } finally {
            postInvoke(rctx);
        }

        #afterThrowRemoteException()
    }

#end

#end

    public JSessionRemote createRemoteObject() throws RemoteException {

        #beforeThrowRemoteException()

        return new $remote_wrp((JStatelessFactory)bf);

        #afterThrowRemoteException()

    }
}
// End: $Id: JStatelessHome.vm 11874 2007-10-28 11:46:45Z loris $
