Commit 04b08df
committed
PTService: add utility method to create a plugin
Surprisingly, the PluginService API does not have a method to create a
plugin from its class. You can only create one from its associated
PluginInfo. So instantiating a plugin becomes a two-step process:
1. Ask the PluginService for the PluginInfo of a given plugin Class.
2. Tell the PluginService to create an instance from that PluginInfo.
And this process is not fully type-safe, since the
PluginInfo#createInstance(PluginInfo) method only knows the object is
of type PT, not P.
To help address this limitation, each PTService now has a handy
create(Class<P extends PT>) method for creating an instance of that
plugin class. This is useful, since using "new" directly is not enough;
the plugin will not have the application context injected as needed.1 parent 755742f commit 04b08df
File tree
2 files changed
+12
-0
lines changed- src/main/java/org/scijava/plugin
2 files changed
+12
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
63 | 72 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
98 | 101 | | |
0 commit comments