package Express.services;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Hashtable;
import Express.services.interfaces.IBusinessMgr;
import Express.services.interfaces.IBusinessServiceMgr;
import Framework.RemoteEvent;
import Framework.RemoteEventProxy;
import Framework.RemoteProxy;
import Framework.ServiceObjectContext;
import Framework.TextData;
import Framework.UsageException;
import Framework.anchored.AnchoredProxy;
import Framework.anchored.MethodMapper;
import Framework.anchored.ServiceInvoker;
import Framework.anchored.ServiceProxy;
import Framework.remoting.parameters.Input;
import GenericDBMS.DBConnectionManager;
/**
Anchored object proxy for {@link BusinessDBMgr}.
*/
public class BusinessDBMgrProxy extends BusinessDBMgr implements AnchoredProxy, RemoteProxy {
private transient ServiceProxy proxy = null;
private String objectName;
private String hostName;
private int port;
/**
* This constructor can store no reference to the original object,
* but must instead copy over it's necessary attributes.
*/
public BusinessDBMgrProxy(BusinessDBMgr baseClass) {
super(new ServiceObjectContext());
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 DBConnectionManager getDB() {
String name = MethodMapper.computeName("getDB");
return (DBConnectionManager)getServiceProxy().intercept(name);
}
@Override
public void setDB(DBConnectionManager pValue) {
String qq_name = MethodMapper.computeName("setDB", DBConnectionManager.class);
getServiceProxy().intercept(qq_name, pValue);
}
@SuppressWarnings("unchecked")
@Override
public Array_Of_IBusinessMgr<IBusinessMgr> getForeignMgrs() {
String name = MethodMapper.computeName("getForeignMgrs");
return (Array_Of_IBusinessMgr<IBusinessMgr>)getServiceProxy().intercept(name);
}
@Override
public void setForeignMgrs(Array_Of_IBusinessMgr<IBusinessMgr> pValue) {
String qq_name = MethodMapper.computeName("setForeignMgrs", Array_Of_BusinessMgr.class);
getServiceProxy().intercept(qq_name, pValue);
}
@Override
public SqlStatementCache getStatementCache() {
String name = MethodMapper.computeName("getStatementCache");
return (SqlStatementCache)getServiceProxy().intercept(name);
}
@Override
public void setStatementCache(SqlStatementCache pValue) {
String qq_name = MethodMapper.computeName("setStatementCache", SqlStatementCache.class);
getServiceProxy().intercept(qq_name, pValue);
}
@Override
public IBusinessServiceMgr getParentService() {
String name = MethodMapper.computeName("getParentService");
return (IBusinessServiceMgr)getServiceProxy().intercept(name);
}
@Override
public void setParentService(IBusinessServiceMgr pValue) {
String qq_name = MethodMapper.computeName("setParentService", BusinessServiceMgr.class);
getServiceProxy().intercept(qq_name, pValue);
}
@Override
public boolean getReadOnly() {
String name = MethodMapper.computeName("getReadOnly");
return ((Boolean)getServiceProxy().intercept(name)).booleanValue();
}
@Override
public void setReadOnly(boolean pValue) {
String qq_name = MethodMapper.computeName("setReadOnly", Boolean.TYPE);
getServiceProxy().intercept(qq_name, pValue);
}
@Override
public Trace getTrace() {
String name = MethodMapper.computeName("getTrace");
return (Trace)getServiceProxy().intercept(name);
}
@Override
public void setTrace(Trace pValue) {
String qq_name = MethodMapper.computeName("setTrace", Trace.class);
getServiceProxy().intercept(qq_name, pValue);
}
@Override
public void executeSql(@Input SqlQuery sqlQuery, @Input TextData sqlText, @Input SqlData sqlData) {
String qq_name = MethodMapper.computeName("executeSql", SqlQuery.class, TextData.class, SqlData.class);
getServiceProxy().intercept(qq_name, sqlQuery, sqlText, sqlData);
}
@Override
public TextData formatSqlText(@Input TextData sqlText, @Input SqlData sqlData) {
String qq_name = MethodMapper.computeName("formatSqlText", TextData.class, SqlData.class);
return (TextData)getServiceProxy().intercept(qq_name, sqlText, sqlData);
}
@Override
public TextData formatSqlText(@Input TextData sqlText) {
String qq_name = MethodMapper.computeName("formatSqlText", TextData.class);
return (TextData)getServiceProxy().intercept(qq_name, sqlText);
}
@Override
public void newKey(@Input BusinessClass source) {
String qq_name = MethodMapper.computeName("newKey", BusinessClass.class);
getServiceProxy().intercept(qq_name, source);
}
@SuppressWarnings("unchecked")
@Override
public Array_Of_BusinessClass<BusinessClass> select(@Input BusinessQuery query) {
String qq_name = MethodMapper.computeName("select", BusinessQuery.class);
return (Array_Of_BusinessClass<BusinessClass>)getServiceProxy().intercept(qq_name, query);
}
@Override
public void selectCorrelated(@Input SqlQuery sqlQuery, @Input Array_Of_BusinessClass<BusinessClass> result, @Input Array_Of_BusinessQuery<BusinessQuery> queries, @Input Array_Of_ConstraintAttr<ConstraintAttr> orderBy) {
String qq_name = MethodMapper.computeName("selectCorrelated", SqlQuery.class, Array_Of_BusinessClass.class, Array_Of_BusinessQuery.class, Array_Of_ConstraintAttr.class);
getServiceProxy().intercept(qq_name, sqlQuery, result, queries, orderBy);
}
@Override
public void selectForeign(@Input SqlQuery sqlQuery, @Input Array_Of_BusinessClass<BusinessClass> result, @Input Array_Of_BusinessQuery<BusinessQuery> queries, @Input Array_Of_ConstraintAttr<ConstraintAttr> orderBy) {
String qq_name = MethodMapper.computeName("selectForeign", SqlQuery.class, Array_Of_BusinessClass.class, Array_Of_BusinessQuery.class, Array_Of_ConstraintAttr.class);
getServiceProxy().intercept(qq_name, sqlQuery, result, queries, orderBy);
}
@Override
public void qq_setDB(@Input DBConnectionManager db) {
String qq_name = MethodMapper.computeName("setDB", DBConnectionManager.class);
getServiceProxy().intercept(qq_name, db);
}
@Override
public void setup(@Input Array_Of_IBusinessMgr<IBusinessMgr> managers) {
String qq_name = MethodMapper.computeName("setup", Array_Of_BusinessMgr.class);
getServiceProxy().intercept(qq_name, managers);
}
@Override
public void SQLdelete(@Input SqlQuery sqlQuery, @Input TextData sqlText, @Input SqlData sqlData) {
String qq_name = MethodMapper.computeName("SQLdelete", SqlQuery.class, TextData.class, SqlData.class);
getServiceProxy().intercept(qq_name, sqlQuery, sqlText, sqlData);
}
@Override
public void SQLinsert(@Input SqlQuery sqlQuery, @Input TextData sqlText, @Input SqlData sqlData) {
String qq_name = MethodMapper.computeName("SQLinsert", SqlQuery.class, TextData.class, SqlData.class);
getServiceProxy().intercept(qq_name, sqlQuery, sqlText, sqlData);
}
@SuppressWarnings("unchecked")
@Override
public Array_Of_BusinessClass<BusinessClass> SQLselect(@Input SqlQuery sqlQuery, @Input TextData sqlText, @Input SqlData sqlData) {
String qq_name = MethodMapper.computeName("SQLselect", SqlQuery.class, TextData.class, SqlData.class);
return (Array_Of_BusinessClass<BusinessClass>)getServiceProxy().intercept(qq_name, sqlQuery, sqlText, sqlData);
}
@Override
public void SQLupdate(@Input SqlQuery sqlQuery, @Input TextData sqlText, @Input SqlData sqlData) {
String qq_name = MethodMapper.computeName("SQLupdate", SqlQuery.class, TextData.class, SqlData.class);
getServiceProxy().intercept(qq_name, sqlQuery, sqlText, sqlData);
}
@Override
public void update(@Input BusinessQuery query) {
String qq_name = MethodMapper.computeName("update", BusinessQuery.class);
getServiceProxy().intercept(qq_name, query);
}
/**
* 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);
}
}