Red Hat Training

A Red Hat training course is available for Red Hat Fuse

2.2. Hot Deployment

Types of configuration file

You can hot deploy the following types of configuration file:
  • Spring XML file, deployable with the suffix, .xml.
  • Blueprint XML file, deployable with the suffix, .xml.

Hot deploy directory

If you have an existing Spring XML or blueprint XML configuration file, you can deploy the configuration file directly by copying it into the following hot deploy directory:
InstallDir/deploy
After deploying, the configuration file is activated immediately.

Hot undeploying an XML file

To undeploy a Spring XML file or a Blueprint XML file from the hot deploy directory, simply delete the XML file from the InstallDir/deploy directory while the Apache Karaf container is running.
Important
The hot undeploy mechanism does not work while the container is shut down. If you shut down the Karaf container, delete the XML file from deploy/, and then restart the Karaf container, the automatically generated bundle corresponding to the XML file will not be undeployed after you restart the container (you can, however, undeploy the bundle manually using the osgi:uninstall console command).

Prerequisites

If you want to deploy Apache Camel routes in a blueprint configuration file, the camel-blueprint feature must be installed (which it is by default). If the camel-blueprint feature has been disabled, however, you can re-install it by entering the following console command:
JBossFuse:karaf@root> features:install camel-blueprint

Default bundle version

When a Spring XML file or a Blueprint XML file is hot deployed, the XML file is automatically wrapped in an OSGi bundle and deployed as a bundle in the OSGi container. By default, the generated bundle has the version, 0.0.0.

Customizing the bundle version

If you prefer to customize the bundle version, use the manifest element in the XML file. The manifest element enables you to override any of the headers in the generated bundle's META-INF/MANIFEST.MF file. In particular, you can use it to specify the bundle version.

Specifying the bundle version in a Spring XML file

To specify the bundle version in a hot-deployed Spring XML file, define a manifest element as follows:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       >

  <manifest xmlns="http://karaf.apache.org/xmlns/deployer/spring/v1.0.0">
      Bundle-Version = 1.2.3.4
  </manifest>

  <camelContext xmlns="http://camel.apache.org/schema/spring">
    <route>
      <from uri="timer://myTimer?fixedRate=true&amp;period=2000"/>
      <to uri="log:ExampleRouter"/>
    </route>
  </camelContext>

</beans>
The manifest element for Spring XML files belongs to the following schema namespace:
http://karaf.apache.org/xmlns/deployer/spring/v1.0.0
The contents of the manifest element are specified using the syntax of a Java properties file.

Specifying the bundle version in a Blueprint XML file

To specify the bundle version in a hot-deployed Blueprint XML file, define a manifest element as follows:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    >

  <manifest xmlns="http://karaf.apache.org/xmlns/deployer/blueprint/v1.0.0">
      Bundle-Version = 1.2.3.4
  </manifest>

  <camelContext xmlns="http://camel.apache.org/schema/blueprint">
    <route>
      <from uri="timer://myTimer?fixedRate=true&amp;period=2000"/>
      <to uri="log:ExampleRouter"/>
    </route>
  </camelContext>

</blueprint>
The manifest element for Blueprint XML files belongs to the following schema namespace:
http://karaf.apache.org/xmlns/deployer/blueprint/v1.0.0
The contents of the manifest element are specified using the syntax of a Java properties file.