Search code examples
javaconfigurationweblogic

Specifying deployment configuration settings for weblogic?


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.


Solution

  • 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");