Skip to content

Commit f83f0b3

Browse files
committed
Merge pull request scijava#17 from scijava/singleton-service
Allow filtering instances before they become singletons
2 parents a483943 + 46f64db commit f83f0b3

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/main/java/org/scijava/plugin/AbstractSingletonService.java

+12-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ public ArrayList<Object> get() {
9999

100100
private void createInstances() {
101101
instances =
102-
Collections.unmodifiableList(getPluginService().createInstancesOfType(
103-
getPluginType()));
102+
Collections.unmodifiableList(filterInstances(getPluginService()
103+
.createInstancesOfType(getPluginType())));
104104

105105
log.info("Found " + instances.size() + " " +
106106
getPluginType().getSimpleName() + " plugins.");
@@ -111,4 +111,14 @@ private void createInstances() {
111111
}
112112
}
113113

114+
/**
115+
* Allows subclasses to exclude instances.
116+
*
117+
* @param list the initial list of instances
118+
* @return the filtered list of instances
119+
*/
120+
protected List<? extends PT> filterInstances(List<PT> list) {
121+
return list;
122+
}
123+
114124
}

0 commit comments

Comments
 (0)