/** * Parse remote server and port from the string representation server:port and store them in * the RemoteCacheAttributes * * @param server the input string * @param rca the target attribute object */ public static void parseServerAndPort(final String server, final RemoteCacheAttributes rca) { Matcher match = SERVER_COLON_PORT.matcher(server); if (match.find() && match.groupCount() == 2) { rca.setRemoteHost( match.group(1) ); rca.setRemotePort( Integer.parseInt( match.group(2) ) ); } else { log.error("Invalid server descriptor: " + server); } } }
rca.setRemoteHost( server.substring( 0, server.indexOf( ":" ) ) ); rca.setRemotePort( Integer.parseInt( server.substring( server.indexOf( ":" ) + 1 ) ) ); RemoteCacheManager rcm = RemoteCacheManager.getInstance( rca, cacheMgr, cacheEventLogger,
rca.setRemoteHost( "localhost" ); rca.setRemotePort( 1101 );
attributes.setRemoteHost("localhost"); attributes.setLocalPort(1202); attributes.setRemotePort(remotePort);
attributes.setRemoteHost("localhost"); attributes.setLocalPort(1202); attributes.setRemotePort(remotePort);
public void testParseServerAndPort() { RemoteCacheAttributes rca = new RemoteCacheAttributes(); RemoteUtils.parseServerAndPort("server1:1234", rca); assertEquals("server1", rca.getRemoteHost()); assertEquals(1234, rca.getRemotePort()); RemoteUtils.parseServerAndPort(" server2 : 4567 ", rca); assertEquals("server2", rca.getRemoteHost()); assertEquals(4567, rca.getRemotePort()); rca.setRemoteHost(""); rca.setRemotePort(0); // Should not change anything RemoteUtils.parseServerAndPort("server2 : port", rca); assertEquals("", rca.getRemoteHost()); assertEquals(0, rca.getRemotePort()); } }
attributes.setRemoteHost("localhost"); attributes.setLocalPort(1202); attributes.setRemotePort(remotePort);
attributes.setRemoteHost("localhost"); attributes.setLocalPort(1202); attributes.setRemotePort(remotePort);