Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
176 views
in Technique[技术] by (71.8m points)

Set the bundle version and start level when deploying camel route as XML in deploy folder of ServiceMix

When deploying bundle in the "deploy" folder in ServiceMix, I am wondering if it is possible to set the bundle version in the blueprint XML.

Example of Camel route (blueprint 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>

And when deployed, the list in the smx console shows:

[1233] [Active     ] [Created     ] [       ] [   80] country-route-dev.xml (0.0.0)

I would like to know if it's also possible to change the start level which is defaulted to 80.

question from:https://stackoverflow.com/questions/65893553/set-the-bundle-version-and-start-level-when-deploying-camel-route-as-xml-in-depl

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It probably won't be the most convenient solution, but :

You can create a Maven project with such structure

src
- main
- - resources
- - - OSGI-INF 
- - - - blueprint
- - - - -  blueprint.xml
pom.xml

Necessarily:

<packaging>bundle</packaging>

In the pom.xml you can set all the bundle parameters you need:

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

Build your bundle and get the jar file for deployment

The level of the bundle is started, you can define in the config.properties

#
# Definition of the default bundle start level
#
org.osgi.framework.startlevel.beginning=100
karaf.startlevel.bundle=80

Also you can create feature for your bundle and reset start level:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...