1 22 package org.jboss.system.server; 23 24 import java.net.InetAddress ; 25 import java.net.UnknownHostException ; 26 27 33 public class ServerConfigUtil 34 { 35 private static final String ANY = "0.0.0.0"; 36 37 42 public static String getDefaultBindAddress() 43 { 44 return System.getProperty(ServerConfig.SERVER_BIND_ADDRESS); 45 } 46 47 52 public static String getSpecificBindAddress() 53 { 54 String address = System.getProperty(ServerConfig.SERVER_BIND_ADDRESS); 55 if (address == null || address.equals(ANY)) 56 return null; 57 return address; 58 } 59 60 68 public static InetAddress fixRemoteAddress(InetAddress address) 69 { 70 try 71 { 72 if (address == null || InetAddress.getByName(ANY).equals(address)) 73 return InetAddress.getLocalHost(); 74 } 75 catch (UnknownHostException ignored) 76 { 77 } 78 return address; 79 } 80 81 89 public static String fixRemoteAddress(String address) 90 { 91 try 92 { 93 if (address == null || ANY.equals(address)) 94 return InetAddress.getLocalHost().getHostName(); 95 } 96 catch (UnknownHostException ignored) 97 { 98 } 99 return address; 100 } 101 102 107 public static String getDefaultPartitionName() 108 { 109 return System.getProperty(ServerConfig.PARTITION_NAME_PROPERTY, ServerConfig.DEFAULT_PARITION_NAME); 110 } 111 112 117 public static boolean isLoadNative() 118 { 119 return Boolean.getBoolean(ServerConfig.NATIVE_LOAD_PROPERTY); 120 } 121 122 128 public static String shortUrlFromServerHome(String longUrl) 129 { 130 String serverHomeUrl = System.getProperty(org.jboss.system.server.ServerConfig.SERVER_HOME_URL); 131 132 if (longUrl == null || serverHomeUrl == null) 133 return longUrl; 134 135 if (longUrl.startsWith(serverHomeUrl)) 136 return ".../" + longUrl.substring(serverHomeUrl.length()); 137 else 138 { 139 String jarServerHomeUrl = "jar:" + serverHomeUrl; 140 if (longUrl.startsWith(jarServerHomeUrl)) 141 return ".../" + longUrl.substring(jarServerHomeUrl.length()); 142 else 143 return longUrl; 144 } 145 } 146 } 147 | Popular Tags |