List of usage examples for org.springframework.remoting.rmi RmiServiceExporter prepare
public void prepare() throws RemoteException
From source file:org.javassonne.networking.impl.RemotingUtils.java
/** * This method takes an object and exposes it as a remove RMI service. The * class that is passed should be the interface that you want the service * exposed as. The name and port will be used to create the url for the * service. e.g. if you provide the name "foo", port 5555, and your ip * address is 123.45.67.89, the following url will access the service: * rmi://123.45.67.89:5555/foo//from ww w. j a v a2s . c o m * * @param svc * - the object that is to be exposed as a remote RMI service * @param svcinterface * - the interface on the object to expose * @param name * - the name of the service for the url * @return - the url of the service (can be passed to others to connect to) * * @throws RemoteException * @throws UnknownHostException */ public static synchronized ServiceInfo exportRMIService(Object svc, Class svcinterface, int port, String name) throws RemoteException, UnknownHostException { RmiServiceExporter exporter = new RmiServiceExporter(); exporter.setRegistryPort(port); exporter.setServiceInterface(svcinterface); exporter.setService(svc); exporter.setServiceName(name); exporter.afterPropertiesSet(); exporter.prepare(); serviceMap_.put(name, exporter); ServiceInfo info = ServiceInfo.create("_rmi._tcp.local.", name, port, "path=index.html"); // return "rmi://"+LOCAL_HOST+":"+port+"/"+name; return info; }
From source file:au.com.jwatmuff.genericp2p.rmi.RMIPeerManager.java
private void refreshService(PeerService service) { RmiServiceExporter exporter = new RmiServiceExporter(); exporter.setRegistryPort(registryPort); exporter.setServiceName(service.name); exporter.setServiceInterface(service.serviceClass); exporter.setService(service.implementation); try {/*from w ww .j a va 2s . c om*/ service.exporter.destroy(); exporter.afterPropertiesSet(); exporter.prepare(); service.exporter = exporter; } catch (RemoteException e) { log.error("Refreshing service " + service.name + " (" + service + ") failed", e); } }
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.//w w w . j a va 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); } } }
From source file:org.grouter.core.RouterServerImpl.java
/** * If there is a rmi port configured then we register the router in jndi. * <p/>/*from w w w.j a va2 s .c om*/ * Lookup up bean in context and use our config files parameters to set * port etc and finally call prepare to fire things up. */ private void initRmi() { logger.info("Check if we are to register as RMI service"); if (router.getRmiRegistryPort() > 0 || router.getRmiServicePort() > 0) { try { logger.info("Trying to register in router as RMI service jndi"); logger.info("Rmiregistryport :" + router.getRmiRegistryPort()); logger.info("Rmiserviceport :" + router.getRmiServicePort()); logger.debug("Get rmi exporter bean from context :" + RMI_SERVICE_EXPORTER_FACTORY_BEAN); RmiServiceExporter rmiServiceExporter = (RmiServiceExporter) context .getBean(RMI_SERVICE_EXPORTER_FACTORY_BEAN); rmiServiceExporter.setRegistryPort(router.getRmiRegistryPort()); rmiServiceExporter.setServicePort(router.getRmiServicePort()); logger.debug("Calling prepare on rmi exporter"); rmiServiceExporter.prepare(); logger.info("Registered ok as RMI service jndi"); } catch (RemoteException e) { logger.error("Failed to register router as RMI service in JNDI", e); } } else { logger.info("Router was no tconfigured to use RMI - rmi ports missing in config file"); } }