gpt4 book ai didi

java - 使用类中介在 WSO2 ESB 中创建自定义代理时出错

转载 作者:行者123 更新时间:2023-11-29 08:22:45 27 4
gpt4 key购买 nike

我使用的是 WSO2_ESB 5.0 版本。下面提到我写的类(class)调解员。

  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

你能帮我解决这个问题吗?非常感谢任何帮助或解决方法。

最佳答案

您能否将 CustomMediator 类定义为非抽象类并尝试。

public class CustomMediator extends AbstractMediator

谢谢

关于java - 使用类中介在 WSO2 ESB 中创建自定义代理时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56141613/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com