私は次のインターフェースを持っています。実装は特定のパスでファイルを暗号化します。
package xx.messaging.fileTransfer;
import org.springframework.integration.annotation.Gateway;
import org.springframework.integration.annotation.Header;
import org.springframework.integration.annotation.Payload;
/**
* <H1>FileEncryptionService</H1>
*/
public interface FileEncryptionService {
/**
* Generates a new encrypted filename based on the input, calls the default method and returns
* the encrypted file name
* @param srcFilename
* @return
* @throws Exception
*/
@Gateway
public String encryptFile(@Payload String srcFilename) throws Exception;
/**
* Encrypt the a file
* @param srcFilename The source file name
* @param destFilename The target file name
*/
@Gateway
public void encryptFile(@Payload String srcFilename, @Header("encryptedFilename") String destFilename);
}
サービスは春の統合を介して呼び出され、ゲートウェイとしてコンテキストに登録されます
<int:gateway service-interface="lu.scoteqint.messaging.fileTransfer.FileEncryptionService"/>
実装する Bean とサービス アクティベーターは次のように登録されます。
<beans:bean id="fileEncryptionService" class="xx.messaging.fileTransfer.impl.CommandLineEncryptionService"/>
<int:service-activator
input-channel="file1"
output-channel="file2"
expression="@fileEncryptionService.encryptFile(payload)"/>
ワイヤータグのログが表示されるため、メッセージのペイロードはファイルへの文字列パスであると予想しています
2013-02-05 15:50:26,911 DEBUG [org.springframework.integration.handler.LoggingHandler] (task-scheduler-1) [Payload=.\src\test\resources\test\xx.xml][Headers={timestamp=1360079426907, id=1c3be020-fc6d-42ba-b3f0-5b963f76fb76}]
しかし、'service-activator' 式はファイルを見つけたようです。
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1004E:(pos 31): Method call: Method encryptFile(java.io.File) cannot be found on lu.scoteqint.messaging.fileTransfer.impl.CommandLineEncryptionService type
at org.springframework.expression.spel.ast.MethodReference.findAccessorForMethod(MethodReference.java:182)
at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:106)
at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:57)
at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:102)
at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:102)
at org.springframework.integration.util.AbstractExpressionEvaluator.evaluateExpression(AbstractExpressionEvaluator.java:126)
at org.springframework.integration.util.AbstractExpressionEvaluator.evaluateExpression(AbstractExpressionEvaluator.java:86)
... 30 more
編集
ログの詳細
2013-02-05 16:26:42,737 DEBUG [org.springframework.integration.channel.DirectChannel] (task-scheduler-1) preSend on channel 'file1', message: [Payload=.\src\test\resources\test.xml][Headers={timestamp=1360081602736, id=877407f6-c5a2-4bea-9ec7-f970b09f08a8}]
パラメータがファイルではなく文字列としてマップされるようにする方法はありますか?