Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The listener better be abstract class to allow us to add more callbacks. We should support multiple listeners. Added the close callback for symmetry. Call to listeners should be after we process the event since listeners aren't fully trusted to get things right. Renamed the class since from users' perspective it is not external. Added help screen
- Loading branch information
Showing
4 changed files
with
84 additions
and
40 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
src/main/java/org/kohsuke/file_leak_detector/ActivityListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package org.kohsuke.file_leak_detector; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.FileOutputStream; | ||
import java.io.RandomAccessFile; | ||
import java.net.ServerSocket; | ||
import java.net.Socket; | ||
import java.nio.channels.SocketChannel; | ||
import java.util.List; | ||
import java.util.concurrent.CopyOnWriteArrayList; | ||
import java.util.zip.ZipFile; | ||
|
||
/** | ||
* Allows user programs to receive callbacks for file open/close activities. | ||
* | ||
* <p> | ||
* Instantiate this class and put it into {@link #LIST} to start receiving callbacks. | ||
* Listeners must be concurrent and re-entrant safe. | ||
* | ||
* @author Michal Linhard (michal@linhard.sk) | ||
* @author Kohsuke Kawaguchi | ||
*/ | ||
public abstract class ActivityListener { | ||
/** | ||
* Called when a new file is opened. | ||
* | ||
* @param obj | ||
* {@link FileInputStream}, {@link FileOutputStream}, {@link RandomAccessFile}, or {@link ZipFile}. | ||
* @param file | ||
* File being opened. | ||
*/ | ||
public void open(Object obj, File file) { | ||
} | ||
|
||
/** | ||
* Called when a new socket is opened. | ||
* | ||
* @param obj | ||
* {@link Socket}, {@link ServerSocket} or {@link SocketChannel} | ||
*/ | ||
public void openSocket(Object obj) { | ||
} | ||
|
||
/** | ||
* Called when a file is closed. | ||
* | ||
* This method tolerates a double-close where a close method is called on an already closed object. | ||
* | ||
* @param obj | ||
* {@link FileInputStream}, {@link FileOutputStream}, {@link RandomAccessFile}, {@link Socket}, {@link ServerSocket}, or {@link ZipFile}. | ||
*/ | ||
public void close(Object obj) { | ||
} | ||
|
||
/** | ||
* These listeners get called. | ||
*/ | ||
public static final List<ActivityListener> LIST = new CopyOnWriteArrayList<ActivityListener>(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 0 additions & 28 deletions
28
src/main/java/org/kohsuke/file_leak_detector/ExternalListener.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters