迁移现有适配器以在 MobileFirst Server V8.0.0 下工作
improve this page | report issue
概述
从 MobileFirst Server V8.0 开始,适配器是 Maven 项目。 了解如何升级在 MobileFirst Server 的较早版本下开发的适配器。
本页面描述了迁移适配器(开发为与 MobileFirst Server V6.2 或更高版本一起使用)以与 MobileFirst Server V8.0一起使用所需采取的步骤。
首先请了解 V8.0 中不推荐使用的功能以及 API 元素和服务器端 API 更改中描述的适配器 API 更改。
- 在某些情况下,现有适配器可按原样与 MobileFirst Server V8.0 一起使用。 请参阅在 MobileFirst Server V8.0 下按原样使用较旧的适配器。
- 在大多数情况下,需要升级适配器。 对于 Java™ 适配器,请参阅针对 MobileFirst Server V8.0 将 Java 适配器迁移到 Maven 项目。 对于 JavaScript 适配器,请参阅针对 MobileFirst Server V8.0 将 JavaScript 适配器迁移到 Maven 项目。
在 MobileFirst Server V8.0 下按原样使用较旧的适配器
除非符合以下任何条件,否则现有适配器可按原样部署在 MobileFirst Server V8.0 下:
适配器类型 | 条件 |
---|---|
Java | 使用 PushAPI 或 SecurityAPI 接口 |
JavaScript |
|
针对 MobileFirst Server V8.0 将 Java 适配器迁移到 Maven 项目
- 创建 archetype 为 adapter-maven-archetype-java 的 Maven 适配器项目。 在设置参数 artifactId 时,请使用适配器名称;对于参数 package,请使用与现有 Java 适配器中的包相同的包。 有关更多信息,请参阅创建 Java 适配器。
- 覆盖在步骤 1 中创建的新适配器项目的 src/main/adapter-resources 文件夹中的适配器描述符文件 (adapter.xml)。有关描述符的更多详细信息,请参阅 Java 适配器描述符文件。
-
从新适配器项目的 src/main/java 文件夹中除去所有文件。 然后,复制旧 Java 适配器项目的 src/ 文件夹下的所有 Java 文件,并保持相同的文件夹结构。 将所有非 Java 文件从旧适配器的 src 文件夹复制到新适配器的 src/main/resources 文件夹。 缺省情况下,src/main/resources 不存在,因此如果适配器包含非 Java 文件,请创建此目录。 有关 Java 适配器 API 中的更改,请参阅 V8.0 中的服务器端 API 更改。
下图说明了 V7.1 之前适配器的结构以及 Maven 适配器(从 V8.0 开始)的结构:
├── adapters │ └── RSSAdapter │ ├── RSSAdapter.xml │ ├── lib │ └── src │ └── com │ └── sample │ ├── RSSAdapterApplication.java │ └── RSSAdapterResource.java
Java 适配器的新结构:
├── pom.xml ├── src │ └── main │ ├── adapter-resources │ │ └── adapter.xml │ └── java │ └── com │ └── sample │ ├── RSSAdapterApplication.java │ └── RSSAdapterResource.java
- 使用以下任一方法,添加 Maven 存储库中未包含的任何 JAR 文件:
- 将 JAR 文件添加到本地存储库(如 Guide to installing third-party JARs 中所述),然后将其添加到 dependencies 元素。
- 使用 systemPath 元素将 JAR 文件添加到 dependencies 元素中。 有关更多信息,请参阅 Introduction to the Dependency Mechanism。
针对 MobileFirst Server V8.0 将 JavaScript 适配器迁移到 Maven 项目
- 创建 archetype 为 adapter-maven-archetype-http 或 adapter-maven-archetype-sql 的 Maven 适配器项目。 在设置参数 artifactId 时,使用适配器名称。 有关更多信息,请参阅创建 JavaScript 适配器。
- 覆盖在步骤 1 中创建的新适配器项目的 src/main/adapter-resources 文件夹中的适配器描述符文件 (adapter.xml)。有关描述符的详细信息,请参阅 JavaScript 适配器描述符文件。
- 覆盖新适配器项目的 src/main/adapter-resources/js 文件夹中的 JavaScript 文件。
Inclusive terminology note: The Mobile First Platform team is making changes to support the IBM® initiative to replace racially biased and other discriminatory language in our code and content with more inclusive language. While IBM values the use of inclusive language, terms that are outside of IBM's direct influence are sometimes required for the sake of maintaining user understanding. As other industry leaders join IBM in embracing the use of inclusive language, IBM will continue to update the documentation to reflect those changes.
Last modified on June 01, 2020