Exchange では、Maven クライアントを使用してアセットをパブリッシュまたはコンシュームする API が提供されます。アセットをパブリッシュするには、一意のアーティファクト名と組織 ID が必要です。API Manager は、組織のアセットとしてパブリッシュされたカスタムポリシーをリストします。
Exchange Maven Facade アセットについての詳細は、 「Exchange Maven Facade」を参照してください。
Maven アーキタイプを使用して作成されたポリシーをデプロイする
提供された Maven アーキタイプを使用してカスタムポリシープロジェクトを作成する場合、ポリシーを Exchange にアップロードするために必要なプラグインが事前定義されています。「アーキタイプを使用したプロジェクトのセットアップ」を参照してください。
Maven アーキタイプを使用して作成されたポリシーをデプロイする手順は、次のとおりです。
-
Maven
.m2 ディレクトリで、Exchange ログイン情報を使用して settings.xml ファイルを更新します。<?xml version="1.0" encoding="UTF-8"?> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <servers> <server> <id>exchange-server</id> <username>myusername</username> <password>mypassword</password> </server> </servers> </settings>ログイン情報でなく、トークンを使用した認証方法についての詳細は、「統合アセットをパブリッシュおよびコンシュームする」を参照してください。 -
mvn clean deploy を実行してポリシーを Exchange にパブリッシュします。これで、指定された組織に属する API にカスタムポリシーを適用できます。
Maven アーキタイプを使用せずに作成されたポリシーをデプロイする
提供された Maven アーキタイプを使用してカスタムポリシープロジェクトを作成していない場合は、Exchange デプロイメント設定を手動で定義する必要があります。
Maven アーキタイプを使用せずに作成されたポリシーをデプロイする手順は、次のとおりです。
-
Anypoint Platform で、使用する組織 ID を次の方法で検索します。
-
[Access Management (アクセス管理)] > [Organization (組織)] に移動します。
-
組織の名前をクリックします。
-
ブラウザーアドレスから UUID をコピーします。たとえば、URL から 2a4b93c3-7899-4ea7-9374-f787744d8784 をコピーします。
-
-
pom.xml ファイルを次のとおり更新します。-
groupId 値を前のステップの組織 ID に置き換えます。<groupId>{orgId}</groupId> -
次のプロパティを追加して、
{orgId} を前のステップの組織 ID に置き換えます。<properties> <exchange.url>https://maven.anypoint.mulesoft.com/api/v1/organizations/{OrgId}/maven</exchange.url> <mule.maven.plugin.version>3.2.0</mule.maven.plugin.version> <!-- check for last available version --> </properties> -
Exchange をリポジトリとして定義します。
<repository> <id>exchange-server</id> <name>MuleSoft Exchange Environment</name> <url>${exchange.url}</url> <snapshots> <enabled>true</enabled> </snapshots> </repository> -
Exchange サーバーを配布管理リポジトリとしてセットアップします。
<distributionManagement> <repository> <id>exchange-server</id> <name>Corporate Repository</name> <url>${exchange.url}</url> <layout>default</layout> </repository> </distributionManagement> -
次の構築プラグインを追加します。
-
Mule Maven プラグイン: 必要なすべてのファイルが存在し、ポリシーを適切にパッケージ化するためのすべての要件を満たしていることを確認する。
-
Maven デプロイプラグイン: Exchange リポジトリと通信し、ポリシーの JAR および YAML ファイルをアップロードする。
<build> <plugins> <plugin> <groupId>org.mule.tools.maven</groupId> <artifactId>mule-maven-plugin</artifactId> <version>${mule.maven.plugin.version}</version> <extensions>true</extensions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> <executions> <execution> <id>upload-template</id> <phase>deploy</phase> <goals> <goal>deploy-file</goal> </goals> <configuration> <repositoryId>exchange-server</repositoryId> <url>${exchange.url}</url> <file>${project.basedir}/${project.artifactId}.yaml</file> <generatePom>false</generatePom> <groupId>${project.groupId}</groupId> <artifactId>${project.artifactId}</artifactId> <version>${project.version}</version> <packaging>yaml</packaging> <classifier>policy-definition</classifier> </configuration> </execution> </executions> </plugin> </plugins> </build>
-
-
次のプラグインリポジトリを追加します。
<pluginRepositories> <pluginRepository> <id>mule-plugin</id> <name>Mule Repository</name> <url>https://repository.mulesoft.org/nexus/content/repositories/public/</url> </pluginRepository> </pluginRepositories>
-
-
Maven
.m2 ディレクトリで、Exchange ログイン情報を使用して settings.xml ファイルを更新します。<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <servers> <server> <id>exchange-server</id> <username>myusername</username> <password>mypassword</password> </server> </servers> </settings>ログイン情報でなく、トークンを使用した認証方法についての詳細は、「統合アセットをパブリッシュおよびコンシュームする」を参照してください。 -
mvn clean deploy コマンドを使用してポリシーをデプロイします。Exchange リポジトリに定義される ID は一致する必要があります。
これで、指定された組織に属する API にカスタムポリシーを適用できます。