Skip to content

Commit e1d4caa

Browse files
committed
ScriptREPL: use service name from @plugin metadata
And fall back to the old behavior of synthesizing a name from the class name when no name is specified in the @plugin annotation. Related discussion at: https://gitter.im/scijava/scijava-common?at=5dcc215f92a84f79fe5da435 This commit is dedicated to Kyle Harrington.
1 parent e243eb9 commit e1d4caa

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/main/java/org/scijava/script/ScriptREPL.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,11 @@ private List<Gateway> gateways() {
386386
}
387387

388388
private String serviceName(final Service service) {
389+
final PluginInfo<?> info = service.getInfo();
390+
final String pluginName = info == null ? null : info.getName();
391+
// Name was explicitly given in the @Plugin annotation.
392+
if (pluginName != null && !pluginName.isEmpty()) return pluginName;
393+
// No name was given; synthesize one from the class name.
389394
final String serviceName = service.getClass().getSimpleName();
390395
final String shortName = lowerCamelCase(
391396
serviceName.replaceAll("^(Default)?(.*)Service$", "$2"));

0 commit comments

Comments
 (0)