开发者

Configuring System property in Spring

I have file channel adapter which need to listen to a directory in specfied intervals. And I have the following code.

<file:inbound-channel-adapter id="fileAdapter"
         directory="file:${SYS.com.abc.wls.workdir}/finalize/" queue-size="1000"
    auto-startup="true" filename-pattern="*.txt">
<int:poller fixed-delay="500">          

</int:poller>       
 </file:inbound-channel-adapter>

when I replce directory="file:${SYS.com.abc.wls.workdir}/finalize/ with a real directory name ( like directory="file:C:/temp/finalize/) everything works fine. But the system property is being set when starting the server, but spring doesnt detect the system property.

Could you please help ?

Update :

I have the following configuration for place holder

<beans:bean id="jobProperties"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <beans:property name="properties">
        <beans:value>
            job.group.commit.interval=5000
        </beans:value>
    </beans:property>
    <beans:property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_FALLBACK" />
    <beans:property name="ignoreUnresolvablePlaceholders"
        value="true" />
    <beans:property name="order" value="1" />
</beans:bean>

Removed : file: from directory="file:${SYS.com.abc.wls.workdir}/finalize/" and changed to auto-create-directory="false" and now I'm gettign the exception as below,

    by: java.lang.IllegalArgumentException: Source directory **[${SYS.com.abc.wls.workdir}\finalize] does not exist**.
 at org.springframework.util.Assert.isTrue(Assert.java:65)
 at org.springframework.integration.file.FileReadingMessageSource.onInit(FileReadingMessageSource.java:233)
 at org.springframework.integration.context.IntegrationObjectSupport.afterPropertiesSet(IntegrationObjectSupport.java:98)
 at org.springframework.integration.file.config.FileReadingMessageSourceFactoryBean.initSource(FileReadingMessageSourceFactoryBean.java:153)
 at org.springframework.integration.file.config.FileReadingMessageSourceFactoryBean.getObject(FileReadingMessageSourceFactoryBean.java:99)
 at org.springframework.integration.file.config.FileReadingMessageSourceFactoryBean.getObject(FileReadingMessageSourceFactoryBean.java:37)
 at or开发者_开发问答g.springframework.beans.factory.support.FactoryBeanRegistrySupport$2.run(FactoryBeanRegistrySupport.java:133)
 at java.security.AccessController.doPrivileged(Native Method)
 at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:131)
 ... 63 more


You need to declare a spring entity which recognizes system properties. The typical approach is to put a PropertyPlaceHolderConfigurer in your Springconfiguration.

The default mode is SYSTEM_PROPERTIES_MODE_FALLBACK, which means that values not held by the configurer will be looked for as a system property. The mode can be overriden using setSystemPropertiesMode.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜