There is an inspect(Object) method in 
org.apache.felix.gogo.runtime.CommandSessionImpl, which is used when no more 
specific formatter is found.

It uses reflection to invoke all public no-args methods on the target object 
and formats each using the LINE level.

For example, see that the value for Bundle uses LINE format, so resembles the 
output of the lb command (which also uses LINE format):

g! bundle 0
Location             System Bundle
State                32
BundleContext        org.apache.felix.framework.BundleContextImpl@f572ebb
BundleId             0
SymbolicName         org.apache.felix.framework
RegisteredServices   [Resolver, PackageAdmin, StartLevel]
ServicesInUse        [StartLevel]
Version              5.6.10
PersistentState      32
Bundle                   0|Active     |    0|org.apache.felix.framework (5.6.10)
Revisions            [org.apache.felix.framework [0](R 0)]
LastModified         0
Headers              [Export-Package=org.osgi.dto; version="1.0.0", 
org.osgi.framework; version="1.8.0",
-- snip --

--
Derek

> On 13 Nov 2018, at 09:48, Neil Bartlett <njbartl...@gmail.com> wrote:
> 
> There is already a bundle command which returns a Bundle object. The
> problem is the formatting of that object, which is controlled by
> the org.apache.felix.service.command.Converter service.
> 
> The implementation class org.apache.felix.gogo.shell.Converters (from the
> shell bundle) implements a format method for Bundle objects at the LINE and
> PART detail levels, which is why the output of the lb command doesn't look
> terrible. It seems to lack an implementation for the INSPECT level however.
> 
> Regards,
> Neil
> 
> On Tue, Nov 13, 2018 at 9:38 AM Todor Boev <rinsv...@gmail.com> wrote:
> 
>> Hello,
>> 
>> Can we add a "bundle" command to gogo that will list a readable summary for
>> a target bundle?
>> Calling BundleContext.getBundle() and looking at the raw object print is
>> almost useless.
>> 
>> Also is there any reason this was not done until now?
>> 
>> Regards,
>> Todor
>> 

Reply via email to