I would like to show on screen the Configuration list returned by org.osgi.service.cm.ConfigurationAdmin.listConfigurations method via gogo shell. I tried with the following:
g! _sref = $.context getServiceReference "org.osgi.service.cm.ConfigurationAdmin"
g! _srv = $.context getService $_sref
g! $_srv listConfigurations
but it fails with the following error:
gogo: IllegalArgumentException: Cannot coerce listconfigurations() to any of [(String)]
What is the right syntax here? Is it possible to do that?
Thanks!
The
listConfigurationsmethod takes a String parameter, which is a filter. If you just want an unfiltered list, then you can passnull, e.g.:This returns an array of Configuration objects, which you will probably want to iterate over with the
eachcommand.However this kind of thing quickly gets too complex for Gogo scripting. For example you're not releasing the service reference with
ungetServiceanywhere. It's probably better to build a reusable Gogo command in Java as a Declarative Services component.