📄 hostnamefactory.java
字号:
/* * $Id: HostNameFactory.java 11049 2008-02-26 19:49:14Z tcarlson $ * -------------------------------------------------------------------------------------- * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com * * The software in this package is published under the terms of the CPAL v1.0 * license, a copy of which has been included with this distribution in the * LICENSE.txt file. */package org.mule.config.factories;import org.mule.api.config.PropertyFactory;import java.net.InetAddress;import java.util.Map;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;/** * Extracts the local hostname from the local system */public class HostNameFactory implements PropertyFactory{ protected static final Log logger = LogFactory.getLog(HostNameFactory.class); 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 InetAddress.getLocalHost().getHostName(); } catch (Exception e) { logger.warn("Unable to resolve hostname, defaulting to 'localhost': " + e.getMessage(), e); return "localhost"; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -