我已经使用 Maven 方法成功部署了您的自定义调解器。这就是我所做的。
我创建了以下目录结构并将您的 SiriBankMediator.java 放在 src/main/java 中:
.
├── pom.xml
├── src
│ └── main
│ └── java
│ └── SiriBankMediator.java
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">
<modelVersion>4.0.0</modelVersion>
<groupId>org.samples.mediator</groupId>
<artifactId>siribankmediator</artifactId>
<version>1.0</version>
<repositories>
<repository>
<id>wso2-maven2-repository</id>
<url>http://dist.wso2.org/maven2</url>
</repository>
<repository>
<id>apache-Incubating-repo</id>
<name>Maven Incubating Repository</name>
<url>http://people.apache.org/repo/m2-incubating-repository</url>
</repository>
<repository>
<id>apache-maven2-repo</id>
<name>Apache Maven2 Repository</name>
<url>http://repo1.maven.org/maven2/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>org.test</Bundle-SymbolicName>
<Bundle-Name>org.test</Bundle-Name>
<Export-Package>
org.test.mediator.*,
</Export-Package>
<Import-Package>
*; resolution:=optional
</Import-Package>
<Fragment-Host>synapse-core</Fragment-Host>
</instructions>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>fully.qualified.MainClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.synapse</groupId>
<artifactId>synapse-core</artifactId>
<version>1.3.0.wso2v1</version>
</dependency>
</dependencies>
</project>
然后在包含 POM 文件的目录中,我们执行mvn compile package
. 这应该构建您需要放入$ESB_HOME/repository/components/lib
名为 target 的文件夹中的 jar 文件。
最后,您可以通过碳管理前端将该类加载为 org.samples.mediator.SiriBankMediator。不要忘记重新启动您的 ESB。希望有帮助。:)