package RemoveEventsWithAnchoredObjects;
import java.util.Hashtable;
import java.net.UnknownHostException;
import java.net.InetAddress;
import java.lang.String;
import java.io.Serializable;
import java.io.ObjectStreamException;
import java.beans.PropertyChangeSupport;
import java.beans.PropertyChangeListener;
import Framework.anchored.ServiceProxy;
import Framework.anchored.ServiceInvoker;
import Framework.anchored.MethodMapper;
import Framework.anchored.AnchoredProxy;
import Framework.anchored.Anchorable;
import Framework.UsageException;
import Framework.ServiceObjectContext;
import Framework.RuntimeProperties;
import Framework.RemoteProxy;
import Framework.RemoteEvent;
import Framework.EventManager;
import DisplayProject.binding.beans.Observable;
import DisplayProject.binding.beans.ExtendedPropertyChangeSupport;
/**
Anchored object proxy for {@link Notify}.
*/
@SuppressWarnings("serial")
public class NotifyProxy extends Notify implements AnchoredProxy, RemoteProxy {
private transient ServiceProxy proxy = null;
private String objectName;
private String hostName;
private int port;
/**
* @deprecated This constructor is present only to allow proxies to be serialised via the efficient serialiser
* and should not be called at any other time.
*/
public NotifyProxy() {
super((ServiceObjectContext)null);
}
/**
* This constructor can store no reference to the original object,
* but must instead copy over it's necessary attributes.
*/
public NotifyProxy(Notify baseClass) {
super((ServiceObjectContext)null);
ServiceInvoker serviceInvoker = getInvoker(baseClass);
if (serviceInvoker == null) {
throw new UsageException("Cannot create a proxy for an object that has not yet been exported.");
}
this.objectName = serviceInvoker.getObjectName();
// The proxy is being created on the same host as the real object
//this.hostName = System.getProperty("RMIregistry.host");
try {
this.hostName = InetAddress.getLocalHost().getHostAddress();
} catch (UnknownHostException e) {
throw new UsageException("Cannot BIND to RMI object ", e);
}
this.port = serviceInvoker.getPort();
}
private ServiceProxy getServiceProxy() {
if (proxy == null) {
proxy = new ServiceProxy(objectName, hostName, port, this.getClass().getSuperclass());
}
return proxy;
}
/**
* Satisfy the {@link RemoteEventProxy} interface
*/
@Override
public String registerInterest(String pHostName, RemoteEvent pAnchoredObject, String pEvent) {
String qq_name = MethodMapper.computeName("registerInterest", String.class, RemoteEvent.class, String.class);
return (String)getServiceProxy().intercept(qq_name, pHostName, pAnchoredObject, pEvent);
}
@Override
public void postEvent(String pEventName, Hashtable<String, Object> pParameters) {
String qq_name = MethodMapper.computeName("postEvent", String.class, Hashtable.class);
getServiceProxy().intercept(qq_name, pEventName, pParameters);
}
@Override
public void deregisterInterest(String pHostName, RemoteEvent pAnchoredObject, String pEvent) {
String qq_name = MethodMapper.computeName("deregisterInterest", String.class, RemoteEvent.class, String.class);
getServiceProxy().intercept(qq_name, pHostName, pAnchoredObject, pEvent);
}
}