package com.vci.server.base.utility;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import com.vci.common.ServiceNames;
|
import com.vci.common.log.ServerWithLog4j;
|
import com.vci.common.resource.IceClientProperties;
|
import com.vci.corba.common.VCIError;
|
import com.vci.corba.bofactory.BOFactoryServicePrx;
|
import com.vci.corba.framework.method.FrameworkServicePrx;
|
import com.vci.corba.omd.OMDServicePrx;
|
import com.vci.corba.portal.PortalServicePrx;
|
import com.vci.corba.query.ObjectQueryServicePrx;
|
import com.vci.corba.volume.VolumeServicePrx;
|
import com.vci.corba.workflow.method.WorkflowServicePrx;
|
import com.zeroc.Ice.Communicator;
|
import com.zeroc.Ice.Current;
|
import com.zeroc.Ice.ObjectPrx;
|
|
public final class ServerServiceProvider {
|
|
private static final ThreadLocal<Current> threadLocal = new ThreadLocal<Current>();
|
|
public static void setCurrent(Current current) {
|
threadLocal.set(current);
|
}
|
/**
|
* 获取系统该框架服务代理
|
* @return
|
*/
|
public static FrameworkServicePrx getFrameService(Current current) {
|
try {
|
ObjectPrx prx = getObjectByName(current.adapter.getCommunicator(), ServiceNames.FRAMESERVICE);
|
|
FrameworkServicePrx prxTemp = FrameworkServicePrx.uncheckedCast(prx);
|
return prxTemp.ice_context(current.ctx);
|
} catch (Exception e) {
|
//e.printStackTrace();
|
ServerWithLog4j.logger.error(e);
|
}
|
|
return null;
|
}
|
|
/**
|
* 获取系统该框架服务代理
|
* @return
|
* @throws Exception
|
*/
|
public static FrameworkServicePrx getFrameService() throws VCIError {
|
try {
|
Current current = threadLocal.get();
|
if (current == null)
|
throw new VCIError("ServerServiceProvider-0001", new String[] {"获取当前上下文失败!"});
|
|
ObjectPrx prx = getObjectByName(current.adapter.getCommunicator(), ServiceNames.FRAMESERVICE);
|
|
FrameworkServicePrx prxTemp = FrameworkServicePrx.uncheckedCast(prx);
|
return prxTemp.ice_context(current.ctx);
|
} catch (VCIError e) {
|
//e.printStackTrace();
|
ServerWithLog4j.logger.error(e);
|
throw e;
|
}
|
}
|
|
/**
|
* 获取系统授权认证框架服务代理
|
* @return
|
*/
|
// public static Auth2ServicePrx getAuth2Service(Current current) {
|
// try {
|
// ObjectPrx prx = getObjectByName(current.adapter.getCommunicator(), ServiceNames.AUTH2SERVICE);
|
//
|
// Auth2ServicePrx prxTemp = Auth2ServicePrx.uncheckedCast(prx);
|
// return prxTemp.ice_context(current.ctx);
|
// } catch (Exception e) {
|
// //e.printStackTrace();
|
// ServerWithLog4j.logger.error(e);
|
// }
|
//
|
// return null;
|
// }
|
|
/**
|
* 获取系统授权认证框架服务代理
|
* @return
|
* @throws Exception
|
*/
|
// public static Auth2ServicePrx getAuth2Service() throws VCIError {
|
// try {
|
// Current current = threadLocal.get();
|
// if (current == null)
|
// throw new VCIError("ServerServiceProvider-0002", new String[] {"获取当前上下文失败!"});
|
//
|
// ObjectPrx prx = getObjectByName(current.adapter.getCommunicator(), ServiceNames.AUTH2SERVICE);
|
//
|
// Auth2ServicePrx prxTemp = Auth2ServicePrx.uncheckedCast(prx);
|
// return prxTemp.ice_context(current.ctx);
|
// } catch (Exception e) {
|
// //e.printStackTrace();
|
// ServerWithLog4j.logger.error(e);
|
//
|
// throw e;
|
// }
|
// }
|
|
/**
|
* 获取缓存服务代理
|
* @return
|
*/
|
// public static CacheServicePrx getCacheService(Current current) {
|
// try {
|
// ObjectPrx prx = getObjectByName(current.adapter.getCommunicator(), ServiceNames.CACHESERVICE);
|
//
|
// CacheServicePrx prxTemp = CacheServicePrx.uncheckedCast(prx);
|
// return prxTemp.ice_context(current.ctx);
|
// } catch (Exception e) {
|
// //e.printStackTrace();
|
// ServerWithLog4j.logger.error(e);
|
// }
|
//
|
// return null;
|
// }
|
|
/**
|
* 获取缓存服务代理
|
* @return
|
* @throws Exception
|
*/
|
// public static CacheServicePrx getCacheService() throws VCIError {
|
// try {
|
// Current current = threadLocal.get();
|
// if (current == null)
|
// throw new VCIError("ServerServiceProvider-0003", new String[] {"获取当前上下文失败!"});
|
//
|
// ObjectPrx prx = getObjectByName(current.adapter.getCommunicator(), ServiceNames.CACHESERVICE);
|
//
|
// CacheServicePrx prxTemp = CacheServicePrx.uncheckedCast(prx);
|
// return prxTemp.ice_context(current.ctx);
|
// } catch (Exception e) {
|
// //e.printStackTrace();
|
// ServerWithLog4j.logger.error(e);
|
// throw e;
|
// }
|
// }
|
|
/**
|
* 获取都西昂模型定义服务代理
|
* @return
|
* @throws Exception
|
*/
|
public static OMDServicePrx getOMDService() throws VCIError {
|
try {
|
Current current = threadLocal.get();
|
if (current == null)
|
throw new VCIError("ServerServiceProvider-0004", new String[] {"获取当前上下文失败!"});
|
|
ObjectPrx prx = getObjectByName(current.adapter.getCommunicator(), ServiceNames.OMDSERVICE);
|
|
OMDServicePrx prxTemp = OMDServicePrx.uncheckedCast(prx);
|
return prxTemp.ice_context(current.ctx);
|
} catch (Exception e) {
|
//e.printStackTrace();
|
ServerWithLog4j.logger.error(e);
|
throw e;
|
}
|
}
|
|
/**
|
* 获取都西昂模型定义服务代理
|
* @return
|
*/
|
public static OMDServicePrx getOMDService(Current current) {
|
try {
|
ObjectPrx prx = getObjectByName(current.adapter.getCommunicator(), ServiceNames.OMDSERVICE);
|
|
OMDServicePrx prxTemp = OMDServicePrx.uncheckedCast(prx);
|
return prxTemp.ice_context(current.ctx);
|
} catch (Exception e) {
|
//e.printStackTrace();
|
ServerWithLog4j.logger.error(e);
|
}
|
|
return null;
|
}
|
|
/**
|
* 获取业务对象工厂服务代理
|
* @return
|
*/
|
public static BOFactoryServicePrx getBOFService(Current current) {
|
try {
|
ObjectPrx prx = getObjectByName(current.adapter.getCommunicator(), ServiceNames.BOFSERVICE);
|
|
BOFactoryServicePrx prxTemp = BOFactoryServicePrx.uncheckedCast(prx);
|
return prxTemp.ice_context(current.ctx);
|
} catch (Exception e) {
|
//e.printStackTrace();
|
ServerWithLog4j.logger.error(e);
|
}
|
|
return null;
|
}
|
|
public static BOFactoryServicePrx getBOFService() throws VCIError {
|
try {
|
Current current = threadLocal.get();
|
if (current == null)
|
throw new VCIError("ServerServiceProvider-0005", new String[] {"获取当前上下文失败!"});
|
|
ObjectPrx prx = getObjectByName(current.adapter.getCommunicator(), ServiceNames.BOFSERVICE);
|
|
BOFactoryServicePrx prxTemp = BOFactoryServicePrx.uncheckedCast(prx);
|
return prxTemp.ice_context(current.ctx);
|
} catch (Exception e) {
|
//e.printStackTrace();
|
ServerWithLog4j.logger.error(e);
|
throw e;
|
}
|
}
|
|
/**
|
* 获取查询模板定义服务代理
|
* @return
|
*/
|
// public static QTDServicePrx getQTDService(Current current) {
|
// try {
|
// ObjectPrx prx = getObjectByName(current.adapter.getCommunicator(), ServiceNames.QTDSERVICE);
|
//
|
// QTDServicePrx prxTemp = QTDServicePrx.uncheckedCast(prx);
|
// return prxTemp.ice_context(current.ctx);
|
// } catch (Exception e) {
|
// //e.printStackTrace();
|
// ServerWithLog4j.logger.error(e);
|
// }
|
//
|
// return null;
|
// }
|
|
// public static QTDServicePrx getQTDService() throws VCIError {
|
// try {
|
// Current current = threadLocal.get();
|
// if (current == null)
|
// throw new VCIError("ServerServiceProvider-0006", new String[] {"获取当前上下文失败!"});
|
//
|
// ObjectPrx prx = getObjectByName(current.adapter.getCommunicator(), ServiceNames.QTDSERVICE);
|
//
|
// QTDServicePrx prxTemp = QTDServicePrx.uncheckedCast(prx);
|
// return prxTemp.ice_context(current.ctx);
|
// } catch (Exception e) {
|
// //e.printStackTrace();
|
// ServerWithLog4j.logger.error(e);
|
// throw e;
|
// }
|
// }
|
|
/**
|
* 获取对象查询服务代理
|
* @return
|
*/
|
public static ObjectQueryServicePrx getOQService(Current current) {
|
try {
|
ObjectPrx prx = getObjectByName(current.adapter.getCommunicator(), ServiceNames.OQSERVICE);
|
|
ObjectQueryServicePrx prxTemp = ObjectQueryServicePrx.uncheckedCast(prx);
|
return prxTemp.ice_context(current.ctx);
|
} catch (Exception e) {
|
//e.printStackTrace();
|
ServerWithLog4j.logger.error(e);
|
}
|
|
return null;
|
}
|
|
public static ObjectQueryServicePrx getOQService() throws VCIError {
|
try {
|
Current current = threadLocal.get();
|
if (current == null)
|
throw new VCIError("ServerServiceProvider-0007", new String[] {"获取当前上下文失败!"});
|
|
ObjectPrx prx = getObjectByName(current.adapter.getCommunicator(), ServiceNames.OQSERVICE);
|
|
ObjectQueryServicePrx prxTemp = ObjectQueryServicePrx.uncheckedCast(prx);
|
return prxTemp.ice_context(current.ctx);
|
} catch (Exception e) {
|
//e.printStackTrace();
|
ServerWithLog4j.logger.error(e);
|
throw e;
|
}
|
}
|
|
/**
|
* 获取参考对象查询服务代理
|
* @return
|
*/
|
// public static RefQueryServicePrx getRQService(Current current) {
|
// try {
|
// ObjectPrx prx = getObjectByName(current.adapter.getCommunicator(), ServiceNames.RQSERVICE);
|
//
|
// RefQueryServicePrx prxTemp = RefQueryServicePrx.uncheckedCast(prx);
|
// return prxTemp.ice_context(current.ctx);
|
// } catch (Exception e) {
|
// //e.printStackTrace();
|
// ServerWithLog4j.logger.error(e);
|
// }
|
//
|
// return null;
|
// }
|
//
|
// public static RefQueryServicePrx getRQService() throws VCIError {
|
// try {
|
// Current current = threadLocal.get();
|
// if (current == null)
|
// throw new VCIError("ServerServiceProvider-0008", new String[] {"获取当前上下文失败!"});
|
//
|
// ObjectPrx prx = getObjectByName(current.adapter.getCommunicator(), ServiceNames.RQSERVICE);
|
//
|
// RefQueryServicePrx prxTemp = RefQueryServicePrx.uncheckedCast(prx);
|
// return prxTemp.ice_context(current.ctx);
|
// } catch (Exception e) {
|
// //e.printStackTrace();
|
// ServerWithLog4j.logger.error(e);
|
// throw e;
|
// }
|
// }
|
|
/**
|
* 获取UI服务服务代理
|
* @return
|
*/
|
public static PortalServicePrx getUIService(Current current) {
|
try {
|
ObjectPrx prx = getObjectByName(current.adapter.getCommunicator(), ServiceNames.UISERVICE);
|
|
PortalServicePrx prxTemp = PortalServicePrx.uncheckedCast(prx);
|
return prxTemp.ice_context(current.ctx);
|
} catch (Exception e) {
|
//e.printStackTrace();
|
ServerWithLog4j.logger.error(e);
|
}
|
|
return null;
|
}
|
|
public static PortalServicePrx getUIService() throws VCIError {
|
try {
|
Current current = threadLocal.get();
|
if (current == null)
|
throw new VCIError("ServerServiceProvider-0009", new String[] {"获取当前上下文失败!"});
|
|
ObjectPrx prx = getObjectByName(current.adapter.getCommunicator(), ServiceNames.UISERVICE);
|
|
PortalServicePrx prxTemp = PortalServicePrx.uncheckedCast(prx);
|
return prxTemp.ice_context(current.ctx);
|
} catch (VCIError e) {
|
//e.printStackTrace();
|
ServerWithLog4j.logger.error(e);
|
throw e;
|
}
|
}
|
|
/**
|
* 获取工作流服务代理
|
* @return
|
*/
|
public static WorkflowServicePrx getWFService(Current current) {
|
try {
|
ObjectPrx prx = getObjectByName(current.adapter.getCommunicator(), ServiceNames.WFSERVICE);
|
|
WorkflowServicePrx prxTemp = WorkflowServicePrx.uncheckedCast(prx);
|
return prxTemp.ice_context(current.ctx);
|
} catch (Exception e) {
|
//e.printStackTrace();
|
ServerWithLog4j.logger.error(e);
|
}
|
|
return null;
|
}
|
|
public static WorkflowServicePrx getWFService() throws VCIError {
|
try {
|
Current current = threadLocal.get();
|
if (current == null)
|
throw new VCIError("ServerServiceProvider-0010", new String[] {"获取当前上下文失败!"});
|
|
ObjectPrx prx = getObjectByName(current.adapter.getCommunicator(), ServiceNames.WFSERVICE);
|
|
WorkflowServicePrx prxTemp = WorkflowServicePrx.uncheckedCast(prx);
|
return prxTemp.ice_context(current.ctx);
|
} catch (VCIError e) {
|
//e.printStackTrace();
|
ServerWithLog4j.logger.error(e);
|
throw e;
|
}
|
}
|
|
/**
|
* 获取卷服务服务代理
|
* @return
|
*/
|
// public static VolumeManagerPrx getVolumeManager(Current current) {
|
// try {
|
// ObjectPrx prx = getObjectByName(current.adapter.getCommunicator(), ServiceNames.VOLUMEMANAGER);
|
//
|
// VolumeManagerPrx prxTemp = VolumeManagerPrx.uncheckedCast(prx);
|
// return prxTemp.ice_context(current.ctx);
|
// } catch (Exception e) {
|
// //e.printStackTrace();
|
// ServerWithLog4j.logger.error(e);
|
// }
|
//
|
// return null;
|
// }
|
//
|
// public static VolumeManagerPrx getVolumeManager() throws VCIError {
|
// try {
|
// Current current = threadLocal.get();
|
// if (current == null)
|
// throw new VCIError("ServerServiceProvider-0011", new String[] {"获取当前上下文失败!"});
|
//
|
// ObjectPrx prx = getObjectByName(current.adapter.getCommunicator(), ServiceNames.VOLUMEMANAGER);
|
//
|
// VolumeManagerPrx prxTemp = VolumeManagerPrx.uncheckedCast(prx);
|
// return prxTemp.ice_context(current.ctx);
|
// } catch (VCIError e) {
|
// //e.printStackTrace();
|
// ServerWithLog4j.logger.error(e);
|
// throw e;
|
// }
|
// }
|
|
/**
|
* 获取系统该框架服务代理
|
* @return
|
*/
|
public static VolumeServicePrx getVolumeService(Current current, String volService) {
|
try {
|
if (StringUtils.isBlank(volService))
|
volService = ServiceNames.VOLUMESERVICE;
|
|
ObjectPrx prx = getObjectByName(current.adapter.getCommunicator(), volService);
|
|
VolumeServicePrx prxTemp = VolumeServicePrx.uncheckedCast(prx);
|
return prxTemp.ice_context(current.ctx);
|
} catch (Exception e) {
|
//e.printStackTrace();
|
ServerWithLog4j.logger.error(e);
|
throw e;
|
}
|
}
|
|
|
|
/**
|
* 获取服务对象代理
|
* @param name
|
* @return
|
* @throws Exception
|
*/
|
private static ObjectPrx getObjectByName(Communicator communicator, String name)
|
{
|
String proxyLocator = name + ":" + IceClientProperties.Endpoints();
|
|
return communicator.stringToProxy(proxyLocator);
|
}
|
|
}
|