By the way, the karaf service maven plugin can update the MANIFEST for you, no
need to do it by hand.
Regards
JB
On 07/18/2017 11:33 PM, Steinar Bang wrote:
Steinar Bang <[email protected]>:
Jean-Baptiste Onofré <[email protected]>:
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).
Forgot one thing:
5. Add a Karaf-Commands manifest header:
http://karaf.apache.org/manual/latest/#_manifest
But after that it worked like a charm.
https://github.com/steinarb/ukelonn/blob/work/use-liquibase/ukelonn.bundle/src/main/java/no/priv/bang/ukelonn/impl/KarafReleaseLiquibaseLockCommand.java
--
Jean-Baptiste Onofré
[email protected]
http://blog.nanthrax.net
Talend - http://www.talend.com