Search code examples
javarestwebsphere

Externalise REST endpoint in Websphere Application Server


I have to consume a REST endpoint from the Utility class written in Java. Utility class is deployed in application server as part of my EAR. The REST resource end point will vary depends on environment like (DEV, TEST, PRE-PROD and PROD). So, I want to externalize the end point and should be able to change it without code change.


Solution

  • The normal way to do this is to configure a URL in JNDI, and do a JNDI lookup for the URL and configure the resource in each environment as it needs to be.

    In the Websphere console under Resources there is a place for "URL" which would seem to be place you would want to put this and then do the lookup in code (or wire in the lookup via Spring or your personal preference).