0

I am trying to create a GoGo-Shell-Command using the Felix-Dependency-Manager (Version 3.2.0) without Annotations.

As far as I understand, the gogo-runtime uses the whiteboard-pattern and scans for services with Properties using the keys CommandProcessor.COMMAND_SCOPE and CommandProcessor.COMMAND_FUNCTION.

In my case, the bundle is started, the service is registered with the correct properties but my command is not listed under "help" nor does it work when I try to call it.

The following code registers the service within the BundleActivator (DependencyActivatorBase):

Properties props = new Properties();
props.put(CommandProcessor.COMMAND_SCOPE, "test");
props.put(CommandProcessor.FUNCTION_SCOPE, new String[] {"command"});

manager.add(createComponent()
    .setInterface(Object.class.getName(), props)
    .setImplementation(MyConsole.class)
    .add(createServiceDependency()
        .setService(MyService.class)));

The following bundles are listed with lb-Command when running my code.

org.apache.felix.gogo.command
org.apache.felix.gogo.runtime
org.apache.felix.gogo.shell
org.apache.felix.dependencymanager
org.apache.felix.dependencymanager.shell
mybundle.service
mybundle.api
mybundle.console

Development is done with BndTools.

Am I missing something here?

lostiniceland
  • 3,729
  • 6
  • 38
  • 50

1 Answers1

1

First of all, your assumption about how to register gogo commands is correct: a whiteboard pattern is used and the scope and function properties determine the commands.

You did not post the code for MyConsole. Does it actually contain a method called command? If not, that could be the problem.

Another potential problem could be that you did not actually add a Bundle-Activator line in your manifest.

If that's not it, use the dm notavail command to see if there are any unregistered components (because of missing dependencies).

Marcel Offermans
  • 3,313
  • 1
  • 15
  • 23
  • Everything you mention is in place: method, activator (also in manifest), and *dm notavail* returns no output (but no error as well, so I guess its correct). I also debugged my activator, to see that the code for registration is executed...which it is. The only thing left, which sometimes caused me trouble recently, is JDK 8 which runs my Eclipse and also my Felix-Runtime – lostiniceland Feb 25 '15 at 19:41
  • Could you please publish this code on github or somewhere else so I can take a look? – Marcel Offermans Feb 26 '15 at 15:23
  • After I tested the Command with the Bnd-Annotations which worked, I found out that there is a problem with the String-Array in the CommandProcessor.FUNCTION_SCOPE: **props.put(CommandProcessor.COMMAND_FUNCTION, "listConferences");** this works, but I wonder why the String [] isnt. – lostiniceland Feb 26 '15 at 20:21
  • I don't know why that does not work for you as I have many examples in projects I work on that do use an array of strings successfully. If you could boil it down to a single, non-working example that I can reproduce here I would be happy to investigate further. – Marcel Offermans Feb 26 '15 at 23:12
  • 1
    Now that is weird: I refactored the code back to the String-Array approach and now it is working. So I guess there must have been a typo, since in my actual code I had used two functions in the array (which is also working now). Thanks for your help...I also uploaded the (working) code to Github (https://github.com/lostiniceland/osgi/tree/master/cloudbook) :-) – lostiniceland Feb 27 '15 at 09:25