Apache Karaf is an OSGi runtime that runs on top of most OSGi containers like Apache Felix and Eclipse Equinox. jclouds provides easy integration with Apache Karaf by leveraging the Karaf "Feature" concept.
This section will describe how to install jclouds on Apache Karaf and run some examples that demonstrate the power of jclouds in a dynamic environment such as Karaf.
jclouds provides the following Karaf "features":
As of the jclouds Version 1.0.0 release, the jclouds-karaf feature is available on the central maven repository, so you can skip this step of getting the source and building it and go directly to the install of the jclouds feature.
git clone git://github.com/apache/jclouds-karaf.git cd jclouds-karaf mvn clean install
features:addurl mvn:org.jclouds.karaf/feature/1.0/xml/features features:install jclouds
features:list | grep jclouds
The following example demonstrates how using jclouds inside Karaf can make it easy to use jclouds. The example leverages the Karaf shell and the configuration administrator to provide two shell commands that read and write data to a blobstore. The BlobStore provider and the access information can change dynamically, and they may be configured or reconfigured using the OSGi configuration administrator.
The first step is to get and build the example:
git clone https://firstname.lastname@example.org/apache/jclouds-examples.git cd jclouds-examples/blobstore-karaf-shell mvn clean install
Then from Karaf shell you can install the example:
osgi:install -s mvn:org.jclouds.examples/blobstore-karaf-shell/1.0-SNAPSHOT
The command above installs in Karaf two new commands:
In order to use those commands, you first need to configure the provider. The configuration is done using the org.jclouds.blobstore PID. You can create the configuration either from inside the shell or by dropping a file named org.jclouds.blobstore.cfg under karaf's etc folder. Let's see how it can be done using the Karaf shell:
config:edit org.jclouds.blobstore config:propset provider aws-s3 config:propset accessKeyId XXXXXX config:propset secretKey XXXXXX config:update
Now you are ready to use the commands
jclouds:blobstore-write mybucket myblob JCloudsRocks jclouds:blobstore-write mybucket myblob
At any point in time, you can edit the configuration, either using the shell or by editing the configuration file. The commands will pick up the changes immediately. This way you can even switch providers.
Watch the demo video.