/**
  * File: ExtendedCheckpointableBaseImpl.java
  * Content: Defines an abstract rmi class to implement the ExtendedCheckpointable interface
  * Author: LuisM Pena
  * Date: 28th October 2001
  * Version:  0.51.00
  * Last change:
  *
  **/

package sensei.middleware.domains;

import java.rmi.server.UnicastRemoteObject;

/**
  * Implementation of the ExtendedCheckpointable RMI interface.
  **/
public abstract class ExtendedCheckpointableBaseImpl extends UnicastRemoteObject implements ExtendedCheckpointable
{

  public ExtendedCheckpointableBaseImpl() throws Exception
  {
    thisExtendedCheckpointable=this;
  }

  public ExtendedCheckpointableBaseImpl(boolean activate) throws Exception
  {
    if (!activate)
      deactivate();
  }

  public void activate() throws Exception
  {
    if (thisExtendedCheckpointable==null)
    {
      thisExtendedCheckpointable=this;
      exportObject(this);
    }
  }

  public void deactivate() throws Exception
  {
    synchronized (this)
    {
      if (thisExtendedCheckpointable!=null)
        unexportObject(thisExtendedCheckpointable,true);
      thisExtendedCheckpointable=null;
    }
  }

  public final ExtendedCheckpointable theExtendedCheckpointable()
  {
    return thisExtendedCheckpointable;
  }

  protected ExtendedCheckpointable thisExtendedCheckpointable;
};