我想在调用Mule中的onCall方法的Java类中实现Singleton,
有我的Java代码
public class MyClass implements Callable {
@Override
public LinkedList<File> onCall(MuleEventContext eventContext) throws Exception {
String fileDirectory = eventContext.getMessage().getInvocationProperty("directory");
String fileDestination = eventContext.getMessage().getInvocationProperty("destination");
LinkedList<File> fileList = (LinkedList<File>) FileUtils.listFiles(new File(fileDirectory), null, false);
for (int j = 0; j < fileList.size(); j++) {
if (fileList.get(j).length() == 0) {
eventContext.getMessage().setOutboundProperty("logger",
"The file was moved to " + fileDestination);
FileUtils.moveFileToDirectory(fileList.get(j), new java.io.File(fileDestination), false);
}
}
fileList = (LinkedList<File>) FileUtils.listFiles(new File(fileDirectory), null, false);
return fileList;
}
}