Announcement Announcement Module
Collapse
No announcement yet.
web.xml environment variable in dataAccessContext.xml Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • web.xml environment variable in dataAccessContext.xml

    Is it posible to use an environment varible defined in web.xml

    <env-entry>
    <env-entry-name>hostname</env-entry-name>
    <env-entry-value>server.myhost.com</env-entry-value>
    <env-entry-type>java.lang.String</env-entry-type>
    </env-entry>

    in dataAccessContext ??? something like this:

    <bean id="MQQuery" class="com.myhost.MQQueryImpl">
    <property name="hostname">
    <value>$(hostname)</value>
    </property>
    </bean>

    Thanks
    Ignacio

  • #2
    Because i dont have a better option i do this:

    <bean id="hostname" class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiName">
    <value>hostname</value>
    </property>
    <property name="resourceRef">
    <value>true</value>
    </property>
    </bean>

    <bean id="MQQuery" class="cr.go.ice.vep.dao.mq.MQQueryImpl">
    <property name="hostname">
    <ref local="hostname"/>
    </property>
    </bean>

    i dont think this is the best way to do this ... but i dont know a better way

    Comment


    • #3
      See the JavaDocs for ServletContextPropertyPlaceholderConfigurer available in 1.1.4 and above.

      Rob

      Comment


      • #4
        Im reading the javadoc right now

        im my case are <env-entry> and not context-param entries. It works too ??

        Any good example ????

        thanks
        Ignacio

        Comment


        • #5
          Ignacio,

          Sorry, no that won't work. Why do you have to use <env-entry>? You should look at the source for ServletContextPPC since you could probably create your own to do what you want.

          Rob

          Comment


          • #6
            Because is easier to modify and enviroment variable on a clustered websphere 5.1. If you change a config file by hand your have to copy this file manually to every server on the cluster ....

            Thanks
            Ignacio

            Comment


            • #7
              Lookup the JNDI support; I don't think you can do exactly what you want, but I believe you can come close. The only problem might be if you change value at runtime - you might be able to do this by using a non-singleton.

              Comment

              Working...
              X