-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DROOLS-384] add a KieScannersRegistry plus methods to read KieScanne…
…r status
- Loading branch information
1 parent
decbe02
commit d90c02e
Showing
5 changed files
with
91 additions
and
10 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
32 changes: 32 additions & 0 deletions
32
kie-ci/src/main/java/org/kie/scanner/KieScannersRegistry.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,32 @@ | ||
package org.kie.scanner; | ||
|
||
import org.drools.compiler.kie.builder.impl.InternalKieScanner; | ||
|
||
import java.lang.ref.WeakReference; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
public class KieScannersRegistry { | ||
|
||
private static List<WeakReference<InternalKieScanner>> scanners = new ArrayList<WeakReference<InternalKieScanner>>(); | ||
|
||
static void register(InternalKieScanner scanner) { | ||
scanners.add(new WeakReference<InternalKieScanner>(scanner)); | ||
} | ||
|
||
public Collection<InternalKieScanner> getAllKieScanners() { | ||
List<InternalKieScanner> allScanners = new ArrayList<InternalKieScanner>(); | ||
Iterator<WeakReference<InternalKieScanner>> i = scanners.iterator(); | ||
while (i.hasNext()) { | ||
InternalKieScanner scanner = i.next().get(); | ||
if (scanner == null) { | ||
i.remove(); | ||
} else { | ||
allScanners.add(scanner); | ||
} | ||
} | ||
return allScanners; | ||
} | ||
} |
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