を参照してください。これは、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をエコーバックし、「エコー」引数の値に基づいて結果を切り替え簡単な例のWebスクリプトを使用しています。したがって、 "false"で呼び出されると、JSONはfalseを返し、エバリュエータはfalseを返します。
評価メソッドが期待するorg.json.simple.JSONObjectと、レスポンスJSONの結果を妨害するために使用しているorg.json.JSONObjectとの間の名前衝突を指摘する必要があります。
BaseEvaluatorのソースコードを見ましたか?それはJSONObjectに関するあなたの質問に答えるべきです。あなたは間違いなくレポ層へのあなた自身の呼び出しを行う必要があります。 Surfフレームワークはこれを既にサポートしているので、Surf APIを活用してこれを行うことができます。しかし、例を見つけるのが面倒です。 –