users@glassfish.java.net

Re: Determining iiop/orb port from within deployed application?

From: Jacques <whshub_at_gmail.com>
Date: Wed, 15 Jun 2011 18:45:26 -0700

For anyone who wants to know for future reference:

By default (at least for ssh nodes/instances), the iiop and http ports (and
others) are set using system properties. This happens only when they are
non-default as far as I can tell.

So the code is basically:

  /** Get a system property that is a port number or retrun the default if
it doesn't exist **/
  public static int getPort(String propertyName, int defaultPort){
    String portString = System.getProperty(propertyName);
    if(portString == null) return defaultPort;
    try{
      return Integer.parseInt(portString);
    }catch(NumberFormatException ex){
      return -1;
    }
  }


int iiop = getPort("IIOP_LISTENER_PORT", 3700);
int http = getPort("HTTP_LISTENER_PORT", 8080);


On Sat, May 7, 2011 at 1:57 PM, Jacques <whshub_at_gmail.com> wrote:

> What is the best to determine the iiop port within the current application?
>
>
> The following command provides the information I need:
> >asadmin get server-config.iiop-service.iiop-listener.orb-listener-1.port
>
> What is the best way to get this value from within a deployed application?
>
>
> Thanks for any pointers.
>
> Jacques
>