Red Hat Training

A Red Hat training course is available for Red Hat Fuse

8.2. Deploying a Feature


You can deploy a feature in one of the following ways:
  • Install at the console, using features:install.
  • Use hot deployment.
  • Modify the boot configuration (first boot only!).

Installing at the console

After you have created a feature (by adding an entry for it in a feature repository and registering the feature repository), it is relatively easy to deploy the feature using the features:install console command. For example, to deploy the example-camel-bundle feature, enter the following pair of console commands:
JBossFuse:karaf@root> features:refreshUrl
JBossFuse:karaf@root> features:install example-camel-bundle
It is recommended that you invoke the features:refreshUrl command before calling features:install, in case any recent changes were made to the features in the feature repository which the kernel has not picked up yet. The features:install command takes the feature name as its argument (and, optionally, the feature version as its second argument).
Features use a flat namespace. So when naming your features, be careful to avoid name clashes with existing features.

Uninstalling at the console

To uninstall a feature, invoke the features:uninstall command as follows:
JBossFuse:karaf@root> features:uninstall example-camel-bundle
After uninstalling, the feature will still be visible when you invoke features:list, but its status will now be flagged as [uninstalled].

Hot deployment

You can hot deploy all of the features in a feature repository simply by copying the feature repository file into the InstallDir/deploy directory.
As it is unlikely that you would want to hot deploy an entire feature repository at once, it is often more convenient to define a reduced feature repository or feature descriptor, which references only those features you want to deploy. The feature descriptor has exactly the same syntax as a feature repository, but it is written in a different style. The difference is that a feature descriptor consists only of references to existing features from a feature repository.
For example, you could define a feature descriptor to load the example-camel-bundle feature as follows:
<?xml version="1.0" encoding="UTF-8"?>
<features name="CustomDescriptor">
  <feature name="hot-example-camel-bundle">
The repository element specifies the location of the custom feature repository, RepositoryURL (where you can use any of the URL formats described in Appendix A, URL Handlers). The feature, hot-example-camel-bundle, is just a reference to the existing feature, example-camel-bundle.

Adding a feature to the boot configuration

If you want to provision copies of Apache Karaf for deployment on multiple hosts, you might be interested in adding a feature to the boot configuration, which determines the collection of features that are installed when Apache Karaf boots up for the very first time.
The configuration file, /etc/org.apache.felix.karaf.features.cfg, in your install directory contains the following settings:
# Comma separated list of features repositories to register by default

# Comma separated list of features to install at startup

# Will put these back in when we decide to include these components
# servicemix-smpp,servicemix-snmp,servicemix-vfs,

This configuration file has two properties:
  • featuresRepositories—Comma separated list of feature repositories to load at startup.
  • featuresBoot—Comma separated list of features to install at startup.
You can modify the configuration to customize the features that are installed as JBoss Fuse starts up. You can also modify this configuration file, if you plan to distribute JBoss Fuse with pre-installed features.
This method of adding a feature is only effective the first time a particular Apache Karaf instance boots up. Any changes made subsequently to the featuresRepositories setting and the featuresBoot setting are ignored, even if you restart the container.
You could force the container to revert back to its initial state, however, by deleting the complete contents of the InstallDir/data/cache (thereby losing all of the container's custom settings).