Я пытаюсь создать пользовательскую команду для консоли OSGI (Equinox), но я не могу ни зарегистрировать, ни правильно использовать команду. Пуск начинается и пытался позвонить mock:command
или command
безрезультатно. Используемое затмение довольно старое: 3.6.2.R36x_v20110210, а содержащий пучок запускается вручную. Есть идеи?Команда OSGi custom shell
public class Activator extends Plugin
{
private static Activator plugin;
private MockCommand service;
@Override
public void start(BundleContext context) throws Exception{
plugin = this;
Dictionary<String, Object> properties = new Hashtable<String, Object>();
properties.put("osgi.command.scope", "mock");
properties.put("osgi.command.function", new String[] {MockCommand.COMMAND});
service = new MockCommand();
context.registerService(MockCommand.class.getName(),service, null);
super.start(context);
}
@Override
public void stop(BundleContext context) throws Exception{
plugin = null;
service = null;
super.stop(context);
}
public static Activator getDefault(){
return plugin;
}
}
И CommandProvider:
public class MockCommand implements CommandProvider{
public static String COMMAND ="command";
public void _command(CommandInterpreter ci) throws Exception {
String commandID = "com.sample.project.fetchMySampleDataCommandId";
((IHandlerService)PlatformUI.getWorkbench().getService(IHandlerService.class)).executeCommand(commandID, null);
}
@Override
public String getHelp() {
StringBuffer buffer = new StringBuffer();
buffer.append("--- Available commands to call by ID ---\n\t");
buffer.append("command --> com.sample.project.fetchMySampleDataCommandId\n\t");
return buffer.toString();
}
}