日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ServiceMix中部署:OSGi Bundle和Feature

發(fā)布時間:2024/4/17 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ServiceMix中部署:OSGi Bundle和Feature 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

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 ,查看已經(jīng)安裝的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. 設(shè)置Bundle Start Level

??? Bundle的Start Level是一個正數(shù),Bundle 的啟動級別越低Bundle越優(yōu)先啟動。

??? (1) osgi:bundel-level 60 182 ,設(shè)置Bundle181,182的啟動級別為60。

??? (2) osgi:start-level ,查看系統(tǒng)的Start Level,默認為100; 可通過osgi:start-level 200,設(shè)置為200.

?

部署多個Bundle:

因為許多開源的框架或工具是有多個Bundle組成的,為方便將相關(guān)的Bundle作為一個unit進行部署,

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

1. 創(chuàng)建一個Feature, 按照下面5步進行

??? (1) 創(chuàng)建一個Custom feature repository

????????? 創(chuàng)建目錄:C:\ServiceMix-Features,在該目錄下創(chuàng)建文件: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的子元素。當(dāng)部署

????????? 擁有依賴的feature時,依賴機制將檢查依賴的feature是否已經(jīng)安裝至容器,如果沒有,依賴機制

????????? 將自動安裝丟失的依賴。

????????? <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

???????? 如果應(yīng)用程序使用了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) 安裝

????????? 首先執(zhí)行:features:refreshUrl , 強制FuseESB內(nèi)核重新讀取所有的feature repository;

????????? 其次執(zhí)行 :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, 當(dāng)Karaf第一次啟動時將決定哪些是已經(jīng)安裝的features的集合。可修改安裝

????????? 目錄etc下的org.apache.karaf.features.cfg文件,在該文件中:

????????? featuresRepositories指定在啟動時要加載的feature repository;

????????? featuresBoot指定在啟動時要安裝的feature.

?

與50位技術(shù)專家面對面20年技術(shù)見證,附贈技術(shù)全景圖

總結(jié)

以上是生活随笔為你收集整理的ServiceMix中部署:OSGi Bundle和Feature的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。