我使用了WSO2_ESB 5.0版本。下面提到我写的班级调解人。
public abstract class CustomMediator extends AbstractMediator {
private static final Log log = LogFactory.getLog(CustomMediator.class);
private String num1 = "10";
private String num2 = "15";
private int sum = 0;
public boolean mediate(MessageContext mc) {
log.info("Call the custom mediator");
sum = Integer.parseInt(num1) + Integer.parseInt(num2);
String totalOfIntegers = String.valueOf(sum);
mc.setProperty("totalOfIntegers", totalOfIntegers);
log.info("Sum of two numbers : " + totalOfIntegers);
return true;
}
public String getType() {
return null;
}
public void setTraceState(int traceState) {
traceState = 0;
}
public int getTraceState() {
return 0;
}
public String getNum1() {
return num1;
}
public void setNum1(String num1) {
this.num1 = num1;
}
public String getNum2() {
return num2;
}
public void setNum2(String num2) {
this.num2 = num2;
}
}
然后我将.jar文件上传到/ repository / components / lib文件夹。下面提到了我为访问类介体而创建的自定义代理。
<?xml version="1.0" encoding="UTF-8"?>
<inSequence xmlns="http://ws.apache.org/ns/synapse">
<log/>
<class name="com.mediator.java.CustomMediator">
<axis2ns1:property name="num1" value="10" xmlns:axis2ns1="http://ws.apache.org/ns/synapse"/>
<axis2ns2:property name="num2" value="12" xmlns:axis2ns2="http://ws.apache.org/ns/synapse"/>
</class>
<property expression="get-property('default','totalOfIntegers')"
name="getTotalValue" scope="default" type="STRING"/>
<log>
<property expression="get-property('default','getTotalValue')" name="Total :"/>
</log>
</inSequence>
<?xml version="1.0" encoding="UTF-8"?>
<outSequence xmlns="http://ws.apache.org/ns/synapse">
<log/>
<send/>
</outSequence>
创建自定义代理服务时,出现以下错误。
Unable to add proxy service :: Error in instantiating class : com.mediator.java.CustomMediator-Error in instantiating class : com.mediator.java.CustomMediator
能帮我解决这个问题吗?任何帮助或变通办法都倍受赞赏。
答案 0 :(得分:3)
您能否将CustomMediator类定义为非抽象类并尝试。
public class CustomMediator extends AbstractMediator
谢谢