Este contenido no está disponible en el idioma seleccionado.
Chapter 10. Deploying a Feature
10.1. Overview
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!).
10.2. 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.
10.3. 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]
.
10.4. 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"> <repository>RepositoryURL</repository> <feature name="hot-example-camel-bundle"> <feature>example-camel-bundle</feature> </feature> </features>
The repository element specifies the location of the custom feature repository, RepositoryURL (where you can use any of the URL formats described in Chapter 15, URL Handlers). The feature, hot-example-camel-bundle
, is just a reference to the existing feature, example-camel-bundle
.
10.5. Hot undeploying a features file
To undeploy a features file from the hot deploy directory, simply delete the features file from the InstallDir/deploy
directory while the Apache Karaf container is running.
The hot undeploy mechanism does not work while the container is shut down. If you shut down the Karaf container, delete the features file from deploy/
, and then restart the Karaf container, the features will not be undeployed after you restart the container (you can, however, undeploy the features manually using the features:uninstall
console command).
10.6. 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.karaf.features.cfg
, in your install directory contains the following settings:
... # # Comma separated list of features repositories to register by default # featuresRepositories = \ mvn:org.apache-extras.camel-extra.karaf/camel-extra/2.21.0.fuse-000032-redhat-2/xml/features, \ mvn:org.apache.karaf.features/spring-legacy/4.2.0.fuse-000191-redhat-1/xml/features, \ mvn:org.apache.activemq/artemis-features/2.4.0.amq-710008-redhat-1/xml/features, \ mvn:org.jboss.fuse.modules.patch/patch-features/7.0.0.fuse-000163-redhat-2/xml/features, \ mvn:org.apache.karaf.features/framework/4.2.0.fuse-000191-redhat-1/xml/features, \ mvn:org.jboss.fuse/fuse-karaf-framework/7.0.0.fuse-000163-redhat-2/xml/features, \ mvn:org.apache.karaf.features/standard/4.2.0.fuse-000191-redhat-1/xml/features, \ mvn:org.apache.karaf.features/enterprise/4.2.0.fuse-000191-redhat-1/xml/features, \ mvn:org.apache.camel.karaf/apache-camel/2.21.0.fuse-000055-redhat-2/xml/features, \ mvn:org.apache.cxf.karaf/apache-cxf/3.1.11.fuse-000199-redhat-1/xml/features, \ mvn:io.hawt/hawtio-karaf/2.0.0.fuse-000145-redhat-1/xml/features # # Comma separated list of features to install at startup # featuresBoot = \ instance/4.2.0.fuse-000191-redhat-1, \ cxf-commands/3.1.11.fuse-000199-redhat-1, \ log/4.2.0.fuse-000191-redhat-1, \ pax-cdi-weld/1.0.0, \ camel-jms/2.21.0.fuse-000055-redhat-2, \ ssh/4.2.0.fuse-000191-redhat-1, \ camel-cxf/2.21.0.fuse-000055-redhat-2, \ aries-blueprint/4.2.0.fuse-000191-redhat-1, \ cxf/3.1.11.fuse-000199-redhat-1, \ cxf-http-undertow/3.1.11.fuse-000199-redhat-1, \ pax-jdbc-pool-narayana/1.2.0, \ patch/7.0.0.fuse-000163-redhat-2, \ cxf-rs-description-swagger2/3.1.11.fuse-000199-redhat-1, \ feature/4.2.0.fuse-000191-redhat-1, \ camel/2.21.0.fuse-000055-redhat-2, \ jaas/4.2.0.fuse-000191-redhat-1, \ camel-jaxb/2.21.0.fuse-000055-redhat-2, \ camel-paxlogging/2.21.0.fuse-000055-redhat-2, \ deployer/4.2.0.fuse-000191-redhat-1, \ diagnostic/4.2.0.fuse-000191-redhat-1, \ patch-management/7.0.0.fuse-000163-redhat-2, \ bundle/4.2.0.fuse-000191-redhat-1, \ kar/4.2.0.fuse-000191-redhat-1, \ camel-csv/2.21.0.fuse-000055-redhat-2, \ package/4.2.0.fuse-000191-redhat-1, \ scr/4.2.0.fuse-000191-redhat-1, \ maven/4.2.0.fuse-000191-redhat-1, \ war/4.2.0.fuse-000191-redhat-1, \ camel-mail/2.21.0.fuse-000055-redhat-2, \ fuse-credential-store/7.0.0.fuse-000163-redhat-2, \ framework/4.2.0.fuse-000191-redhat-1, \ system/4.2.0.fuse-000191-redhat-1, \ pax-http-undertow/6.1.2, \ camel-jdbc/2.21.0.fuse-000055-redhat-2, \ shell/4.2.0.fuse-000191-redhat-1, \ management/4.2.0.fuse-000191-redhat-1, \ service/4.2.0.fuse-000191-redhat-1, \ camel-undertow/2.21.0.fuse-000055-redhat-2, \ camel-blueprint/2.21.0.fuse-000055-redhat-2, \ camel-spring/2.21.0.fuse-000055-redhat-2, \ hawtio/2.0.0.fuse-000145-redhat-1, \ camel-ftp/2.21.0.fuse-000055-redhat-2, \ wrap/2.5.4, \ config/4.2.0.fuse-000191-redhat-1, \ transaction-manager-narayana/5.7.2.Final
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 Fuse starts up. You can also modify this configuration file, if you plan to distribute 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).