Sun app server ports

Hi-

How can we get the list of server(sun app server) ports programatically? in JRun we have some thing like this -

JRunAdminService jrunAdmin = new JRunAdminService();

int[] myPorts = jrunAdmin.listServerPortsUsed(JRun.getServerName());

Any help would be greately appriciated.

Thanks,

Anand

[334 byte] By [anandms5] at [2007-11-26 8:19:22]
# 1

I don't think Sun Application Servers have this API. But it is interesting thought.

Actually, just returning the port numbers as a collection of nonzero positive

integers is not enough, I think. The ports have sockets listening for connections

for a particular protocol.

In other words, I want to know how you'll use this data.

Thanks,

Kedar

kedarmhaswade at 2007-7-6 21:22:51 > top of Java-index,Application & Integration Servers,Application Servers...
# 2

hi-

thanks for ur response.

I need this info b/c I need to start certain jobs depending in port AND ip address, here is the code snippet for jrun

JRunAdminService jrunAdmin = new JRunAdminService();

int[] myPorts = jrunAdmin.listServerPortsUsed(JRun.getServerName());

Map inMap = new HashMap();

Map outMap = new HashMap();

// Retrieve the designated server from the database

outMap = // here db call to get the designated server info

InetAddress localNetIP= InetAddress.getLocalHost();

String localIP = null;

int portToRun = 0;

// Loop through ports and get IP addresses, cross ref with designated server

for (int i=0; i<myPorts.length; i++) {

localIP = (String)localNetIP.getHostAddress();

System.out.println("- ...JRun port: " +myPorts+ ", Local IP: " +localIP);

if (outMap != null) {

String ip_address = ((String)outMap.get("ip_address")).trim();

String port = ((String)outMap.get("port")).trim();

if ((localIP.equals(ip_address)) && (myPorts == Integer.parseInt(port))) {

toRunScheduler = true;

portToRun = myPorts;

System.out.println("- ...loading scheduler for JRun port: "+portToRun + ", Local IP: " +localIP);>

anandms5 at 2007-7-6 21:22:51 > top of Java-index,Application & Integration Servers,Application Servers...