## ---------------------------------------------------------------------------
## 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): Guillaume Sauthier
## Contributor(s): ______________________________________.
##
## ---------------------------------------------------------------------------
## $Id$
## ---------------------------------------------------------------------------

// This class is the bean specific part of JServiceEndpoint
// Generated by GenIC via Velocity. Do not edit directly this file.
// Start: $Id$

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

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

import javax.ejb.EJBException;
import javax.ejb.RemoveException;

import org.ow2.carol.rmi.exception.RmiUtility;
import org.ow2.jonas.lib.ejb21.JSessionContext;
import org.ow2.jonas.lib.ejb21.JStatelessFactory;
import org.ow2.jonas.lib.ejb21.JServiceEndpoint;
import org.ow2.jonas.lib.ejb21.RequestCtx;
import org.ow2.jonas.lib.ejb21.TraceEjb;
import org.ow2.jonas.lib.ejb21.EJBInvocation;

import org.ow2.jonas.deployment.ejb.SessionStatelessDesc;

import org.objectweb.util.monolog.api.BasicLevel;

public class $class extends JServiceEndpoint implements $serviceEndpoint {

    /**
     * Constructor
     */
    public $class(JStatelessFactory sf) throws RemoteException {
        super(sf);
    }

#foreach ($M in $methodList)

    public $M.getReturnType() $M.getName()($M.getFormalParameters())
    #if ( $M.getExceptionList().length() > 0 )
    throws $M.getExceptionList()
    #end

    {

    //logger.log(BasicLevel.DEBUG, "");

    #beforeThrowRemoteException()

    #if ($M.getReturnType() != "void")
    $M.getReturnType() result;
    #end

    EJBInvocation ejbInv = new EJBInvocation();
    ejbInv.methodPermissionSignature = "$M.getSecuritySignature()";
    ejbInv.arguments = $M.getArrayObjectParameters();
    RequestCtx rctx = preInvoke($M.getTxAttribute());
    try {
        rctx.ejbContext = bs.getICtx(rctx.currTx);
        $bean_wrp b = ($bean_wrp) rctx.ejbContext.getInstance();
        ejbInv.bean = b;
        checkSecurity(ejbInv);
        rctx.bmcalled = true;

        #if ($M.getReturnType() != "void")
        result =
        #end
        b.$M.getName()($M.getActualParameters());

    } catch (javax.ejb.AccessLocalException e) {
        throw new EJBException("Security Exception thrown by an enterprise Bean", e);
    } catch (EJBException e) {
        rctx.sysExc = e;
        throw e;
    } catch (RuntimeException e) {
        rctx.sysExc = e;
        throw new EJBException("RuntimeException thrown by an enterprise Bean", e);
    } catch (Error e) {
        rctx.sysExc = e;
        throw new EJBException("Error thrown by an enterprise Bean"+e);
    } catch (RemoteException e) {
        rctx.sysExc = e;
        throw new EJBException("Remote Exception raised:", e);
    } finally {
        postInvoke(rctx);
    }

    #if ($M.getReturnType() != "void")
    return result;
    #end

    #afterThrowRemoteException()

    }

#end

}
// End: $Id$
