http://springsfeng.iteye.com/blog/1392658

ServiceMix中部署:OSGi Bundle和Feature

  • 博客分类:
  • ESB-ServiceMix

部署单个Bundle:

1. Hot Deployment

Copy JAR文件至ServiceMix安装目录下的deploy 目录下即可。

Linux下命令:cp ProjectDir/target/foo-1.0-SNAPSHOT.jar InstallDir/deploy

2. 手动部署

(1) osgi:install , 例如:osgi:install -s file:ProjectDir/target/foo-1.0-SNAPSHOT.jar

(2) osgi:list ,查看已经安装的Bundle。

(3) osgi:uninstall 181 , Uninstall Bundle 181.

(4) osgi:resolve 181 , 解析Bundle181的依赖是否满足。

(5) osgi:start 181 182 183 , 启动三个Bundle.

(6) osgi:stop 181 182 183 , 停止三个Bundle.

(7) osgi:restart 181 182 183 , 重启三个Bundle.

3. 设置Bundle Start Level

Bundle的Start Level是一个正数,Bundle 的启动级别越低Bundle越优先启动。

(1) osgi:bundel-level 60 182 ,设置Bundle181,182的启动级别为60。

(2) osgi:start-level ,查看系统的Start Level,默认为100; 可通过osgi:start-level 200,设置为200.

部署多个Bundle:

因为许多开源的框架或工具是有多个Bundle组成的,为方便将相关的Bundle作为一个unit进行部署,

FuseESB提供了一个新的部署单元:Feature, 可以在一次部署中部署多个Bundle.

1. 创建一个Feature, 按照下面5步进行

(1) 创建一个Custom feature repository

创建目录:C:\ServiceMix-Features,在该目录下创建文件:features.xml:

<?xml version="1.0" encoding="UTF-8"?>
          <features name="CustomFeatureRepository" >
          </features>

其中name="CustomFeatureRepository"为自定义的,默认为repo-0,与Maven Repository

及OBR相比,Features Repository不提供Bundle的存储,他只提供存储Bundle引用的集合。

(2) 添加一个Feature至Custom feature repository

<?xml version="1.0" encoding="UTF-8"?>
          <features>
               <feature name="example-camel-bundle" version="1.0.0">
                    <bundle>

file:C:/Projects/camel-bundle/target/camel-bundle-1.0-SNAPSHOT.jar

</bundle>
               </feature>
         </features>

验证是否安装成功:features:refreshUrl, features:list 或

features:list | grep example-camel-bundle

(3) 添加Local repository URL to the feature service

features:addUrl C:/ServiceMix-Features/features.xml

features:listUrl

(4) 添加依赖Feature to the feature

如果体格features依赖其他的features,可以添加features元素作为源features的子元素。当部署

拥有依赖的feature时,依赖机制将检查依赖的feature是否已经安装至容器,如果没有,依赖机制

将自动安装丢失的依赖。

<features>
              <feature name="example-camel-bundle">
                  <bundle>

file:C:/Projects/camel-bundle/target/camel-bundle-1.0-SNAPSHOT.jar

</bundle>
                  <feature version="4.4.1-fuse-00-08">camel-core</feature>
                  <feature version="4.4.1-fuse-00-08">camel-springosgi</feature>
                  <feature version="4.4.1-fuse-00-08">servicemixcamel</feature>
              </feature>
         </features>

(5) 添加OSGi configuration to the feature

如果应用程序使用了OSGi Configuration Admin Service,那么可以给feature添加config元素进行

配置,例如下面的例子指定了prefix属性有一个值MyTransform:

<?xml version="1.0" encoding="UTF-8"?>
         <features>
              <feature name="example-camel-bundle">
                   <config name="org.fusesource.fuseesb.example" >
                        prefix=MyTransform
                   </config>
             </feature>
         </features>

下面的列子演示使用上面的配置:

<beans xmlns="http://www.springframework.org/schema/beans"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns:ctx="http://www.springframework.org/schema/context"
               xmlns:osgi="http://camel.apache.org/schema/osgi"
               xmlns:osgix="http://www.springframework.org/schema/osgicompendium"
               ...>
               ...
               <bean id="myTransform" class="org.fusesource.fuseesb.example.MyTransform">
                     <property name="prefix" value="${prefix}"/>
               </bean>
               <osgix:cm-properties id="preProps" persistentid="org.fusesource.fuseesb.example">
                     <prop key="prefix">DefaultValue</prop>
               </osgix:cm-properties>
               <ctx:property-placeholder properties-ref="preProps" />
         </beans>

上述配置中的${prefix}的值为:MyTransform.

2. 部署一个Feature

(1) 安装

首先执行:features:refreshUrl , 强制FuseESB内核重新读取所有的feature repository;

其次执行 :features:install example-camel-bundle

(2) 卸载

卸载feature:features:uninstall example-camel-bundle

卸载feature repository: features:removerepository CustomFeatureRepository

(3) 热部署

Copy Feature repository至ServiceMix安装目录下的deploy目录,热部署时推荐重新定义一个简化的

feature repository:

<?xml version="1.0" encoding="UTF-8"?>
         <features name="CustomDescriptor">
             <repository>C:/ServiceMix-Features/features.xml</repository>
             <feature name="hot-example-camel-bundle">
                  <feature>example-camel-bundle</feature>
             </feature>
         </features>

(4) 添加一个Feature至boot configuration

如果期望提供Apache Karaf的Copy 部署在多个主机上,那么可以添加一个feature至boot

configuration, 当Karaf第一次启动时将决定哪些是已经安装的features的集合。可修改安装

目录etc下的org.apache.karaf.features.cfg文件,在该文件中:

featuresRepositories指定在启动时要加载的feature repository;

featuresBoot指定在启动时要安装的feature.

ServiceMix中部署:OSGi Bundle和Feature相关推荐

  1. Eclipse中安装插件时提示:No repository found containing: osgi.bundle,org.eclipse.emf,2.8.0.v20180706-1146

    场景 在Eclipse中安装ERMaster时提示: No repository found containing: osgi.bundle,org.eclipse.emf,2.8.0.v201807 ...

  2. OSGi Bundle之Hello World

    http://developer.51cto.com/art/200909/152209.htm 本文是<你好,OSGi>系列的第二部分.之前曾介绍过OSGi是什么,下面将继续上篇介绍的内 ...

  3. aws rds监控慢sql_在AWS RDS SQL Server上的SSAS中部署表格数据库

    aws rds监控慢sql In this article, we are going to explore Analysis Service for AWS RDS SQL Server in de ...

  4. No repository found containing: osgi.bundle,org.tigris.subversion.clientadapter.javahl,1.9.3

    在 Eclipse 安装 SVN 插件 subclipse 1.12 时,多次遇到以下问题: p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px ' ...

  5. Android kotlin jetpack compose 在APP中部署运行ktor服务器

    Android kotlin jetpack compose 在APP中部署运行ktor服务器 前言 添加依赖 服务器管理 活动 效果 DEMO 完事 前言 遇到需求,需要在APP中部署一个服务器,局 ...

  6. 通过带Flask的REST API在Python中部署PyTorch

    通过带Flask的REST API在Python中部署PyTorch 在本文中,将使用Flask来部署PyTorch模型,并用讲解用于模型推断的 REST API.特别是,将部署一个预训练的Dense ...

  7. OpenCV中的特征匹配(Feature Matching)

    OpenCV中的特征匹配(Feature Matching) 1. 效果图 2. 原理 3. 源码 3.1 SIFT关键点检测+Knn近邻匹配 3.2 ORB关键点检测+蛮力特征匹配 3.3 SIFT ...

  8. 在LINUX中部署NIS服务器

    在LINUX中部署NIS服务器 一.部署前的准备工作:   1.准备两台虚拟机,一台作server,一台作clint.   2.配好网卡,使用相同的网卡.   3.配好ip,ip必须在同一网段.   ...

  9. docker swarm英文文档学习-8-在集群中部署服务

    Deploy services to a swarm在集群中部署服务 集群服务使用声明式模型,这意味着你需要定义服务的所需状态,并依赖Docker来维护该状态.该状态包括以下信息(但不限于): 应该运 ...

最新文章

  1. mysql对数据库的备份和还原
  2. 分布式入门之3:副本控制
  3. Advanced Linq - Dynamic Linq query library: Add support for 'Contains' extension
  4. 1.7编程基础之字符串_04石头剪子布
  5. 【报告分享】2019年12月郭广昌混沌课程ppt(附下载链接)
  6. python和lisp学哪个好_五位专家跟你讲讲为啥Python更适合做AI/机器学习
  7. python和c先学哪个-python和c先学哪个
  8. 讯飞输入法粤语语音识别率达95%支持粤转普
  9. 自学编程这几点非常重要
  10. Atitit.ide代码块折叠插件 eclipse
  11. 《英雄联盟》捞月狗数据初探
  12. reviewboard 介绍
  13. PHP 照片合并视频
  14. t’触发器真值表和状态方程_t触发器(d触发器真值表)
  15. 中国人想在外国卖东西,这些经典网站不能错过
  16. 十五、IO流【黑马JavaSE笔记】(本文文中记录了个人学习感受)
  17. Android 新版支付宝API开发
  18. 微信吸粉技巧:微信群怎么玩?
  19. stream filter 多条件筛选
  20. 企业研发人员配备比例_一般公司职能结构及人员分布比例配备

热门文章

  1. HarmonyOS之AI能力·分词
  2. Jenkins 创建一个freestyle的Job
  3. 10.2.1 CSS介绍与引入
  4. ZYAR20A 亚克力2驱 蓝牙 298寻迹避障机器人 —— 小车红外遥控实验
  5. 【Linux】一步一步学Linux——bind命令(231)
  6. Hibernate框架整合DM数据库
  7. 数据结构-----最大堆的实现
  8. 为什么计算机的编码那么多,为什么中国剩余定理可用于计算机编码?
  9. mongodb与java结合_MongoDB初探系列之四:MongoDB与Java共舞
  10. LVS(9)——为NAT单独增加路由器