Skip to content
Branch: master
Find file History
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
karaf-rest-example-api Update version to 4.3.0-SNAPSHOT Feb 11, 2019
karaf-rest-example-client Update version to 4.3.0-SNAPSHOT Feb 11, 2019
karaf-rest-example-features
karaf-rest-example-provider Update version to 4.3.0-SNAPSHOT Feb 11, 2019
karaf-rest-example-whiteboard
README.md
pom.xml Update version to 4.3.0-SNAPSHOT Feb 11, 2019

README.md

Apache Karaf REST Example

Abstract

This example shows how to use JAX-RS to implement a REST service.

This example uses blueprint to deal with the jaxrs-server and Apache CXF as the implementation of the JAXRS specification.

It implements a BookingService with a REST implementation.

The "client" bundle uses the BookingService with a REST client stub.

Artifacts

  • karaf-rest-example-api is a common bundle containing the Booking POJO and the BookingService interface.
  • karaf-rest-example-provider is a blueprint bundle providing the BookingServiceRest implementation of the BookingService interface.
  • karaf-rest-example-client is a regular Blueprint bundle using the BookingService.
  • karaf-rest-example-client-http is a regular Blueprint REST client bundle using Java Http.
  • karaf-rest-example-client-cxf is a regular Blueprint REST client bundle using Apache CXF.
  • karaf-rest-example-features provides a Karaf features repository used for the deployment.

Build

The build uses Apache Maven. Simply use:

mvn clean install

Feature and Deployment

On a running Karaf instance, register the features repository using:

karaf@root()> feature:repo-add mvn:org.apache.karaf.examples/karaf-rest-example-features/LATEST/xml

Then, you can install the service provider feature:

karaf@root()> feature:install karaf-rest-example-provider

And the service client feature using Java Http:

karaf@root()> feature:install karaf-rest-example-client-http

The karaf-rest-example-client-http feature provides booking:* commands you can use to call the REST service.

And the service client feature using Apache CXF:

karaf@root()> feature:install karaf-rest-example-client-cxf

The karaf-rest-example-client-cxf feature provides booking:* commands you can use to call the REST service.

Usage

Once you have install a client feature, you can use booking:add and booking:list commands to interact with the REST service.

karaf@root()> booking:add 1 "John Doe" AF520
karaf@root()> booking:list
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.