Commit 9308e6b2 authored by Tigran Mkrtchyan's avatar Tigran Mkrtchyan
Browse files

rpcsvc: added a method to get socketaddress.

parent 0f8ace98
......@@ -260,6 +260,12 @@
<url>http://download.java.net/maven/glassfish/</url>
<layout>default</layout>
</repository>
<repository>
<id>download.java.net</id>
<name>Glassfish Repository for Maven</name>
<url>http://download.java.net/maven/glassfish/ </url>
<layout>default</layout>
</repository>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven</name>
......
......@@ -29,6 +29,7 @@ import com.sun.grizzly.TCPSelectorHandler;
import com.sun.grizzly.UDPSelectorHandler;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
......@@ -268,4 +269,33 @@ public class OncRpcSvc {
public void setThreadCount(int count) {
_controller.setReadThreadsCount(count);
}
/**
* Returns the address of the endpoint this service is bound to,
* or <code>null<code> if it is not bound yet.
* @param protocol
* @return a {@link InetSocketAddress} representing the local endpoint of
* this service, or <code>null</code> if it is not bound yet.
*/
public InetSocketAddress getInetSocketAddress(int protocol) {
TCPSelectorHandler handler;
switch(protocol){
case IpProtocolType.TCP:
handler =
(TCPSelectorHandler) _controller.getSelectorHandler(Controller.Protocol.TCP);
break;
case IpProtocolType.UDP:
handler =
(UDPSelectorHandler) _controller.getSelectorHandler(Controller.Protocol.UDP);
break;
default:
handler = null;
}
if (handler != null) {
return new InetSocketAddress(handler.getInet(), handler.getPort());
}
return null;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment