0

I want to implement Singleton in a Java class who call the onCall Method in Mule ,

There is my java code

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;
}
}
  • there is multiple ways to do that.check this out https://stackoverflow.com/questions/2111768/singleton-class-in-java – Asanka Anthony Oct 31 '18 at 10:11
  • Could explain what you are trying to achieve? Perhaps a singleton is not the best solution for what you are trying to do. – aled Nov 04 '18 at 12:09

0 Answers0