You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@river.apache.org by si...@apache.org on 2012/10/12 16:56:19 UTC

svn commit: r1397599 - /river/jtsk/trunk/src/org/apache/river/config/LocalHostLookup.java

Author: sijskes
Date: Fri Oct 12 14:56:19 2012
New Revision: 1397599

URL: http://svn.apache.org/viewvc?rev=1397599&view=rev
Log:
RIVER-413

Added:
    river/jtsk/trunk/src/org/apache/river/config/LocalHostLookup.java

Added: river/jtsk/trunk/src/org/apache/river/config/LocalHostLookup.java
URL: http://svn.apache.org/viewvc/river/jtsk/trunk/src/org/apache/river/config/LocalHostLookup.java?rev=1397599&view=auto
==============================================================================
--- river/jtsk/trunk/src/org/apache/river/config/LocalHostLookup.java (added)
+++ river/jtsk/trunk/src/org/apache/river/config/LocalHostLookup.java Fri Oct 12 14:56:19 2012
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.river.config;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.logging.Logger;
+
+/**
+ */
+public class LocalHostLookup
+{
+    private final static Logger logger = Logger.getLogger(LocalHostLookup.class.getName());
+
+    private static InetAddress localHost ;
+
+    public static InetAddress getLocalHost() throws UnknownHostException
+    {
+        if( localHost == null ) {
+            setLocalHost( InetAddress.getLocalHost() );
+        }
+        return InetAddress.getLocalHost();
+    }
+
+    private static void setLocalHost(InetAddress localHost)
+    {
+        if( localHost.isLoopbackAddress() ) {
+            logger.warning( "local host is loopback" );
+        }
+        LocalHostLookup.localHost = localHost ;
+    }
+
+    private LocalHostLookup()
+    {
+    }
+}