📄 serviceproxycenter.java
字号:
package net.s3o.core.service;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.HashMap;
import org.springframework.beans.factory.InitializingBean;
import com.caucho.hessian.client.HessianProxyFactory;
public class ServiceProxyCenter implements InitializingBean {
public static HessianProxyFactory serviceProxyFactory = new HessianProxyFactory();
private HashMap serviceProxys=null;
private ArrayList serviceProxysList=null;
public void afterPropertiesSet() throws Exception {
if (serviceProxys==null) {
serviceProxys=new HashMap();
}
}
public Object callRemoteServiceByName(String proxyName,Object arguments) throws MalformedURLException{
Object result=null;
IBaseService clientService=getSerivecProxy(proxyName);
if (clientService==null) { return null; }
result=clientService.doService(arguments);
return result;
}
public static Object callRemoteServiceByURL(String serviceURL,Object arguments) throws MalformedURLException{
Object result=null;
IBaseService clientService=createSerivecProxy(serviceURL);
if (clientService==null) { return null; }
result=clientService.doService(arguments);
return result;
}
protected IBaseService getSerivecProxy(String proxyName){
if (serviceProxys==null) return null;
return (IBaseService)serviceProxys.get(proxyName);
}
public static IBaseService createSerivecProxy(String serviceURL){
try {
return (IBaseService)serviceProxyFactory.create(IBaseService.class, serviceURL);
} catch (MalformedURLException e) {
return null;
}
}
public HashMap getServiceProxys() {
return serviceProxys;
}
public void setServiceProxys(HashMap serviceProxys) {
this.serviceProxys = serviceProxys;
}
public ArrayList getServiceProxysList() {
return serviceProxysList;
}
public void setServiceProxysList(ArrayList serviceProxysList) {
this.serviceProxysList = serviceProxysList;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -