用Spring動態呼叫RMI遠端物件
阿新 • • 發佈:2019-02-07
// 不需要通過BeanFactory直接動態呼叫遠端物件
DistributeCenterBO distributeCenterBO = null;
RmiProxyFactoryBean rmiProxyFactoryBean = new RmiProxyFactoryBean();
rmiProxyFactoryBean.setServiceInterface(DistributeCenterBO.class);
rmiProxyFactoryBean.setServiceUrl(
"rmi://localhost:1199/DistributeCenterBO");
try {
rmiProxyFactoryBean.afterPropertiesSet(); //更改ServiceInterface或ServiceUrl之後必須呼叫該方法,來獲取遠端呼叫樁
} catch (Exception ex) {
}
if (rmiProxyFactoryBean.getObject() instanceof DistributeCenterBO) {
distributeCenterBO = (DistributeCenterBO)
rmiProxyFactoryBean.getObject();
distributeCenterBO.register(SubscriberImpl.subscriberId);
}
DistributeCenterBO distributeCenterBO = null;
RmiProxyFactoryBean rmiProxyFactoryBean = new RmiProxyFactoryBean();
rmiProxyFactoryBean.setServiceInterface(DistributeCenterBO.class);
rmiProxyFactoryBean.setServiceUrl(
"rmi://localhost:1199/DistributeCenterBO");
try {
rmiProxyFactoryBean.afterPropertiesSet(); //更改ServiceInterface或ServiceUrl之後必須呼叫該方法,來獲取遠端呼叫樁
} catch (Exception ex) {
}
if (rmiProxyFactoryBean.getObject() instanceof DistributeCenterBO) {
distributeCenterBO = (DistributeCenterBO)
rmiProxyFactoryBean.getObject();
distributeCenterBO.register(SubscriberImpl.subscriberId);
}