Since I'm generating the URIs in my documents as absolute links, I
need some kind of mechanism to find what is the base URI for my
application.
In particular when deploying as a WAR file, the URI is determined by
the name of the WAR file, so blah.war would be deployed as for example:
http://mymachine.com/blah/{whatever}
where {whatever} would be the part of the URI that Restlet would
route on.
in particular my "URIFactory" needs to be called with setRoot("http://
mymachine.com:9999/blah/") so it can generate correct URIs.
Is there a mechanism within Restlet for me to get this URI? I realise
I might not be able to get it until the first request has been sent,
I could do it myself in a filter, although I would still have to make
some kind of educated guess as to where the Tomcat part of the URI
stops and the restlet part starts. (For instance, since everything
below is routed at '/v1/' I could naively just scan for that substring)
I had this problem also when running as a standalone server with
Jetty, but since I then started the server on a particular port I
could set the root to "http://localhost:8976" from the main() method.
--
Stian Soiland, myGrid team
School of Computer Science
The University of Manchester
http://www.cs.man.ac.uk/~ssoiland/