これが役立つかどうかを確認してください。これは、BaseEvaluatorを拡張するクラスに入ります。Springを介してBeanを配線し、アクションに評価者を設定します。
public boolean evaluate(JSONObject jsonObject) {
boolean result = false;
final RequestContext rc = ThreadLocalRequestContext.getRequestContext();
final String userId = rc.getUserId();
try {
final Connector conn = rc.getServiceRegistry().getConnectorService().getConnector("alfresco", userId, ServletUtil.getSession());
final Response response = conn.call("/someco/example?echo=false");
if (response.getStatus().getCode() == Status.STATUS_OK) {
System.out.println(response.getResponse());
try {
org.json.JSONObject json = new org.json.JSONObject(response.getResponse());
result = Boolean.parseBoolean(((String) json.get("result")));
} catch (JSONException je) {
je.printStackTrace();
return false;
}
} else {
System.out.println("Call failed, code:" + response.getStatus().getCode());
return false;
}
} catch (ConnectorServiceException cse) {
cse.printStackTrace();
return false;
}
return result;
}
この例では、JSONをエコーバックし、「echo」引数の値に基づいて結果を切り替える簡単なサンプルWebスクリプトを使用しています。したがって、「false」で呼び出されると、JSONはfalseを返し、エバリュエーターはfalseを返します。
おそらく、evaluateメソッドが期待するorg.json.simple.JSONObjectと、応答JSONからの結果を取得するために使用しているorg.json.JSONObjectとの間の名前の衝突を指摘する必要があります。