Is Apache Aries running in Felix?

社会主义新天地 提交于 2020-01-13 07:00:28

问题


I'm trying to build a Blueprint bundle to run in Apache Felix. I tried to make it running but I didn't succeed. The blueprint bundle works fine in Karaf but not in Felix. Is it any documentation or a running example on the web to explain how to run a Blueprint bundle only with plain Felix. I suppose I have to manually add Aries to Felix platform but it didn't seem to work.

To be more precise, I want a simple service to see that it's loaded from a blueprint.xml XML config file as a Blueprint bundle. The service may have only one dummy method or even just a constructor with a println in it. That service class I want to refer it in OSGI-INF/blueprint/blueprint.xml so it will be loaded when the Blueprint bundle is loaded by Felix.


回答1:


After spending some time trying to solve this problem I found the solution. So, you need the following bundles to be installed into your Felix (tested with v.4.4.1) in order to make Aries Blueprint running:

  • org.apache.aries.blueprint : org.apache.aries.blueprint : 1.1.0
  • org.apache.aries : org.apache.aries.util : 1.1.0
  • org.apache.aries.proxy : org.apache.aries.proxy : 1.0.1
  • org.apache.felix : org.apache.felix.configadmin : 1.8.0
  • one implementation of SLF4J (in this case will be PAX Logging):
    • org.ops4j.pax.logging : pax-logging-api : 1.4
    • org.ops4j.pax.logging : pax-logging-service : 1.4 (you may exclude log4j : log4j because is not needed)

These jars will enable Aries Blueprint in Felix (but only the XML configuration version). If you want to use annotations, you have to add also annotation related Jars.

Here is a pom to ease your work. Just run it and all the jar needed to be installed in felix will be in your target folder.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.apache.aries</groupId>
    <artifactId>blueprint-felix-assembly</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>Blueprint Felix Jar Assembly</name>
    <packaging>pom</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <pax.logging.version>1.4</pax.logging.version>
        <aries.version>1.1.0</aries.version>
        <aries.proxy.version>1.0.1</aries.proxy.version>
        <felix.config.admin.version>1.8.0</felix.config.admin.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.configadmin</artifactId>
            <version>${felix.config.admin.version}</version>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.logging</groupId>
            <artifactId>pax-logging-api</artifactId>
            <version>${pax.logging.version}</version>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.logging</groupId>
            <artifactId>pax-logging-service</artifactId>
            <version>${pax.logging.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.aries.blueprint</groupId>
            <artifactId>org.apache.aries.blueprint</artifactId>
            <version>${aries.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.aries</groupId>
            <artifactId>org.apache.aries.util</artifactId>
            <version>${aries.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.aries.proxy</groupId>
            <artifactId>org.apache.aries.proxy</artifactId>
            <version>${aries.proxy.version}</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <excludeTransitive>true</excludeTransitive>
                            <outputDirectory>${project.build.directory}</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>



回答2:


Aries should run very well on Apache Felix it does not require Apache Karaf to run. In fact we are using plain equinox for our integration tests.

You can take a look at the integration test base class to see which bundles you need.



来源:https://stackoverflow.com/questions/24938214/is-apache-aries-running-in-felix

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!