Skip to content

Commit 5435cc0

Browse files
committed
CommandInfo: implement the Versioned interface
1 parent cf47e2a commit 5435cc0

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/main/java/org/scijava/command/CommandInfo.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import org.scijava.ItemVisibility;
4848
import org.scijava.Locatable;
4949
import org.scijava.ValidityProblem;
50+
import org.scijava.Versioned;
5051
import org.scijava.event.EventService;
5152
import org.scijava.module.Module;
5253
import org.scijava.module.ModuleException;
@@ -58,6 +59,7 @@
5859
import org.scijava.plugin.PluginInfo;
5960
import org.scijava.service.Service;
6061
import org.scijava.util.ClassUtils;
62+
import org.scijava.util.Manifest;
6163
import org.scijava.util.StringMaker;
6264

6365
/**
@@ -77,7 +79,7 @@
7779
* commands and the rich {@link Module} interface.
7880
*/
7981
public class CommandInfo extends PluginInfo<Command> implements ModuleInfo,
80-
Identifiable, Locatable
82+
Identifiable, Locatable, Versioned
8183
{
8284

8385
/** Wrapped {@link PluginInfo}, if any. */
@@ -435,6 +437,19 @@ public String getLocation() {
435437
}
436438
}
437439

440+
// -- Versioned methods --
441+
442+
@Override
443+
public String getVersion() {
444+
try {
445+
final Manifest m = Manifest.getManifest(loadDelegateClass());
446+
return m == null ? null : m.getImplementationVersion();
447+
}
448+
catch (final ClassNotFoundException exc) {
449+
return null;
450+
}
451+
}
452+
438453
// -- Helper methods --
439454

440455
/**

0 commit comments

Comments
 (0)