List of usage examples for org.springframework.remoting.rmi RmiServiceExporter setRegistry
public void setRegistry(Registry registry)
From source file:au.com.jwatmuff.genericp2p.rmi.RMIPeerManager.java
/** * Associates the given class and service name, so that the service may * be obtained from any Peer objects supplied by this PeerManager. * If an implementation is supplied, remote client may obtain an instance * of the service from the this client.//from w w w.jav a 2 s . co m * * For the service to be obtainable from a given remote peer, that peer must * have also registered the service and supplied an implementation of the * service. * * @param <T> * @param serviceName * @param serviceClass * @param implementation */ @Override public <T> void registerService(String serviceName, Class<T> serviceClass, T implementation) { PeerService<T> service = new PeerService<T>(); service.name = serviceName; service.serviceClass = serviceClass; service.implementation = implementation; if (peerServiceMap.containsKey(serviceName)) { log.warn("Service with name " + serviceName + " has already been registered"); } if (implementation != null) { RmiServiceExporter exporter = new RmiServiceExporter(); //exporter.setRegistryPort(registryPort); exporter.setRegistry(registry); exporter.setServiceName(serviceName); exporter.setServiceInterface(serviceClass); exporter.setService(implementation); try { exporter.afterPropertiesSet(); exporter.prepare(); service.exporter = exporter; peerServiceMap.put(serviceName, service); } catch (RemoteException e) { log.error("Exporting service " + serviceName + " (" + serviceClass + ") failed", e); } } }