rdp4j
rdp4j copied to clipboard
Can I get directory details along with file name in MyListener? I want to check which directory the mentioned file is added / removed
Can I get directory details along with file name in MyListener? I want to check which directory the mentioned file is added / removed / modified. Can I have one listener to poll 10 directories and I get which event is called on which folder?
You can add as many PolledDirectory
implementations as you wish into the DirectoryPoller
. Either via the DirectoryPollerBuilder
or the DirectoryPoller
instance it self.
The FileElement
and PolledDirectory
implementations, as exposed by the Listener
interfaces, are yours, so you can expose anything you like from those. Just cast to your implementation to get access.
See example below:
public static void main(String[] args) {
DirectoryPoller dirPoller = DirectoryPoller.newBuilder()
.addPolledDirectory(new MyPolledDirectory("some/path"))
.addPolledDirectory(new MyPolledDirectory("another/path"))
.addListener(new MyListener())
.start();
dirPoller.addPolledDirectory(new MyPolledDirectory("third/path"));
}
static class MyListener extends AbstractRdp4jListener {
@Override
public void fileAdded(FileAddedEvent event) throws InterruptedException {
MyPolledDirectory myDir = (MyPolledDirectory) event.getPolledDirectory();
MyFileElement myFileElement = (MyFileElement) event.getFileElement();
}
}