| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.common.mw.channel.rmi; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.rmi.Naming; | 
|---|
|  |  |  | import org.apache.logging.log4j.* ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public class RmiClient { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static final Logger log = LogManager.getLogger(RmiClient.class.getName()) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private String rmiServerIp; | 
|---|
|  |  |  | private Integer rmiServerPort; | 
|---|
|  |  |  | private String rmiServerContext ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public RmiClient(String rmiServerIp, Integer rmiServerPort, String rmiServerContext){ | 
|---|
|  |  |  | this.rmiServerIp = rmiServerIp ; | 
|---|
|  |  |  | this.rmiServerPort = rmiServerPort ; | 
|---|
|  |  |  | this.rmiServerContext = rmiServerContext ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 得到中间件RMI | 
|---|
|  |  |  | * @return RmiFrameWork | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public RmiFrameWork getRmiInterface() { | 
|---|
|  |  |  | String rmiServerUrl = "rmi://" + this.rmiServerIp + ":" + this.rmiServerPort + "/" + this.rmiServerContext ; | 
|---|
|  |  |  | RmiFrameWork rmiIntf = null; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | rmiIntf = (RmiFrameWork) Naming.lookup(rmiServerUrl); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("连接RMI服务:" + rmiServerUrl + "时出错。", e); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return rmiIntf; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|