Announcement Announcement Module
Collapse
No announcement yet.
MessageSource with external property file Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • MessageSource with external property file

    Hi,

    I've defined a MessageSource like so:

    Code:
    <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
      <property name="basename"><value>WEB-INF/sso</value></property>
      <property name="cacheSeconds"><value>60</value></property>
    </bean>
    but I want to specify a path for the properties file outside the WAR. Is this possible?

    Thank you in advance for any help,
    grimholtz

  • #2
    Yes, you can actually load from all kinds of resources: "basename" is a Spring resource location, following the same rules as an application context's "contextConfigLocation" etc.

    A plain path will be relative to the current application context. A "classpath:" URL will be treated as classpath resource.
    A "file:" URL will load from an absolute file system path.
    Any other URL, such as "http:", is possible too.

    So in your case, try a "file:" URL with the absolute path outside the WAR.

    Juergen

    Comment


    • #3
      Thanks for the help, Juergen! Here's a slightly more challenging use of ReloadableResourceBundleMessageSource (or its friends) on which I'm hoping you can shed some light:

      I've specified the file: path in JNDI as a java.net.URL. So in Spring I define a bean like so:

      Code:
      <bean id="propertiesUrl" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName"><value>url/propertiesURL</value></property>
        <property name="resourceRef"><value>true</value></property>	  
      </bean>
      How can I specify this URL as the basename for ReloadableResourceBundleMessageSource?

      Thank you again,
      Eric

      Comment


      • #4
        p.s. the following does not work:

        Code:
        <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
          <property name="basename"><ref bean="propertiesUrl"/></property>
          <property name="cacheSeconds"><value>60</value></property>
        </bean>

        Comment

        Working...
        X