I have an Apache tapestry application which is running under Jetty server. As such port number of the running HTTP server can be obtained during a request from the request object. But I need to find out the port number at which the server is running during program start up (somewhere in AppModule). Is there some way to get this information programmatically? I tried to access @Symbol(SymbolConstants.HOSTPORT) String hostPort in a service but this doesn't work. It simply gives 0. Apparently 0 means that I should be looking up the port number from request.
The reason I need it is because I need to write this information in some database which is accessible to other services such that they are aware of the port / ip address at which this application is running and can call it up.