Results 1 to 3 of 3

Thread: Dynamic configuration dependend on application context

  1. #1
    Join Date
    Aug 2006
    Location
    NRW / Germany
    Posts
    1

    Question Dynamic configuration dependend on application context

    Hi,
    I have the problem that I have two web applications (both are the same) running in Tomcat which both needs different data storages for caching (OSCache is used). The initialisation of OSCache is done in the application-context:

    Code:
    <!-- Cache -->
    	<bean id="cacheAdministrator" class="com.opensymphony.oscache.general.GeneralCacheAdministrator" destroy-method="destroy">
    		<constructor-arg index="0">
    			<props>
    				<prop key="cache.memory">true</prop>
    				<prop key="cache.event.listeners">biz.solution4your.lms.cache.StatisticListenerImpl, com.opensymphony.oscache.extra.ScopeEventListenerImpl</prop>
    				<prop key="cache.persistence.class">com.opensymphony.oscache.plugins.diskpersistence.HashDiskPersistenceListener</prop>
    				<prop key="cache.persistence.overflow.only">true</prop>
    				<prop key="cache.path">${catalina.base}/temp/cache</prop>
    				<prop key="cache.capacity">100</prop>
    				<prop key="cache.unlimited.disk">false</prop>
    			</props>
    		</constructor-arg>
    	</bean>
    	<!-- /Cache -->
    As you can see, I am currently using "${catalina.base}/temp/cache" (this would be the same for both webapplications in Tomcat), but I like to know if I can also use the webapplication to make sure the caches are different for the different webapplications? E.g. something like this directory structure: "<tomcatbasepath>/temp/<applicationcontext>/cache". Any idea?

    TIA Octoate

  2. #2
    Join Date
    Jun 2005
    Posts
    4,232

    Default

    If you include a bean in your context that implements ServletContextAware it will be wired with the context at startup. Then you can pull the context name out of the ServletContext (e.g. using a PropertyPathFactoryBean).

  3. #3
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    As david suggested, use the ServletContext to add parameters as part of your web.xml. This way, you don't have to rely on the a system property (which is viewed by the entire VM) and you change things dynamically w/o much hassle.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •