Osgi bundle 使用JBoss Fuse Fabric发布和访问OSGI服务

Osgi bundle 使用JBoss Fuse Fabric发布和访问OSGI服务,osgi-bundle,jbossfuse,fusefabric,Osgi Bundle,Jbossfuse,Fusefabric,我在jboss fuse fabric上公开并部署了一个OSGi服务。 现在,我需要从部署在jboss fuse fabric中另一个容器上的另一个包访问此服务。但在客户端容器中无法访问该服务。 jboss保险丝V6.3 当我在fuse fabric中的同一容器中部署OSGi service bundle和client bundle时,它可以工作,但当我在中的不同容器中部署时,它不工作并显示错误: 无法启动捆绑包com.osgi.app.bean-camel-client10/1.0.0的blu

我在jboss fuse fabric上公开并部署了一个OSGi服务。 现在,我需要从部署在jboss fuse fabric中另一个容器上的另一个包访问此服务。但在客户端容器中无法访问该服务。 jboss保险丝V6.3

当我在fuse fabric中的同一容器中部署OSGi service bundle和client bundle时,它可以工作,但当我在中的不同容器中部署时,它不工作并显示错误: 无法启动捆绑包com.osgi.app.bean-camel-client10/1.0.0的blueprint容器,因为无法解析依赖项[(objectClass=org.fusesource.example.service.HelloWorldSvc)]

在客户端:

POM.xml:

<dependency>
    <groupId>com.osgi.app</groupId>
    <artifactId>bean-app-service1</artifactId>
    <version>1.0</version>
</dependency>

com.osgi.app
bean-app-service1
1
config.xml:

<reference id="helloWorld"
    interface="org.fusesource.example.service.HelloWorldSvc"/>
<camelContext xmlns="http://camel.apache.org/schema/blueprint" >
<route>
  <from uri="timer:foo?period=5000"/>
  <to uri="bean:org.fusesource.example.service.HelloWorldSvc?method=sayHello"/>

  <log message="The message contains: ${body}"/>
 </route>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
         http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
         http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<bean id="hello" class="org.fusesource.example.service.impl.HelloWorldSvcImpl"/>

 <service ref="hello" interface="org.fusesource.example.service.HelloWorldSvc"/>
 </blueprint>

内部服务提供商:

pom.xml:

<groupId>com.osgi.app</groupId>
<artifactId>bean-app-service2</artifactId>
<version>1.0</version>
<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <version>${version.maven-bundle-plugin}</version>
    <extensions>true</extensions>
    <configuration>
      <instructions>
        <Bundle-SymbolicName>${pom.groupId}.${pom.artifactId}</Bundle-SymbolicName>
        <Export-Package>org.fusesource.example.service</Export-Package>
      </instructions>
    </configuration>
  </plugin>
com.osgi.app
bean-app-service2
1
org.apache.felix
maven捆绑插件
${version.maven bundle plugin}
真的
${pom.groupId}.${pom.artifactId}
org.fusesource.example.service
config.xml:

<reference id="helloWorld"
    interface="org.fusesource.example.service.HelloWorldSvc"/>
<camelContext xmlns="http://camel.apache.org/schema/blueprint" >
<route>
  <from uri="timer:foo?period=5000"/>
  <to uri="bean:org.fusesource.example.service.HelloWorldSvc?method=sayHello"/>

  <log message="The message contains: ${body}"/>
 </route>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
         http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
         http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<bean id="hello" class="org.fusesource.example.service.impl.HelloWorldSvcImpl"/>

 <service ref="hello" interface="org.fusesource.example.service.HelloWorldSvc"/>
 </blueprint>

如何通过驼峰上下文访问部署在fuse fabric中另一个容器中的服务?


确切的意思是:调用
BundleContext.registerService(“org.fusesource.example.service.HelloWorldSvc”,对象,属性

注册后,您在本地OSGi注册中心注册了一个服务,该注册中心的作用域是JVM的单个实例,这并不意味着要在不同的JVM中访问该服务

如果希望服务在不同的JVM(=在不同的OSGi注册表中)中可用,则需要某种远程处理—尝试使用CXF端点或远程处理camel组件之一(camel-CXF、camel-rest等)