
package applis.ejb.perfs;

import java.rmi.RemoteException;
import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
import javax.ejb.RemoveException;
import javax.ejb.CreateException;

import org.objectweb.jonas.common.Log;
import org.objectweb.util.monolog.api.Logger;
import org.objectweb.util.monolog.api.BasicLevel;

public class PerfsBean implements EntityBean {
 
    static protected Logger logger = null;

    protected EntityContext entityContext;

    public  int	code  = 0;
    public  String value = null;

    public PerfsBeanPK ejbCreate(int i, String s) throws CreateException, RemoteException {
	code = i;
	value = s;
	// In CMP, should return null.
	return null;
    }

    public void ejbPostCreate(int i, String s) throws CreateException, RemoteException {
    }

    public void ejbActivate() throws RemoteException {
    }

    public void ejbPassivate() throws RemoteException {
    }

    public void ejbLoad() throws RemoteException {
    }

    public void ejbStore() throws RemoteException {
    }
  
    public void ejbRemove() throws RemoveException{
    }

    public void setEntityContext(EntityContext ctx) {
        if (logger == null)
            logger = Log.getLogger(Log.JONAS_TESTS_PREFIX);
        logger.log(BasicLevel.DEBUG, "");
        entityContext  = ctx;
    }

    public void unsetEntityContext() {
    }

    public String read() throws RemoteException {
        logger.log(BasicLevel.DEBUG, "value = "+value);
        return value;
    }

    public void write(String v) throws RemoteException {
        logger.log(BasicLevel.DEBUG, "value = "+v);
        value = new String(v);
    }

    public String txread() throws RemoteException {
        logger.log(BasicLevel.DEBUG, "value = "+value);
        return value;
    }

    public void txwrite(String v) throws RemoteException {
        logger.log(BasicLevel.DEBUG, "value = "+v);
        value = new String(v);
    }

} 

