package jas2.util.rmi;

import java.rmi.*;
import java.rmi.server.*;
import java.io.*;
import java.util.*;

/**
 * An RMI Destination represents a specific instance of
 * destination for remote events. Each RMIDestination 
 * is internally given a unique ID to represent the
 * place to which events should be delivered
 */
public class RMIDestination implements Externalizable
{
	public RMIDestination(){} // Needed for externalization
	RMIDestination(int id)
	{
		this.ID = id;
	}
	public void readExternal(ObjectInput in) throws IOException 
	{
		ID = in.readInt();
	}
	public void writeExternal(ObjectOutput out) throws IOException 
	{
		out.writeInt(ID);
	}
	public void addObserver(Observer obs)
	{
		if (m_obs == null) m_obs = new Vector();
		m_obs.addElement(obs);
	}
	public void removeObserver(Observer obs)
	{
		m_obs.removeElement(obs);
	}
	void notifyObservers(Object arg)
	{
		if (m_obs == null) return;
		Enumeration e = m_obs.elements();
		while (e.hasMoreElements())
		{
			Observer o = (Observer) e.nextElement();
			o.update(null,arg);
		}
	}
	int getID()
	{
		return ID;
	}
	private Vector m_obs;
	private int ID;
}

 

Ads help maintain this website.