Programmatically Start OSGi (Equinox)?

前端 未结 3 1890
野性不改
野性不改 2020-11-28 04:39

I\'d like to be able to easily start an OSGi framework (preferably Equinox) and load up any bundles listed in my pom from a java main.

Is this possible? If so, how?

3条回答
  •  生来不讨喜
    2020-11-28 05:04

    This thread might be a bit stale, but anyway...

    Pax has excellent support for maven urls, it even has a wrap url handler allowing you to dynamically convert non-osgi jar to nice tidy bundles.

    http://wiki.ops4j.org/display/paxurl/Mvn+Protocol

        
            org.ops4j.pax.url
            pax-url-wrap
            1.2.5        
        
        
            org.ops4j.pax.url
            pax-url-mvn
            1.2.5        
        
    

    The command would then be:

    install -s mvn:groupId:artifactId:version:classifier
    

    Note: chicken-egg scenario - you have to install these using a file: url handler first or put them into an autodeploy directory.

    Karaf has this all build in to it's distro, so maybe have a look at Karaf launcher source?

    2nd note: deploying snapshots are enable by appending @snapshots to the repo URL, configuration is managed via ConfigAdmin

    In terms of managing all your POM defined dependencies have a look at Karaf features - there's a plugin that would enable to generate a features XML file which can then be used to deploy your entire app: http://karaf.apache.org/manual/2.1.99-SNAPSHOT/developers-guide/features-maven-plugin.html

    Further more this XML artifact can be deployed to your OBR, so you can take a vanilla Felix/Equinox/Karaf setup, add the mvn url handler and configure with your company's mvn repo then provision the entire app =)

提交回复
热议问题