ラバ アプリケーションが起動する前に、いくつかの処理を実行したかったのです。Mule のドキュメントに従って、このためのカスタム エージェントを作成できます。しかし、mule の起動時にエージェントがロードされません。
カスタム エージェントの作成方法の例を教えてください。
以下に示すように、同じテストプログラムを作成しました
CustomAgent クラス
package agent;
import org.mule.api.MuleException;
import org.mule.api.agent.Agent;
import org.mule.api.lifecycle.InitialisationException;
public class CustomAgent implements Agent{
public CustomAgent() {
}
private String port;
public String getPort() {
return port;
}
public void setPort(String port) {
this.port = port;
}
@Override
public void initialise() throws InitialisationException {
System.out.println("Initialize on port: " + port);
}
@Override
public void start() throws MuleException {
System.out.println("Started on port: " + port);
}
@Override
public void stop() throws MuleException {
System.out.println("Stopping the agent");
}
@Override
public void dispose() {
// TODO Auto-generated method stub
}
@Override
public void setName(String name) {
this.port = name;
}
@Override
public String getName() {
return port;
}
@Override
public String getDescription() {
// TODO Auto-generated method stub
return getName();
}
}
これは私の CustomAgent.xml ファイルです
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.3.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd">
<custom-agent name="mycustomagent" class="agent.AgentTest">
<spring:property name="port" value="8899"></spring:property>
</custom-agent>
</mule>
jarファイルをエクスポートして入れてみました
MULE_HOME\lib\opt
と
MULE_HOME\lib\ユーザー
しかし、エージェントとしてロードされていません。
助けてください!