- Timestamp:
- 09/24/19 14:13:24 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/geniusweb/profilesserver/websocket/ProfilesListSocket.java
r1 r5 45 45 private Session session; 46 46 private Listener<ChangeEvent> changeListener; 47 private static transient String hostport = ""; // cache 47 48 48 49 public ProfilesListSocket() { … … 130 131 private String getIpAddressAndPort() 131 132 throws UnknownHostException, MalformedObjectNameException { 133 synchronized (hostport) { 134 if (hostport.isEmpty()) { 135 MBeanServer beanServer = ManagementFactory 136 .getPlatformMBeanServer(); 132 137 133 MBeanServer beanServer = ManagementFactory.getPlatformMBeanServer(); 138 Set<ObjectName> objectNames = beanServer.queryNames( 139 new ObjectName("*:type=Connector,*"), 140 Query.match(Query.attr("protocol"), 141 Query.value("HTTP/1.1"))); 134 142 135 Set<ObjectName> objectNames = beanServer.queryNames(136 new ObjectName("*:type=Connector,*"),137 Query.match(Query.attr("protocol"), Query.value("HTTP/1.1")));143 String host = InetAddress.getLocalHost().getHostAddress(); 144 String port = objectNames.iterator().next() 145 .getKeyProperty("port"); 138 146 139 String host = InetAddress.getLocalHost().getHostAddress();140 String port = objectNames.iterator().next().getKeyProperty("port");141 142 return host + ":" + port;147 hostport = host + ":" + port; 148 } 149 return hostport; 150 } 143 151 144 152 }
Note:
See TracChangeset
for help on using the changeset viewer.