Reputation: 645
I have a super lightweight weblogic application and I need access to a string that will change depending on the environment. I've searched for a bit and all my options seem to require building classes and loaders etc. However with the number of application configuration files weblogic has I'm fully expecting there to be a better place to store a single global property for quick reference that can be changed using the plan.xml file.
Upvotes: 2
Views: 1895
Reputation: 34387
Not sure, if your looking for this(adding another answer).
startWebLogic.cmd/startWebLogic.sh
available in your weblogic domain folder.set JAVA_OPTIONS=%JAVA_OPTIONS% -Dmy.environment=TestEnviroment
in the top section of the file
before it calls call "%DOMAIN_HOME%\bin\startWebLogic.cmd" %*
Weblogic
server.This variable is now present in the environment for usage.
Upvotes: 1
Reputation: 34387
I think you can use plan.xml
during deployment time with entry as below to override myEnvVariable
context variable value defined through context in web.xml
. Details are provided at Oracle Website.
<variable-definition>
<variable>
<name>myEnvVariable</name>
<value>myEnvironmentDependentValue</value>
</variable>
</variable-definition>
You may want to create different plan.xml
for different environments.
Context variable in web.xml
can be defined as below:
<context-param>
<param-name>myEnvVariable</param-name>
<param-value>myEnvironmentDefaultValue/param-value>
</context-param>
Context variables can be retrieved in server side using request object as below:
String myEnvVariableString= getServletContext().getInitParameter("myEnvVariable");
Upvotes: 1