/** * Get the naming url used for RMI registration * * @param location * the remote location * @param serviceName * the remote service name * @return the URL for RMI lookup */ public static String getNamingURL(final RemoteLocation location, final String serviceName) { return getNamingURL(location.getHost(), location.getPort(), serviceName); }
/** * Sets the location attribute of the RemoteCacheAttributes object. * <p> * @param host The new remoteHost value * @param port The new remotePort value */ @Override public void setRemoteLocation( String host, int port ) { this.location = new RemoteLocation(host, port); }
/** * For easier debugging. * <p> * @return Basic info on this listener. */ @Override public String toString() { StringBuilder buf = new StringBuilder(); buf.append( "\n AbstractRemoteCacheListener: " ); buf.append( "\n RemoteHost = " + irca.getRemoteLocation().toString() ); buf.append( "\n ListenerId = " + listenerId ); return buf.toString(); } }
public void testParseServerAndPort() { RemoteLocation loc = RemoteLocation.parseServerAndPort("server1:1234"); assertEquals("server1", loc.getHost()); assertEquals(1234, loc.getPort()); loc = RemoteLocation.parseServerAndPort(" server2 : 4567 "); assertEquals("server2", loc.getHost()); assertEquals(4567, loc.getPort()); loc = RemoteLocation.parseServerAndPort("server2 : port"); assertNull(loc); } }
RemoteLocation location = RemoteLocation.parseServerAndPort(server); RemoteLocation location = RemoteLocation.parseServerAndPort(server);
factory = new RemoteCacheFactory(); factory.initialize(); remotePort = server.remoteCacheServerAttributes.getRemoteLocation().getPort();
/** * @return String, all the important values that can be configured */ @Override public String toString() { StringBuilder buf = new StringBuilder(); buf.append( "\n RemoteCacheAttributes " ); if (this.location != null) { buf.append( "\n remoteHost = [" + this.location.getHost() + "]" ); buf.append( "\n remotePort = [" + this.location.getPort() + "]" ); } buf.append( "\n cacheName = [" + getCacheName() + "]" ); buf.append( "\n remoteType = [" + remoteType + "]" ); buf.append( "\n removeUponRemotePut = [" + this.removeUponRemotePut + "]" ); buf.append( "\n getOnly = [" + getOnly + "]" ); return buf.toString(); } }
/** * Parse remote server and port from the string representation server:port and store them in * a RemoteLocation object * * @param server the input string * @return the remote location object */ public static RemoteLocation parseServerAndPort(final String server) { Matcher match = SERVER_COLON_PORT.matcher(server); if (match.find() && match.groupCount() == 2) { RemoteLocation location = new RemoteLocation( match.group(1), Integer.parseInt( match.group(2) ) ); return location; } else { log.error("Invalid server descriptor: " + server); } return null; } }
/** * IP address for the service, if one is stored. * <p> * Protected for testing. * <p> * @return String */ protected String getIPAddressForService() { String ipAddress = "(null)"; if (this.getRemoteCacheAttributes().getRemoteLocation() != null) { ipAddress = this.getRemoteCacheAttributes().getRemoteLocation().toString(); } return ipAddress; } }