Announcement Announcement Module
Collapse
No announcement yet.
MessageSource properties file loading from a remote location Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • MessageSource properties file loading from a remote location

    Hi All,

    I am using Spring web-mvc in SAP web server. Is it possible to store the properties file in some remote location like in knowledge management of sap and load these files as message resources in spring mvc application.

    As far as I know there is a class ResourceLoader used to load the properties file from class path. I tried extending this class and write my own implementation to get the resources from my file system, but I was not successful.

    here is my resourceLoader method to retrieve resource

    Code:
    public Resource getResource(String location) {
    		System.out.println("KMResourceLoader getResource:" + location);
    		File file = new File("D:/test/" + location + ".properties");
    		MessageResource messageResource = new MessageResource(file);
    		messageResource.setLastModified(new Date().getTime());
    		return messageResource;
    	}
    In the above code MessageResource is a custom class that implements Resource and extends AbstractResource.

    here is my configuration for messageSource
    Code:
    <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    		<property name="defaultEncoding" value="UTF-8"></property>
    		<property name="resourceLoader" ref="kmResourceLoader"></property>
    		<property name="basenames">
    			<list>
    				<value>messages</value>
    			</list>
    		</property>
    	</bean>
    Please advice me on this

  • #2
    Is someone there to help me ?

    Comment


    • #3
      you cannot use the resourceLoader

      The ResourceLoader got overridden during application context initialization with a XmlWebApplicationContext (or the applicationContext your application is runing in) because it implements the 'ResourceLoaderAware' interface.

      Comment

      Working...
      X