Bug 525498 - Need more flexible ways of setting the server's base URI
Summary: Need more flexible ways of setting the server's base URI
Status: NEW
Alias: None
Product: Lyo
Classification: Technology
Component: Tools (show other bugs)
Version: 2.2.0   Edit
Hardware: All Mac OS X
: P3 normal (vote)
Target Milestone: 2.x.x   Edit
Assignee: Jad El-khoury CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 519678
Blocks:
  Show dependency tree
 
Reported: 2017-10-03 08:27 EDT by Jim Amsden CLA
Modified: 2017-11-06 12:14 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jim Amsden CLA 2017-10-03 08:27:07 EDT
The generated server base URI is currently specified using a context-param in the web.xml deployment descriptor file. For example:


	<context-param>
		<description>Base URI for the adaptor.</description>
		<param-name>com.ibm.oslc.adaptor.iotp.servlet.baseurl</param-name>
		<param-value>https://rlia4iot.raleigh.ibm.com:9443</param-value>
	</context-param>

The Lyo Designer generated ServletListener class use the ServletContext getInitParameter() method to read this property, and if it is not specified, uses http://localhost:8080 as the default.

This works fine, but in practice results in the need to edit the deployment descriptor file in order to deploy the generated OSLC toolchain component on different servers. 

Perhaps an additional option would be to provide the baseuri as a System property that can be set from the command line that could be used in addition to the context-param in web.xml and the default. The System property should have the highest priority (used first), followed by the context-param, followed by the default.
Comment 1 Jad El-khoury CLA 2017-10-03 16:12:51 EDT
1.
Jim! If you can provide me with the desired code for the contextInitialized() method, I can match it in the generator.


2. I suggest we also change DEFAULT_BASE to be non-final.
At the start of the contextInitialized() method, I can have a //TODO comment to inform programmer that they can override this value of DEFAULT_BASE.

3.
This would also be an opportunity to deal with the https://bugs.eclipse.org/bugs/show_bug.cgi?id=519474 (Rename default servlet name from "JAX-RS Servlet" to "oslc-servlet")
Comment 2 Andrii Berezovskyi CLA 2017-11-06 11:54:43 EST
From my email reply:

I use context.xml in Tomcat to override the value in the descriptor. No web.xml changes inside the WAR file are needed. Every AS allows that.

Quick search turns this https://www.ibm.com/support/knowledgecenter/en/SSAW57_8.5.5/com.ibm.websphere.nd.doc/ae/rweb_custom_props.html

So I see no reason to go back to Java system props, I prefer to use the Java EE container configuration facilities.