Women in Technology

Hear us Roar



Article:
  Advanced Configuration of the Spring MVC Framework
Subject:   Why not use jndi?
Date:   2006-03-24 06:29:50
From:   mdebruijn
Why not use the naming server for the environment specific settings?


I've moved the environment specific settings from the applicationContext.xml file to the naming server.
applicationContext.xml example:

<bean id="myService" class="nl.novumsoftware.MyService">
<property name=”url”>
<bean class=”org.springframework.jndi.JndiObjectFactoryBean”>
<property name=”jndiName”>
<value>java:comp/env/databaseUrl</value>
</property>
</bean>
</property>
</bean>


Example for the naming server in Tomcat:

<Context path="/myweb" ... >
<Environment name="databaseUrl" type="java.lang.String" value="jdbc:oracle:thin:@myHost:1521:myInstance"/>
</Context>



De ear/war can now be deployed on any machine without modifications. Of course the solution only works for application server managed applications.


Martijn de Bruijn