1

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!

matteo rulli
  • 1,443
  • 2
  • 18
  • 30

2 Answers2

1

The listConfigurations method takes a String parameter, which is a filter. If you just want an unfiltered list, then you can pass null, e.g.:

$_srv listConfigurations null

This returns an array of Configuration objects, which you will probably want to iterate over with the each command.

However this kind of thing quickly gets too complex for Gogo scripting. For example you're not releasing the service reference with ungetService anywhere. It's probably better to build a reusable Gogo command in Java as a Declarative Services component.

Neil Bartlett
  • 23,743
  • 4
  • 44
  • 77
  • So it was enough to write null at the end. Thank you. By the way, the complete each command I used is the following: `_out = $_srv listConfigurations null` / `each [ $_out ] { echo $it }` – matteo rulli Jul 05 '15 at 12:25
1

It's probably a lot easier to use the following shell commands to achieve that:

https://bitbucket.org/pjtr/net.luminis.cmc

Which has, amongst other things, a command called:

cm list
Marcel Offermans
  • 3,313
  • 1
  • 15
  • 23