Here you can find the source of getDestination(InetSocketAddress server)
public static InetSocketAddress getDestination(InetSocketAddress server)
//package com.java2s; /******************************************************************************* * Copyright (c) 2016 Bosch Software Innovations GmbH and others. * //from w w w .ja va2s . c o m * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. * * The Eclipse Public License is available at * http://www.eclipse.org/legal/epl-v10.html * and the Eclipse Distribution License is available at * http://www.eclipse.org/org/documents/edl-v10.html. * * Contributors: * Achim Kraus (Bosch Software Innovations GmbH) - initial implementation * stuff copied from TcpConnectorTest * Achim Kraus (Bosch Software Innovations GmbH) - adjust creation of oubound message * with null correlation context. * Achim Kraus (Bosch Software Innovations GmbH) - add sending correlation context. * Achim Kraus (Bosch Software Innovations GmbH) - replace "any/0.0.0.0" with * "localhost/127.0.0.1" in destination. * Achim Kraus (Bosch Software Innovations GmbH) - add create server address * using LoopbackAddress. ******************************************************************************/ import java.net.InetAddress; import java.net.InetSocketAddress; public class Main { public static InetSocketAddress getDestination(InetSocketAddress server) { if (server.getAddress().isAnyLocalAddress()) { // for destination replace any by localhost server = new InetSocketAddress(InetAddress.getLoopbackAddress(), server.getPort()); } return server; } }