Writing Gogo Commands

82 views
Skip to first unread message

Peter Kriens

unread,
Mar 25, 2017, 9:30:51 AM3/25/17
to OSGi Developer Mail List, bndtool...@googlegroups.com
Most of the Gogo commands I see written do not take advantage of Gogo at all. Gogo basically allows you to write plain old Java code that is indistinguishable from your normal service code. In fact, you can often directly use your service code. This works because Gogo has a powerful underlying formatting and conversion technique.

I’ve written, with the help of SMA and Ray Augé, an App note. If you ever wrote a Gogo command suggest you read it. If you’ve not, a good time to start:


There is also an app note about how to use Gogo, which is also often a surprise to people. For this next app note I’ve extended the this app note with an explanation of the Gogo functions/lambdas.


Enjoy! And please submit a PR to improve these app notes.

Kind regards,

Peter Kriens

Neil Bartlett

unread,
Mar 25, 2017, 10:41:04 AM3/25/17
to bndtool...@googlegroups.com, OSGi Developer Mail List
Speaking of which, I’ve always wanted to use annotations to define my Gogo commands instead of manually specifying the service properties. So instead of:

@Component(property = { “osgi.command.scope=blah”, “osgi.command.function=dosomething” })
public class Blah {
public void dosomething() {}
}

I would like to write:

@Component
@GogoScope(“blah”)
public class Blah {
@GogoCommand
public void dosomething() {}
}

… which would translate at build time to the same thing (I’m not proposing to change the Gogo runtime model).


--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raymond Auge

unread,
Mar 25, 2017, 11:16:46 AM3/25/17
to bndtool...@googlegroups.com, OSGi Developer Mail List
Neil,

You should be able to do something quite similar in R7 DS due to the new component property types :)

- Ray

To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Raymond Augé (@rotty3000)
Senior Software Architect Liferay, Inc. (@Liferay)
Board Member & EEG Co-Chair, OSGi Alliance (@OSGiAlliance)

Raymond Auge

unread,
Mar 25, 2017, 11:17:21 AM3/25/17
to bndtool...@googlegroups.com, OSGi Developer Mail List
... at least on the component, not at the method level.

- Ray

BJ Hargrave

unread,
Mar 25, 2017, 11:38:12 AM3/25/17
to bndtool...@googlegroups.com
Using the new support coming for DS 1.4, you can define a component property type which can be applied to the component to declare service properties.

@ComponentPropertyType
@interface GoGo {
  String PREFIX_ = "osgi.command.";
  String scope();
  String function();
}

@Component
@GoGo(scope="blah", function="dosomething")
public class Blah {
  public void dosomething() {}
}

But, as Ray noted, there is no way to have some annotation on a method result in a component property using the DS 1.4 support. Something like that would need to be special custom support in Bnd.
--
BJ

Neil Bartlett

unread,
Mar 25, 2017, 11:46:19 AM3/25/17
to bndtool...@googlegroups.com
Thanks BJ and Ray. I was vaguely aware of that. Of course, it’s the method annotations I really want because referring to method names from String literals at the class level is easily broken by refactoring. Also it’s nice to see right there on the method that that method is a command.

I will look into doing this in bnd… in my copious spare time.

Neil

Christian Schneider

unread,
Mar 27, 2017, 8:52:31 AM3/27/17
to bndtool...@googlegroups.com
I am currently working on some improved documentation for felix gogo. (https://issues.apache.org/jira/browse/FELIX-5595)
Currently I described the most important of the build in commands as well as the color configuration for the new gogo jline.

I think your app notes would be very well suited for the felix gogo docs. Should I rather link them or directly add them on the felix site?

Christian
--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com

Peter Kriens

unread,
Mar 27, 2017, 12:08:22 PM3/27/17
to bndtool...@googlegroups.com
I would prefer linking … but since it is ASL you’re free to copy it of course.

Kind regards,

Peter Kriens
Reply all
Reply to author
Forward
0 new messages