我有几个软件包(A,B和C)部署到OSGi容器,每个包含一个CamelContext和一些路由.我有另一个包(M),CamelContext带有一个路由(用于收集监控数据)和一个InterceptStrategybean.我希望InterceptStrategyM中的bean自动应用于CamelContext容器中的所有其他s(即A,B和C中的那些),而不必修改其他bundle.
最终,目标是将每个数据从CamelContextM中窃听到路线中,而不必对A,B或C进行任何更改以明确路由Exchange.这种方法或类似的方法是否可行?
所有CamelContexts都是使用Spring XML配置的.
更新:附加上下文
捆绑包A,B和C包含负责处理数据的核心产品.Bundle M包含一个可选的监控工具,用于测量流经A,B和C的数据的某些参数.目前,添加可选工具需要更改A,B和C中的路由以添加额外的Processors来丰富Exchange使用监控数据并在<to />端点之前读取监控数据.
目标是能够将Bundle M放入已经过验证的A,B和C系统; 并使其自动应用于现有路由,而无需修改现有和工作捆绑包的配置.这是可以接受的进行修改,以A,B和C,以支持这一点,只要改变不会导致A,B和C依靠M上运行(即ABC仍然必须运行不M).
如果有比使用拦截器更好的方法,我对此持开放态度.主要目标是:
更新2:由于我的博客有点死,链接降级,所以你可以在这里查看文章:
我有一个maven项目,使用我的POM.XML中配置的非常有名的felix maven bundle插件,方法如下:
<packaging>bundle</packaging>
(...)
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId};singleton:=true</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
<Export-Package>jlifx.*</Export-Package>
<!-- <Embed-Dependency>*</Embed-Dependency> -->
</instructions>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
然后我的POM中也包含一些1级/级别的依赖项:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>5.0.0.Alpha1</version>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
现在我的问题开始了...如果我做mvn安装我将使用它非常棒的MANIFEST.MF和我所有的,但我不会得到其他依赖捆绑包,这意味着如果我抓住我的捆绑文件并将其放在我的OSGi框架实例上我会得到类似"无法解决1.0:缺少需求[1.0] osgi.wiring.package;(&(osgi.wiring.package = etc ......")
因此,我发现创建我的第一级依赖项包的一种方法是在我的POM中创建一个配置文件,如下所示:
<profiles>
<!-- http://www.lucamasini.net/Home/osgi-with-felix/creating-osgi-bundles-of-your-maven-dependencies -->
<!-- -Pcreate-osgi-bundles-from-dependencies bundle:wrap -->
<profile>
<id>create-osgi-bundles-from-dependencies</id>
<build>
<directory>${basedir}/bundles</directory>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId> …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用apache maven创建一个包.当我运行mvn clean install命令时,它给出了以下错误:
javax.servlet缺少dependencies.dependency.version':servlet-api.jar
我把'servlet-api.jar'放在我项目的资源文件夹中
任何人都可以告诉我应该在哪里放置该jar文件?
更新:这是我的pom.xml
<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">
<parent>
<artifactId>felix-parent</artifactId>
<groupId>org.apache.felix</groupId>
<version>2.1</version>
<relativePath>../pom/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.4.1-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<name>Maven Bundle Plugin</name>
<description>
Provides a maven plugin that supports creating an OSGi bundle
from the contents of the compilation classpath along with its
resources and dependencies. Plus a zillion other features.
The plugin uses the Bnd tool (http://www.aqute.biz/Code/Bnd)
</description>
<scm>
<connection>scm:svn:http://svn.apache.org/repos/asf/felix/trunk/bundleplugin</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/felix/trunk/bundleplugin</developerConnection>
<url>http://svn.apache.org/repos/asf/felix/trunk/bundleplugin</url>
</scm>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin> …Run Code Online (Sandbox Code Playgroud) 我决定在OSGI和Karaf之上构建一个应用程序 - 我真的很喜欢这个东西.但是,我在本地开发机器上进行日常部署时遇到了一些困难.我的意思是..我做了一个改变,然后我想在我当地的Karaf实例上进行测试.它可能发生在每小时几次.
我现在这样做的方式是创建一个JAR包的maven构建,然后将其复制到Karaf的deploy目录中.我认为它根本不优雅.
我试图寻找一种方法(谷歌).我读到了Karaf的功能,但似乎尽管它是一个很好的机制来部署整个应用程序,但它并没有解决我的问题.据我所知,它不会检查我的SNAPSHOT jar的新版本是否出现在我当地的maven回购中,对吗?
我正试图在eclipse中创建一个简单的插件.当我运行应用程序时,我在日志文件中看到此错误:
org.osgi.framework.BundleException:bundle org.xy的bundle org.xyActivator的激活器无效.
你对这个错误有任何想法吗?
我试图了解OSGI包中Bundle-Classpath的预期用例.
以下是我的理解,请帮助我理解这是否正确.
假设我正在创建一个OSGI捆绑包,该捆绑包将部署在其他捆绑包的生态系统中.我正在处理的捆绑包需要一些其他捆绑包,但它们不会在这个生态系统中加载/导出,而且我无法控制生态系统的输出.在这种情况下,我可以将这些包放在某个目录(比如'lib')中,这些目录成为我的捆绑包的一部分.这些包也应该从Bundle-Classpath引用,因此可以加载它们.
当你想选择比微服务OSGI模块有什么我可以用微服务做,我不能与OSGI的模块呢?
是否可以将非osgi库与OSGi应用程序一起使用?
举个例子,我正在开发一个基于语义的搜索引擎,我正在使用第三方自然语言处理库(http://wiki.opencog.org/w/RelEx_Dependency_Relationship_Extractor).
是否有可能将这样一个不支持OSGi的库作为几个jar文件与我的OSGi应用程序接口?
我正在使用maven-bundle-plugin(bnd有效)。
从源中包含资源文件很简单。
例如,在构建期间将资源文件 ( src/main/resources/some.xml) 移动到target目录 ( target/classes/some.xml)下,可以使用以下<Include-Resource>指令将其包含到包中:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.0.1</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Include-Resource>
some.xml=target/classes/some.xml,
</Include-Resource>
</instructions>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
让我们有一个依赖:
<dependency>
<groupId>com.example</groupId>
<artifactId>library</artifactId>
<version>1.0.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
如何在依赖中引用资源文件jar?
换句话说,如何
指定如下内容:
com.example:library:1.0.0:jar/some.xml
Run Code Online (Sandbox Code Playgroud)而不是这个:
target/classes/some.xml
Run Code Online (Sandbox Code Playgroud)所以来自依赖项之一的资源出现在输出包中jar?
osgi-bundle ×10
osgi ×9
java ×6
maven ×2
apache-camel ×1
apache-karaf ×1
bnd ×1
dependencies ×1
eclipse ×1
integration ×1
interceptor ×1
jar ×1
karaf ×1
maven-2 ×1