This example shows how to create a shell command.
It provides a very simple command, calling a BookingService.
- karaf-command-example-api is a common bundle providing the
BookingPOJO and theBookingServiceinterface. - karaf-command-example-provider is a very simple Karaf bundle providing
BookingServiceimplementation. - karaf-command-example-command is the actual bundle providing the Karaf shell command.
- karaf-command-example-features provides a Karaf features repository used for the deployment.
The build uses Apache Maven. Simply use:
mvn clean install
On a running Karaf instance, register the features repository:
karaf@root()> feature:repo-add mvn:org.apache.karaf.examples/karaf-command-example-features/LATEST/xml
Then, you can install the service provider feature:
karaf@root()> feature:install karaf-command-example-provider
The shell commands can be installed with the corresponding feature:
karaf@root()> feature:install karaf-command-example
Once you have installed the feature, you can see new commands available in the Apache Karaf shell.
booking:add command adds a new booking in the booking service. For instance:
karaf@root()> booking:add AF520 Doe
booking:list command lists the current bookings:
karaf@root()> booking:list
ID β Flight β Customer
βββββββββΌβββββββββΌβββββββββ
2226065 β AF520 β Doe
booking:remove command removes a booking from the booking service:
karaf@root()> booking:remove 2226065