/*
 * 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
 *
 * --------------------------------------------------------------------------
 * $Id$
 * --------------------------------------------------------------------------
 */

package org.objectweb.jonas.jtests.beans.flocal;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import javax.ejb.CreateException;
import javax.ejb.EJBException;
import javax.ejb.RemoveException;
import javax.ejb.EJBObject;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;


/**
 * Stateful Session
 * @author Philippe Durieux, Philippe Coq
 */
public class TargetSF extends TargetSL {

    public String string;
    public int number;
    public  boolean createdViaCreateXX;
    public  boolean createdViaCreateYY;
	
    /**
     * The Session bean must define 1 or more ejbCreate methods.
     *
     * @throws CreateException Failure to create a session EJB object.
     */
    public void ejbCreate() throws CreateException {
        //	logger.log(BasicLevel.DEBUG, "");
        string = "";
        number = 0;
        createdViaCreateXX = false;        
        createdViaCreateYY = false;
    }

	
    /**
     * ejbCreate methods with parameter
     *
     * @throws CreateException Failure to create a session EJB object.
     */
    public void ejbCreate(String s, int n) throws CreateException {
        //	logger.log(BasicLevel.DEBUG, "");
        string = s;
        number = n;
        createdViaCreateXX = false;        
        createdViaCreateYY = false;
    }

    	
    /**
     * ejbCreate methods for a create<METHOD>
     *
     * @throws CreateException Failure to create a session EJB object.
     */
    public void ejbCreateXX(String s, int n) throws CreateException {
        //logger.log(BasicLevel.DEBUG, "");
        string = s;
        number = n;
        createdViaCreateXX = true;        
        createdViaCreateYY = false;
    }

    /**
     * ejbCreate methods for a Local create<METHOD>
     *
     * @throws CreateException Failure to create a session EJB object.
     */
    public void ejbCreateYY(String s, int n) throws CreateException {
        //logger.log(BasicLevel.DEBUG, "");
        string = s;
        number = n;
        createdViaCreateXX = false;        
        createdViaCreateYY = true;
    }


    // ------------------------------------------------------------------
    // Target implementation
    // ------------------------------------------------------------------

    /**
     * getNumber
     */
    public int  getNumber() {
        //logger.log(BasicLevel.DEBUG, "");
        return number;
    }

   /**
     * getString
     */
    public String  getString() {
        //logger.log(BasicLevel.DEBUG, "");
        return string;
    }

    /**
     * isCreatedViaCreateXX
     */
    public boolean  isCreatedViaCreateXX() {
        //logger.log(BasicLevel.DEBUG, "");
        return createdViaCreateXX;
    }

    // ------------------------------------------------------------------
    // TargetLocal implementation
    // ------------------------------------------------------------------

    /**
     * isCreatedViaCreateYY
     */
    public boolean  isCreatedViaCreateYY() {
        //logger.log(BasicLevel.DEBUG, "");
        return createdViaCreateYY;
    }
}
