Announcement Announcement Module
Collapse
No announcement yet.
How to use system properties in a BeanFactory? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to use system properties in a BeanFactory?

    Hi all,

    I have a little problem you may be able to help me with I have a bean that has 2 setter methods that take file locations as the parameters. The bean is configured in a WebContext as follows:

    <bean id="catalogueManager" class="com.medseaconsulting.catalogue.business.Pro ductCatalogueManagerImpl" init-method="loadCatalogue">
    <property name="categoryFile" value="/tools/apache/jakarta/tomcat/4.1.27/webapps/crystal2spain/resources/categories.xml"/>
    <property name="productFile" value="/tools/apache/jakarta/tomcat/4.1.27/webapps/crystal2spain/resources/products.xml"/>
    </bean>

    I would like to replace the first part of the path with the system property CATALINA_HOME as in
    <property name="categoryFile" value="${CATALINA_HOME}/webapps/crystal2spain/resources/categories.xml"/>

    I cannot use a relative path as this is dependent upon the directory from which Tomcat is started so something like "../webapps/crystal2spain/resources/categories.xml" is OK for my test environment where I always start Tomcat from the bin directory. However, when I deploy to my hosting service this is not true. I usually get a user home directory from where tomcat is lanched using the CATALINA_HOME system property.

    My bean is not aware of a web context or anything else so I cannot get a context-init param and use that either.

    Can anybody tell me how to handle this or suggest another solution?

    Regards

    Steve

  • #2
    You can use "org.springframework.beans.factory.config.Property PlaceholderConfigurer". Check the "systemPropertiesMode" property.

    Comment

    Working...
    X