felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Derek Baum <de...@baums.org.uk>
Subject Re: Gogo shell - don't call getXXX on each object
Date Wed, 19 Nov 2014 10:30:09 GMT
Two things are happening here:

1. By default gogo prints the result of commands (including assignments)

g! lb -s | grep gogo
    2|Active     |    1|org.apache.felix.gogo.command (0.12.0)
    3|Active     |    1|org.apache.felix.gogo.runtime (0.10.0)
    4|Active     |    1|org.apache.felix.gogo.shell (0.10.0)
true

The ‘true’ in the output above is the result of the grep command, printed by the togo
console.


2. The result is printed using registered converters for the type, not just toString().

This means that multiple methods may be invoked by the converter to print the type - as you
have found.

The rationale behind this, was that it allowed commands to be constructed directly from api
calls.
For example, the ‘bundle’ command is a direct call to BundleContext.getBundle():

g! b1 = bundle 1

produces a pretty formatted bundle listing - which is done by the registered converter for
Bundle - the value assigned to b1 is the bundle imll:

g! set b1
BundleImpl      b1              org.apache.felix.bundlerepository [1]

This behaviour can be disabled by setting:

g! .Gogo.format=false

Note: although this solves your issue, some commands such as ‘bundle’ will no longer produce
the expected output.

In this case you can invoke the converter explicitly using the format command:

g! bundle 1
g! format
Bundle                   1|Active     |    1|org.apache.felix.bundlerepository (1.6.6)
...

—
Derek

On 19 Nov 2014, at 09:44, Bulu <bulu@romandie.com> wrote:

> Hello all
> 
> When I assign variables in Gogo Shell like so:
>   g! _srefs = $.context getServiceReferences "com.example.Class" "(some=filter)"
> the shell automatically calls all getXXX methods on the returned object and prints the
result out.
> 
> How can I avoid this?
> I have some long running getXXX methods which I don't want to be called unless needed.
> 
> Thanks Phil
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message