package Distributed;
import java.util.Hashtable;
import java.net.UnknownHostException;
import java.net.InetAddress;
import java.io.Serializable;
import Framework.remoting.parameters.Input;
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 Distributed2.TopCustomizedDBMgr;
/**
Anchored object proxy for {@link BottomBusinessDBMgr}.
*/
@SuppressWarnings("serial")
public class BottomBusinessDBMgrProxy extends BottomBusinessDBMgr 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 BottomBusinessDBMgrProxy() {
super((ServiceObjectContext)null);
}
/**
* This constructor can store no reference to the original object,
* but must instead copy over it's necessary attributes.
*/
public BottomBusinessDBMgrProxy(BottomBusinessDBMgr 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;
}
@Override
public TopCustomizedDBMgr getDBMgr() {
String qq_name = MethodMapper.computeName("getDBMgr");
return (TopCustomizedDBMgr)getServiceProxy().intercept(qq_name);
}
@Override
public void setDBMgr(TopCustomizedDBMgr pValue) {
String qq_name = MethodMapper.computeName("setDBMgr", TopCustomizedDBMgr.class);
getServiceProxy().intercept(qq_name, pValue);
}
@Override
public TopCustomizedDBMgr getParentService() {
String qq_name = MethodMapper.computeName("getParentService");
return (TopCustomizedDBMgr)getServiceProxy().intercept(qq_name);
}
@Override
public void setParentService(TopCustomizedDBMgr pValue) {
String qq_name = MethodMapper.computeName("setParentService", TopCustomizedDBMgr.class);
getServiceProxy().intercept(qq_name, pValue);
}
@Override
public void setup(@Input TopCustomizedDBMgr aParentService) {
String qq_name = MethodMapper.computeName("setup", TopCustomizedDBMgr.class);
getServiceProxy().intercept(qq_name, aParentService);
}
@Override
public void someWork() {
String qq_name = MethodMapper.computeName("someWork");
getServiceProxy().intercept(qq_name);
}
@Override
public void setup() {
String qq_name = MethodMapper.computeName("setup");
getServiceProxy().intercept(qq_name);
}
/**
* 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);
}
}