The idea was to provide multiple web applications running inside a Tomcat instance with configuration properties from config files located outside the WAR file of the applications. I'm currently trying to provide these configuration properties with a global naming resource (defined inside the server.xml) which is consumed by the said applications to keep the configuration container independent and to avoid direct file access from a web application. So far almost everything already works perfectly! Except that Tomcat obviously caches resources which are looked up via JNDI. This way I have to restart Tomcat every time the external config files changes because the web applications never access my ObjectFactory again after Tomcat has cached the result of the ObjectFactory. Is there any way to disable this behavior of Tomcat's JNDI resource management? Thanks in advance!
There is sort of a way to get this happen. It is not a cache, instead it is singleton or non singleton.
Take the default example that ships with Tomcat
<Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml" /> <Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml" singleton="false"/>Then you are able to decide when getObjectInstance returns a new object, or a cached object in your own code.
Popular Links
Comments
Post new comment