OSGi 系列(十八)之 基于注解的 Blueprint
OSGi 系列(十八)之 基于注解的 Blueprint
1. 注解实现 blueprint
第一步:bundle 添加 Bundle-Blueprint-Annotation
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.0.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-Blueprint-Annotation>true</Bundle-Blueprint-Annotation>
</instructions>
</configuration>
</plugin>
第二步:karaf 要安装以下 4 个 bundle:
install -s mvn:org.apache.xbean/xbean-bundleutils/3.18
install -s mvn:org.apache.xbean/xbean-finder/3.18
install -s mvn:org.apache.aries.blueprint/org.apache.aries.blueprint.annotation.api/1.0.1
install -s mvn:org.apache.aries.blueprint/org.apache.aries.blueprint.annotation.impl/1.0.1
注意 karaf 4.1.5 上要重启 aries-blueprint:
feature:stop aries-blueprint
feature:start aries-blueprint
或直接在 standard-4.1.5-features.xml 文件中 aries-blueprint 中添加:
<feature name="aries-blueprint" description="Aries Blueprint" version="4.1.5">
<feature>aries-proxy</feature>
<bundle dependency="true" start-level="20">mvn:org.apache.aries/org.apache.aries.util/1.1.3</bundle>
<!-- Making the compatibility bundle a dependency allows it to only be installed on-demand -->
<bundle dependency="true" start-level="20">mvn:org.apache.aries.blueprint/org.apache.aries.blueprint.core.compatibility/1.0.0</bundle>
<!-- 添加 Bundle-Blueprint-Annotation 支持 -->
<bundle start-level="20">mvn:org.apache.xbean/xbean-bundleutils/3.18</bundle>
<bundle start-level="20">mvn:org.apache.xbean/xbean-finder/3.18</bundle>
<bundle start-level="20">mvn:org.apache.aries.blueprint/org.apache.aries.blueprint.annotation.api/1.0.1</bundle>
<bundle start-level="20">mvn:org.apache.aries.blueprint/org.apache.aries.blueprint.annotation.impl/1.0.1</bundle>
<bundle start-level="20">mvn:org.apache.aries.blueprint/org.apache.aries.blueprint.api/1.0.1</bundle>
<bundle start-level="20">mvn:org.apache.aries.blueprint/org.apache.aries.blueprint.cm/1.1.0</bundle>
<bundle start-level="20">mvn:org.apache.aries.blueprint/org.apache.aries.blueprint.core/1.8.3</bundle>
<conditional>
<condition>bundle</condition>
<bundle start-level="30">mvn:org.apache.karaf.bundle/org.apache.karaf.bundle.blueprintstate/4.1.5</bundle>
</conditional>
<capability>
osgi.service;effective:=active;objectClass=org.apache.aries.blueprint.services.ParserService,
osgi.extender; osgi.extender="osgi.blueprint";uses:="org.osgi.service.blueprint.container,org.osgi.service.blueprint.reflect";version:Version="1.0"
</capability>
</feature>