将 Apache Camel 添加到 Eclipse RCP 应用程序

问题描述 投票:0回答:1

我尝试在 Eclipse RCP 应用程序中添加 Apache Camel 支持。使用新的 Eclipse,我还可以在目标平台文件中添加 Maven 存储库,这就是我所做的。我的目标平台包含:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-core</artifactId>
    <version>4.6.0</version>
    <type>jar</type>
</dependency>

我还检查了 includeDependency 字段以包含所需的依赖项。到目前为止一切都很好,我为camel 项目自动生成了所有 20 个左右的插件。我将它们添加到我的清单文件中,编译工作正常,一切都很好。除了当我尝试启动 Camel 时,我收到一个运行时异常,提示

No language for 'simple' found
(类似的东西,我现在没有确切的 stackstrace)。

问题是这个:

  • simple
    语言位于核心语言模块中
  • core-engine
    模块尝试将
    simple
    语言(来自
    core-languages
    )加载到骆驼上下文中
  • core-engine
    core-languages
    是 2 个不同的插件,因此 Equinox 类加载器将不允许
    core-engine
    查看
    core-languages
    模块内 META-INF 文件夹中的任何文件

我只能想到两种可能的解决方案:

  1. 包含 Apache Camel 作为 jar 依赖项。问题是我在 Maven 中没有看到任何可下载的 Apache Camel 核心 jar。我将不得不克隆存储库并构建我自己的 jar。
  2. 构建一个 Maven 项目,该项目采用所有 Camel 核心依赖项并输出包含依赖项的单个 rcp 插件。对于这个,我不需要克隆 Camel 存储库,但我不能 100% 确定我可以实现这一目标。

对于这两种方法,我认为之后添加另一个 Camel 组件非常麻烦,因为它可能涉及修改我创建的自定义项目以包含新组件(假设

core-engine
需要访问它以将其加载到上下文中)。另外,我不知道如何将 Camel 核心与可选组件分开。

有什么想法可以让 Camel 与 Eclipse RCP 一起使用吗?

您可以在这里找到我的目标平台https://github.com/grozadanut/ro.linic.ui/blob/main/target-platform/target-platform.target

RCP 产品在这里:https://github.com/grozadanut/ro.linic.ui/blob/main/ro.linic.ui.product/linic.product

apache-camel eclipse-rcp equinox target-platform
1个回答
0
投票

我最终将所有 Camel 核心 jar 添加到我的 ro.linic.ui.camel.core 插件中。为了能够在其他插件中使用camel,我添加了这个 ro.linic.ui.camel.core 插件作为依赖项,并导出了所需的包以便能够在其他插件中使用camel代码。

我确实使用 Maven 自动下载 jar,因此我不必单独下载每个 jar。我用的pom:

<project>
<modelVersion>4.0.0</modelVersion>

<parent>
    <relativePath>../pom.xml</relativePath>
    <groupId>ro.linic.tycho</groupId>
    <artifactId>releng</artifactId>
    <version>1.0.0-SNAPSHOT</version>
</parent>

<groupId>ro.linic.ui</groupId>
<artifactId>ro.linic.ui.camel.core</artifactId>
<version>0.0.1</version>
<packaging>eclipse-plugin</packaging>

<dependencyManagement>
    <dependencies>
        <!-- Camel BOM -->
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-bom</artifactId>
            <version>4.6.0</version>
            <scope>import</scope>
            <type>pom</type>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>

    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-core</artifactId>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${project.build.directory}/${project.build.finalName}.lib
                        </outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

然后我从生成的输出文件夹中取出所有camel jar,并将它们添加到运行时 -> 类路径部分中的清单中。

© www.soinside.com 2019 - 2024. All rights reserved.