-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Full impl of the Process Listener Feature.
Now with a test and a default solution included for easy use.
- Loading branch information
Showing
6 changed files
with
173 additions
and
2 deletions.
There are no files selected for viewing
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
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
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
42 changes: 42 additions & 0 deletions
42
src/main/java/com/github/kokorin/jaffree/process/ProcessListener.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,42 @@ | ||
package com.github.kokorin.jaffree.process; | ||
|
||
import java.util.Collections; | ||
import java.util.Set; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
/** | ||
* @author Speiger | ||
*/ | ||
public interface ProcessListener { | ||
public void onStart(Process process); | ||
public void onStop(Process process); | ||
|
||
/** | ||
* Simple tracker wrapper that allows to track all instances being loaded. | ||
* | ||
* @param instances Set. Highly Suggest {@link Collections#newSetFromMap} using a {@link ConcurrentHashMap} for multithreading support | ||
* @return ProcessListener wrapper | ||
*/ | ||
public static ProcessListener of(Set<Process> instances) { | ||
return new Impl(instances); | ||
} | ||
|
||
static class Impl implements ProcessListener { | ||
Set<Process> instances; | ||
|
||
public Impl(Set<Process> instances) { | ||
this.instances = instances; | ||
} | ||
|
||
@Override | ||
public void onStart(Process process) { | ||
instances.add(process); | ||
} | ||
|
||
@Override | ||
public void onStop(Process process) { | ||
instances.remove(process); | ||
} | ||
|
||
} | ||
} |
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
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