karaf-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steinar Bang ...@dod.no>
Subject Re: What's the current model for console commands?
Date Tue, 18 Jul 2017 15:50:51 GMT
>>>>> Jean-Baptiste Onofré <jb@nanthrax.net>:

> Hi Steinar,
> you can take a look on the documentation:

> http://karaf.apache.org/manual/latest/#_console_3

Thanks!

The HelloShellCommand sample seems easy to follow.

I've now also read the javadoc here:
 https://github.com/apache/karaf/blob/master/shell/core/src/main/java/org/apache/karaf/shell/api/action/Action.java#L21

In short:
 1. Implement the Action interface in a class with a no-argument constructor
 2. Annotate the implementation with @Command
 3. Annotate the implementation with @Service
 4. Create fields for the OSGi services needed and annotate these fields
    with @Reference

Karaf will then instantiate the class as needed and provide the OSGi
services (so there is no need to mess around with singletons).

> Especially the "By hand" section which is up to date.


> You will see the annotations from the new Shell API, including the
> @Service "new" one.

> As a complete example, you can take a look on any Karaf internal commands.

Ok, thanks.  I will try just the simple approach first. :-)


Mime
View raw message