There are often situations where an application on WAS needs to be configured differently in production and test environments. There are multiple ways to configure an application without modifying the packaged war/ear file depending on the environment.
A common customer question on configuration of the application goes like this ...
We want to load our web application twice in the same WAS server instance ... once for production and once for test. The web app has a configuration file that is different for prod vs test. Our current "technique" is we open the jar in each deployment to update a property file with the fully qualified path/name of the config file. Ick. There must be a better way. I see "custom properties" on a per-application basis. I could add the property there, then add code to read the property in our code. I see all kinds of examples of doing this for JVM properties, but no examples for web-app configuration So, looking for advice, sample code, ...
4 ways of achieving this...
- Using the Contexts and Dependency Injection support for alternatives and/or producers or with third party extensions like CODI in WAS 8.
- Using a resource environment as explained here http://www.ibm.com/developerworks/websphere/library/techarticles/0611_totapally/0611_totapally.html
- Using WebSphere Environment Variables is also another way to configure your application in an environment agnostic fashion. http://pic.dhe.ibm.com/infocenter/wasinfo/fep/topic/com.ibm.websphere.soafep.multiplatform.doc/info/ae/ae/tcws_variable.html
- A property file can be made accessible to Java EE application components in a standards-compliant way by configuring it as a URL resource in the application server and making a reference to it available for lookup in the JNDI namespace. http://www.ibm.com/developerworks/websphere/library/techarticles/0502_botzum/0502_botzum.html
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.