问题描述
在ServiceMix的“deploy”文件夹中部署bundle时,我想知道是否可以在蓝图XML中设置bundle版本。
Camel 路线示例(蓝图 xml):
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0" xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0" xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd
http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd">
<cm:property-placeholder persistent-id="my.deploy.route" update-strategy="reload">
<cm:default-properties>
<cm:property name="amq.url" value="tcp://my-amq-host:61616?jms.watchTopicAdvisories=false" />
<cm:property name="tracer.enable" value="false" />
</cm:default-properties>
</cm:property-placeholder>
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<onException uSEOriginalMessage="true">
<exception>java.lang.Exception</exception>
<handled>
<constant>true</constant>
</handled>
<to uri="activemq:queue:SYNCHRO.DLQ" />
</onException>
<route id="route-countries">
<from uri="activemq:queue:SYS.soURCE.COUNTRY" />
<to uri="activemq:queue:OTHER.DESTINATION.COUNTRY" />
</route>
</camelContext>
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="${amq.url}" />
</bean>
</blueprint>
部署后,smx 控制台中的列表显示:
[1233] [Active ] [Created ] [ ] [ 80] country-route-dev.xml (0.0.0)
我想知道是否也可以更改默认为 80 的起始级别。
解决方法
这可能不是最方便的解决方案,但是:
你可以用这样的结构创建一个Maven项目
src
- main
- - resources
- - - OSGI-INF
- - - - blueprint
- - - - - blueprint.xml
pom.xml
必然:
<packaging>bundle</packaging>
在 pom.xml 中你可以设置你需要的所有包参数:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Description>${project.description}</Bundle-Description>
<Bundle-Version>1.0.0</Bundle-Version>
<Import-Package>*</Import-Package>
</instructions>
</configuration>
</plugin>
构建您的包并获取用于部署的 jar 文件
bundle的级别,可以在config.properties中定义
#
# Definition of the default bundle start level
#
org.osgi.framework.startlevel.beginning=100
karaf.startlevel.bundle=80
您还可以为您的捆绑包创建功能并重置开始级别:
<feature name="my-project" version="1.0.0">
<bundle start-level="80" start="false">mvn:com.mycompany.myproject/myproject-dao</bundle>
<bundle start-level="85" start="false">mvn:com.mycompany.myproject/myproject-service</bundle>
</feature>