このコンテンツは選択した言語では利用できません。
Chapter 4. Hot deployment vs manual deployment
Abstract
Fuse provides two different approaches for deploying files: hot deployment or manual deployment. If you need to deploy a collection of related bundles it is recommended that you deploy them together as a feature, rather than singly (see Chapter 7, Deploying Features).
4.1. Hot Deployment
4.1.1. Hot deploy directory
Fuse monitors files in the FUSE_HOME/deploy
directory and hot deploys everything in this directory. Each time a file is copied to this directory, it is installed in the runtime and started. You can subsequently update or delete the files in the FUSE_HOME/deploy
directory, and the changes are handled automatically.
For example, if you have just built the bundle, ProjectDir/target/foo-1.0-SNAPSHOT.jar
, you can deploy this bundle by copying it to the FUSE_HOME/deploy
directory as follows (assuming you are working on a UNIX platform):
% cp ProjectDir/target/foo-1.0-SNAPSHOT.jar FUSE_HOME/deploy
4.2. Hot undeploying a bundle
To undeploy a bundle from the hot deploy directory, simply delete the bundle file from the FUSE_HOME/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 bundle file from FUSE_HOME/deploy
directory, and then restart the Karaf container, the bundle will not be undeployed after you restart the container.
You can also undeploy a bundle by using the bundle:uninstall
console command.
4.3. Manual Deployment
4.3.1. Overview
You can manually deploy and undeploy bundles by issuing commands at the Fuse console.
4.3.2. Installing a bundle
Use the bundle:install
command to install one or more bundles in the OSGi container. This command has the following syntax:
bundle:install [-s] [--start] [--help] UrlList
Where UrlList is a whitespace-separated list of URLs that specify the location of each bundle to deploy. The following command arguments are supported:
-s
- Start the bundle after installing.
--start
-
Same as
-s
. --help
- Show and explain the command syntax.
For example, to install and start the bundle, ProjectDir/target/foo-1.0-SNAPSHOT.jar
, enter the following command at the Karaf console prompt:
bundle:install -s file:ProjectDir/target/foo-1.0-SNAPSHOT.jar
On Windows platforms, you must be careful to use the correct syntax for the file
URL in this command. See Section 12.1, “File URL Handler” for details.
4.3.3. Uninstalling a bundle
To uninstall a bundle, you must first obtain its bundle ID using the bundle:list
command. You can then uninstall the bundle using the bundle:uninstall
command (which takes the bundle ID as its argument).
For example, if you have already installed the bundle named A Camel OSGi Service Unit
, entering bundle:list
at the console prompt might produce output like the following:
... [ 181] [Resolved ] [ ] [ ] [ 60] A Camel OSGi Service Unit (1.0.0.SNAPSHOT)
You can now uninstall the bundle with the ID, 181
, by entering the following console command:
bundle:uninstall 181
4.3.4. URL schemes for locating bundles
When specifying the location URL to the bundle:install
command, you can use any of the URL schemes supported by Fuse, which includes the following scheme types:
4.4. Redeploying bundles automatically using bundle:watch
In a development environment—where a developer is constantly changing and rebuilding a bundle—it is typically necessary to re-install the bundle multiple times. Using the bundle:watch
command, you can instruct Karaf to monitor your local Maven repository and re-install a particular bundle automatically, as soon as it changes in your local Maven repository.
For example, given a particular bundle—with bundle ID, 751
—you can enable automatic redeployment by entering the command:
bundle:watch 751
Now, whenever you rebuild and install the Maven artifact into your local Maven repository (for example, by executing mvn install
in your Maven project), the Karaf container automatically re-installs the changed Maven artifact. For more details, see Apache Karaf Console Reference.
Using the bundle:watch
command is intended for a development environment only. It is not recommended for use in a production environment.