public String getIp() throws UnknownHostException { return NetworkUtils.getLocalHost().getHostAddress(); }
/** * Creates the server address object with the IP and port that this config should bind to. */ private ServerAddress createServerAddress() throws UnknownHostException { return new ServerAddress(NetworkUtils.getLocalHostIp(host), port); }
public static boolean isServerReachable(URL url, int timeout) { int port = url.getPort() != -1 ? url.getPort() : url.getDefaultPort(); return isServerReachable(url.getHost(), port, timeout); }
public String getHost() throws UnknownHostException { return NetworkUtils.getLocalHost().getCanonicalHostName(); }
public Object create(Map<?, ?> props) throws Exception { // we could use getCanonicalHostName here. however, on machines behind // NAT firewalls it seems that is often the NAT address, which corresponds // to an interface on the firewall, not on the local machine. try { return NetworkUtils.getLocalHost().getHostName(); } catch (Exception e) { logger.warn("Unable to resolve hostname, defaulting to 'localhost': " + e.getMessage(), e); return "localhost"; } }
public MuleService(MuleContext muleContext) { this.muleContext = muleContext; String patch = System.getProperty("sun.os.patch.level", null); jdk = System.getProperty("java.version") + " (" + System.getProperty("java.vm.info") + ")"; os = System.getProperty("os.name"); if (patch != null && !"unknown".equalsIgnoreCase(patch)) { os += " - " + patch; } os += " (" + System.getProperty("os.version") + ", " + System.getProperty("os.arch") + ")"; buildNumber = MuleManifest.getBuildNumber(); buildDate = MuleManifest.getBuildDate(); try { InetAddress iad = NetworkUtils.getLocalHost(); host = iad.getCanonicalHostName(); ip = iad.getHostAddress(); } catch (UnknownHostException e) { // ignore } }
public ServerSocket createServerSocket(URI uri, int backlog, Boolean reuse) throws IOException { String host = StringUtils.defaultIfEmpty(uri.getHost(), "localhost"); InetAddress inetAddress = InetAddress.getByName(host); if ((inetAddress.equals(NetworkUtils.getLocalHost()) || host.trim().equals("localhost")) && TcpPropertyHelper.isBindingLocalhostToAllLocalInterfaces()) { logger.warn(TcpMessages.localhostBoundToAllLocalInterfaces()); return createServerSocket(uri.getPort(), backlog, reuse); } else { return createServerSocket(inetAddress, uri.getPort(), backlog, reuse); } }
wsdlContents = wsdlContents.replaceAll(LOCALHOST_LOCALDOMAIN, NetworkUtils.getLocalHost().getHostName()); wsdlContents = wsdlContents.replaceAll(LOCALHOST, NetworkUtils.getLocalHost().getHostName());
public DefaultMuleConfiguration(boolean containerMode) { this.containerMode = containerMode; // Apply any settings which come from the JVM system properties. applySystemProperties(); if (id == null) { id = UUID.getUUID(); } if (domainId == null) { try { domainId = NetworkUtils.getLocalHost().getHostName(); } catch (UnknownHostException e) { logger.warn(e); domainId = "org.mule"; } } try { validateEncoding(); } catch (FatalException e) { throw new RuntimeException(e); } }
@java.lang.Override public void destroyObject(Object key, Object object) throws Exception { ImmutableEndpoint ep = (ImmutableEndpoint)key; InetAddress inetAddress; String host = ep.getEndpointURI().getHost(); if("null".equalsIgnoreCase(host)) { inetAddress = NetworkUtils.getLocalHost(); } else { inetAddress = InetAddress.getByName(host); } MulticastSocket socket = (MulticastSocket)object; socket.leaveGroup(inetAddress); super.destroyObject(key, object); }
return NetworkUtils.getLocalHost().getHostName(); return NetworkUtils.getLocalHost().getHostAddress();
InetAddress address = NetworkUtils.getLocalHost(); final String xaNodeId = MessageFormat.format("Mule[{0}/{1}]", address.getHostName(), address.getHostAddress());
try InetAddress host = NetworkUtils.getLocalHost(); header.add("Host: " + host.getHostName() + " (" + host.getHostAddress() + ")");
if (wsdlString.indexOf("localhost") > -1) wsdlString = wsdlString.replaceAll("localhost", NetworkUtils.getLocalHost().getHostName());
@Override protected synchronized void doDispatch(MuleEvent event) throws Exception { DatagramSocket socket = connector.getSocket(endpoint); try { byte[] payload = event.transformMessage(DataType.BYTE_ARRAY_DATA_TYPE); int port = endpoint.getEndpointURI().getPort(); InetAddress inetAddress = null; //TODO, check how expensive this operation is if("null".equalsIgnoreCase(endpoint.getEndpointURI().getHost())) { inetAddress = NetworkUtils.getLocalHost(); } else { inetAddress = InetAddress.getByName(endpoint.getEndpointURI().getHost()); } write(socket, payload, port, inetAddress); } finally { connector.releaseSocket(socket, endpoint); } }
try InetAddress host = NetworkUtils.getLocalHost(); doBody(String.format("Host: %s (%s)", host.getHostName(), host.getHostAddress()));