2012-12-21 33 views
1

我是Spring Integration的新手。我有下面的代碼。我已經把一個文本文件,在我的系統文件夾中的一個,我已經如下配置的入站通道適配器:如何在彈簧集成中獲取文件的完整路徑?

<int-file:inbound-channel-adapter channel="filesInChannel" 
    directory="file:${java.io.tmpdir}/input" auto-create-directory="true" > 

    <int:poller id="poller" fixed-delay="1000" /> 
</int-file:inbound-channel-adapter> 

<int:channel id="filesInChannel"> </int:channel> 

我的問題是從通道(filesInChannel)我怎麼會知道文件名,包括它的絕對路徑?

例如:我的文件位於C:\someFolder\some.txt

從通道我應該得到上面的路徑。

+0

看爲['InboundChannelAdapter']的API(http://static.springsource.org/spring - 整合/存檔/ 1.0.0.M6/apidocs /組織/ springframework的/集成/終端/ InboundChannelAdapter.html) – Raffaele

回答

3

你想要做什麼,一旦你有文件名?

的消息有效載荷是一個java.io.File所以可以簡單的使用表達式payload.absolutePath,例如:

<header-enricher...> 
    <header name="foo" expression="payload.absolutePath" /> 
</header-enricher> 
相關問題