搜索

此内容没有您所选择的语言版本。

2.2. Hot Deployment

download PDF

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.
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.