如何使用Java在mule中调用onCall方法的Class实现Singleton?

时间:2018-10-31 09:19:16

标签: java singleton mule

我想在调用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;
}
}

0 个答案:

没有答案