Skip to content

Commit f44d764

Browse files
committed
Gateway: make an effort to inject plugin metadata
People like to create gateways by calling the constructors directly. Let's make sure that when they are created in this fashion, methods of RichPlugin like getInfo() and getPriority() still work correctly.
1 parent f31a468 commit f44d764

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/main/java/org/scijava/AbstractGateway.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import org.scijava.platform.AppEventService;
5555
import org.scijava.platform.PlatformService;
5656
import org.scijava.plugin.AbstractRichPlugin;
57+
import org.scijava.plugin.PluginInfo;
5758
import org.scijava.plugin.PluginService;
5859
import org.scijava.prefs.PrefService;
5960
import org.scijava.script.ScriptService;
@@ -86,7 +87,15 @@ public AbstractGateway() {
8687

8788
public AbstractGateway(final String appName, final Context context) {
8889
this.appName = appName;
89-
if (context != null) setContext(context);
90+
if (context != null) {
91+
setContext(context);
92+
93+
// NB: Make a best effort to inject plugin metadata.
94+
final PluginInfo<?> info = PluginInfo.getOrCreate(getClass(),
95+
Gateway.class, context.getPluginIndex());
96+
info.inject(this);
97+
Priority.inject(this, info.getPriority());
98+
}
9099
}
91100

92101
// -- Gateway methods --

0 commit comments

Comments
 (0)