Skip to content

Commit e5fa4d1

Browse files
committed
Merge pull request #11 from knime-ip/reuse-plugin-index
Make PluginIndex reusable
2 parents ea21253 + fd85037 commit e5fa4d1

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

org.knime.knip.scijava.core/META-INF/MANIFEST.MF

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.11.0",
1313
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
1414
Bundle-ActivationPolicy: lazy
1515
Bundle-ClassPath: .
16-
Export-Package: org.knime.knip.scijava.core
16+
Export-Package: org.knime.knip.scijava.core,
17+
org.knime.knip.scijava.core.pluginindex
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package org.knime.knip.scijava.core.pluginindex;
2+
3+
import org.scijava.plugin.PluginFinder;
4+
import org.scijava.plugin.PluginIndex;
5+
6+
/**
7+
* {@link PluginFinder} which can be reused without re-adding all plugins from a
8+
* {@link PluginFinder} to the index when creating a Context with this plugin
9+
* index.
10+
*
11+
* @author Jonathan Hale (University of Konstanz)
12+
*/
13+
public class ReusablePluginIndex extends PluginIndex {
14+
15+
/* flag to keep track of whether #discover() has been called already */
16+
private boolean discovered = false;
17+
18+
/**
19+
* @see PluginIndex#PluginIndex()
20+
*/
21+
public ReusablePluginIndex() {
22+
super();
23+
}
24+
25+
/**
26+
* @param pluginFinder
27+
* @see PluginIndex#PluginIndex(PluginFinder)
28+
*/
29+
public ReusablePluginIndex(final PluginFinder pluginFinder) {
30+
super(pluginFinder);
31+
}
32+
33+
@Override
34+
public void discover() {
35+
if (!discovered) {
36+
super.discover();
37+
}
38+
discovered = true;
39+
}
40+
}

0 commit comments

Comments
 (0)