One: Service-side development:<bean id= "Webimagesserviceimpl"class= "Com.yknet.llgo.service.rmi.impl.WebImagesServiceImpl" ></bean> <!--image Management Service interface--<bean I D= "Webimagesserviceexporter"class= "Org.springframework.remoting.rmi.RmiServiceExporter" > <!--Implementation Class--<property Name= " Service "ref=" Webimagesserviceimpl "/> <!--define the name of the services, call the client--<property name=" Servicen Ame "value=" Webimagesservice "/> <!--server interface and <property name=" Serviceinterface "value = "Com.yknet.llgo.service.rmi.IWebImagesService"/> <!--port number of the server, this is also for the client to call---<propert Y name= "Registryport" value= "8088"></property> <property name=" Serviceport "value="2098"/><!--not specified on the random--</bean> <bean id=" Smrmisocket "class= "Com.yknet.llgo.core.SMRMISocket" ></bean>
Resolving connection timeouts When external network access is resolved
PackageCom.yknet.llgo.core;Importjava.io.IOException;ImportJava.net.ServerSocket;ImportJava.net.Socket;Importjava.rmi.server.RMISocketFactory; Public classSmrmisocketextendsRmisocketfactory { PublicSocket Createsocket (String host,intPort)throwsioexception{return NewSocket (Host,port); } PublicServerSocket Createserversocket (intPort)throwsIOException {if(Port = = 0) Port=2098;//random if not specified return NewServerSocket (port); } }
Second: Customer service configuration:
class= "Org.springframework.remoting.rmi.RmiProxyFactoryBean" > <!--port number must be exactly the same as the server configuration 8088/ Imagesserviceweb: Is the server-side configuration ServiceName-- <property name= "serviceurl" value= "rmi://121.42.138.7:8088/ Webimagesservice "></property> <!--server interface-- <property name=" Serviceinterface "value=" Com.yknet.llgo.service.rmi.IWebImagesService "/> </bean>
Java RMI Development