1.spring访问corba
Properties prop = new Properties();
prop.put("org.omg.CORBA.ORBClass", "org.jacorb.orb.ORB");
prop.put("org.omg.CORBA.ORBSingletonClass", "org.jacorb.orb.ORBSingleton");
//服务器端指定端口区间处理工厂
prop.put("jacorb.net.server_socket_factory", "org.jacorb.orb.factory.PortRangeServerSocketFactory");
//服务器端指定的端口
prop.put("jacorb.net.server_socket_factory.port.min", "30000");
prop.put("jacorb.net.server_socket_factory.port.max", "30001");
// 客户端重复连接次数
prop.put("jacorb.retries", "2");
//连接服务器端不成功后指定时间断开连接
prop.put("jacorb.connection.client.idle_timeout", "5001");
//服务发布命名地址
prop.put("ORBInitRef.NameService", "corbaloc::vci-dyp-PC:30000/NameService");
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB .init(new String[]{null}, prop);
try {
org.omg.CosNaming.NamingContextExt nc = org.omg.CosNaming.NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService"));
WorkflowService workflowService = WorkflowServiceHelper.narrow(nc.resolve(nc.to_name("workflowService")));
} catch (Exception e) {
e.printStackTrace();
}
注:如果是需要在tomcat启动时就加载可将上述代码写到一个lister类,同时有一个工具类来管理service对象
2.corba访问spring
注:背景:bs端通过service访问corba服务调用流程引擎,这时流程引擎在执行完成操作时执行流程事件(流程事件核心代码在bs端),也就是corba端要反过来调用spring窗口内的service对象,这时操作如下:
spring配置文件添加代码:
<bean id="serviceExporter" class="org.springframework.remoting.rmi.RmiServiceExporter">
<property name="serviceName" value="vciWorkFlowService"/>
<property name="service" ref="vCIWorkFlowServiceImpl"/>
<property name="serviceInterface" value="com.vci.plm.portal.service.IVCIWorkFlowService"/>
<property name="registryPort" value="9000"/>
<property name="servicePort" value="9001"/>
</bean>
事件类里调用service代码如下:
RmiProxyFactoryBean proxy = new RmiProxyFactoryBean();
proxy.setServiceInterface(IVCIWorkFlowService.class);
proxy.setServiceUrl("rmi://192.168.0.22:9000/vCIWorFlowService");//tomcate发布所在机器ip,及上述配置的serviceName
proxy.afterPropertiesSet();//如果 不加该语句,会抛java.lang.NullPointException
IVCIWorkFlowService vciWorkflowSerivce = (IVCIWorkFlowService) proxy.getObject();