Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
652 views
in Technique[技术] by (71.8m points)

java - How to pass boolean property to class mediator in WSO2 EI

Is there any way to pass a boolean parameter to the class mediator? I tried with the following code block.

public class CustomMediator extends AbstractMediator {
    private String cacheEnabled;

    public boolean mediate(MessageContext messageContext) {}

    public String isCacheEnabled() {
        return cacheEnabled;
    }

    public void setCacheEnabled(String cacheEnabled) {
        this.cacheEnabled = cacheEnabled;
    }
}
<class name="lk.chathurabuddi.CustomMediator ">
    <property name="cacheEnabled" value="true"/>
</class>

But I'm getting the following runtime error.

TID: [-1234] [] [2021-01-11 06:45:49,060] ERROR {org.apache.synapse.config.xml.PropertyHelper} -  Error invoking setter method named : setCacheEnabled() that takes a single String, int, long, float, double or boolean parameterargument type mismatch {org.apache.synapse.config.xml.PropertyHelper}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try using a property mediator.

<class name="lk.chathurabuddi.CustomMediator">
 <property name="cacheEnabled" expression="$ctx:cacheEnabled"/>
</class>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...