/**
  * File: GroupMonitorBaseImpl.java
  * Content: Defines an abstract rmi class to implement the GroupMonitor 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 GroupMonitor RMI interface.
  **/
public abstract class GroupMonitorBaseImpl extends UnicastRemoteObject implements GroupMonitor
{

  public GroupMonitorBaseImpl() throws Exception
  {
    thisGroupMonitor=this;
  }

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

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

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

  public final GroupMonitor theGroupMonitor()
  {
    return thisGroupMonitor;
  }

  protected GroupMonitor thisGroupMonitor;
};