本文整理汇总了Java中com.thetransactioncompany.jsonrpc2.server.MessageContext类的典型用法代码示例。如果您正苦于以下问题:Java MessageContext类的具体用法?Java MessageContext怎么用?Java MessageContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MessageContext类属于com.thetransactioncompany.jsonrpc2.server包,在下文中一共展示了MessageContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import com.thetransactioncompany.jsonrpc2.server.MessageContext; //导入依赖的package包/类
public JSONRPC2Response process(JSONRPC2Request req, MessageContext ctx) {
if (req.getMethod().equals("Echo")) {
JSONRPC2Error err = JSONRPC2Helper.validateParams(requiredArgs, req);
if (err != null)
return new JSONRPC2Response(err, req.getID());
HashMap inParams = (HashMap) req.getParams();
String echo = (String) inParams.get("Echo");
Map outParams = new HashMap();
outParams.put("Result", echo);
return new JSONRPC2Response(outParams, req.getID());
}
else {
// Method name not supported
return new JSONRPC2Response(JSONRPC2Error.METHOD_NOT_FOUND, req.getID());
}
}
示例2: handleLoadData
import com.thetransactioncompany.jsonrpc2.server.MessageContext; //导入依赖的package包/类
private JSONRPC2Response handleLoadData(JSONRPC2Request request, MessageContext context){
if (!request.getParamsType().equals(JSONRPC2ParamsType.OBJECT) ||
!(request.getParams() instanceof Map)) {
return new JSONRPC2Response(JSONRPC2Error.INVALID_PARAMS,
request.getID());
}
Map<?,?> map = (Map<?,?>) request.getParams();
if (!map.containsKey(JsonRpcConstants.PARAM_NAME_DATASET)) {
return new JSONRPC2Response(JSONRPC2Error.INVALID_PARAMS,
request.getID());
}
String datasetName = getArg(map, JsonRpcConstants.PARAM_NAME_DATASET);
if (datasetName == null) {
return new JSONRPC2Response(JSONRPC2Error.INVALID_PARAMS,
request.getID());
}
datasetName = datasetName.trim();
JSONRPC2Response response = new JSONRPC2Response(solver.getInputs(datasetName),request.getID());
System.out.println("reponse: " + datasetName);
return response;
}
示例3: process
import com.thetransactioncompany.jsonrpc2.server.MessageContext; //导入依赖的package包/类
public JSONRPC2Response process(JSONRPC2Request req, MessageContext ctx) {
if (req.getMethod().equals("I2PControl")) {
return process(req);
} else {
// Method name not supported
return new JSONRPC2Response(JSONRPC2Error.METHOD_NOT_FOUND, req.getID());
}
}
示例4: process
import com.thetransactioncompany.jsonrpc2.server.MessageContext; //导入依赖的package包/类
public JSONRPC2Response process(JSONRPC2Request req, MessageContext ctx) {
if (req.getMethod().equals("NetworkSetting")) {
return process(req);
} else {
// Method name not supported
return new JSONRPC2Response(JSONRPC2Error.METHOD_NOT_FOUND, req.getID());
}
}
示例5: process
import com.thetransactioncompany.jsonrpc2.server.MessageContext; //导入依赖的package包/类
public JSONRPC2Response process(JSONRPC2Request req, MessageContext ctx) {
if (req.getMethod().equals("RouterManager")) {
return process(req);
} else {
// Method name not supported
return new JSONRPC2Response(JSONRPC2Error.METHOD_NOT_FOUND,
req.getID());
}
}
示例6: process
import com.thetransactioncompany.jsonrpc2.server.MessageContext; //导入依赖的package包/类
public JSONRPC2Response process(JSONRPC2Request req, MessageContext ctx) {
if (req.getMethod().equals("RouterInfo")) {
return process(req);
} else {
// Method name not supported
return new JSONRPC2Response(JSONRPC2Error.METHOD_NOT_FOUND,
req.getID());
}
}
示例7: process
import com.thetransactioncompany.jsonrpc2.server.MessageContext; //导入依赖的package包/类
public JSONRPC2Response process(JSONRPC2Request req, MessageContext ctx) {
if (req.getMethod().equals("GetRate")) {
JSONRPC2Error err = JSONRPC2Helper.validateParams(requiredArgs, req);
if (err != null)
return new JSONRPC2Response(err, req.getID());
HashMap inParams = (HashMap) req.getParams();
String input = (String) inParams.get("Stat");
if (input == null) {
return new JSONRPC2Response(JSONRPC2Error.INVALID_PARAMS, req.getID());
}
long period;
try {
period = (Long) inParams.get("Period");
} catch (NumberFormatException e) {
return new JSONRPC2Response(JSONRPC2Error.INVALID_PARAMS, req.getID());
}
RateStat rateStat = I2PAppContext.getGlobalContext().statManager().getRate(input);
// If RateStat or the requested period doesn't already exist, create them.
if (rateStat == null || rateStat.getRate(period) == null) {
long[] tempArr = new long[1];
tempArr[0] = period;
I2PAppContext.getGlobalContext().statManager().createRequiredRateStat(input, "I2PControl", "I2PControl", tempArr);
rateStat = I2PAppContext.getGlobalContext().statManager().getRate(input);
}
if (rateStat.getRate(period) == null)
return new JSONRPC2Response(JSONRPC2Error.INTERNAL_ERROR, req.getID());
Map outParams = new HashMap();
Rate rate = rateStat.getRate(period);
rate.coalesce();
outParams.put("Result", rate.getAverageValue());
return new JSONRPC2Response(outParams, req.getID());
}
return new JSONRPC2Response(JSONRPC2Error.METHOD_NOT_FOUND, req.getID());
}
示例8: process
import com.thetransactioncompany.jsonrpc2.server.MessageContext; //导入依赖的package包/类
public JSONRPC2Response process(JSONRPC2Request req, MessageContext ctx) {
if (req.getMethod().equals("Authenticate")) {
JSONRPC2Error err = JSONRPC2Helper.validateParams(requiredArgs, req, JSONRPC2Helper.USE_NO_AUTH);
if (err != null)
return new JSONRPC2Response(err, req.getID());
HashMap inParams = (HashMap) req.getParams();
String pwd = (String) inParams.get("Password");
// Try get an AuthToken
AuthToken token = SecurityManager.getInstance().validatePasswd(pwd);
if (token == null) {
return new JSONRPC2Response(JSONRPC2ExtendedError.INVALID_PASSWORD, req.getID());
}
Object api = inParams.get("API");
err = validateAPIVersion(api);
if (err != null)
return new JSONRPC2Response(err, req.getID());
Map outParams = new HashMap();
outParams.put("Token", token.getId());
outParams.put("API", I2PControlVersion.API_VERSION);
return new JSONRPC2Response(outParams, req.getID());
} else {
// Method name not supported
return new JSONRPC2Response(JSONRPC2Error.METHOD_NOT_FOUND, req.getID());
}
}
示例9: process
import com.thetransactioncompany.jsonrpc2.server.MessageContext; //导入依赖的package包/类
@Override
public JSONRPC2Response process(JSONRPC2Request request, MessageContext messageContext) {
if (request.getMethod().equalsIgnoreCase(TRAINING)) {
return handleTraining(request);
} else {
return new JSONRPC2Response(JSONRPC2Error.METHOD_NOT_FOUND, request.getID());
}
}
示例10: process
import com.thetransactioncompany.jsonrpc2.server.MessageContext; //导入依赖的package包/类
@Override
public JSONRPC2Response process(JSONRPC2Request request, MessageContext messageContext) {
if (request.getMethod().equalsIgnoreCase(COMMENT_SEARCH)) {
return handleCommentSearch(request);
} else {
return new JSONRPC2Response(JSONRPC2Error.METHOD_NOT_FOUND, request.getID());
}
}
示例11: process
import com.thetransactioncompany.jsonrpc2.server.MessageContext; //导入依赖的package包/类
@Override
public JSONRPC2Response process(JSONRPC2Request request, MessageContext messageContext) {
if (request.getMethod().equalsIgnoreCase(TWEET_SEARCH)) {
return handleTweetSearch(request);
} else {
return new JSONRPC2Response(JSONRPC2Error.METHOD_NOT_FOUND, request.getID());
}
}
示例12: process
import com.thetransactioncompany.jsonrpc2.server.MessageContext; //导入依赖的package包/类
@Override
public JSONRPC2Response process(JSONRPC2Request request, MessageContext messageContext) {
if (request.getMethod().equalsIgnoreCase(VIDEO_SEARCH)) {
return handleVideoSearch(request);
} else {
return new JSONRPC2Response(JSONRPC2Error.METHOD_NOT_FOUND, request.getID());
}
}
示例13: process
import com.thetransactioncompany.jsonrpc2.server.MessageContext; //导入依赖的package包/类
@Override
public JSONRPC2Response process(JSONRPC2Request request, MessageContext context) {
StringBuilder logBuilder = new StringBuilder()
.append(request.getMethod())
.append(" request params")
.append(request.getParams().toString())
.append(" from ")
.append(context.getClientInetAddress())
.append(": ");
if (request.getMethod().equals(JsonRpcConstants.METHOD_NAME_LOAD_DATA)) {
logger.info(logBuilder.append("dispatched.").toString());
return handleLoadData(request,context);
}
else if (request.getMethod().equals(JsonRpcConstants.METHOD_NAME_DATASETS)) {
logger.info(logBuilder.append("dispatched.").toString());
return handleDatasets(request,context);
}
else if (request.getMethod().equals(JsonRpcConstants.METHOD_NAME_SOLVE)) {
logger.info(logBuilder.append("dispatched.").toString());
return handleSolve(request,context);
}
else{
logger.info(logBuilder.append("invalid.").toString());
return new JSONRPC2Response(JSONRPC2Error.METHOD_NOT_FOUND,
request.getID());
}
}
示例14: process
import com.thetransactioncompany.jsonrpc2.server.MessageContext; //导入依赖的package包/类
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public JSONRPC2Response process(final JSONRPC2Request req,
final MessageContext ctxt) {
final ApiHandler m = this.handlers.get(req.getMethod());
if (m != null) {
if (m.getType() != JSONRPC2ParamsType.NO_PARAMS
&& m.getType() != req.getParamsType()) {
return new JSONRPC2Response(new JSONRPC2Error(
JSONRPC2Error.INVALID_PARAMS.getCode(), req.getMethod()
+ " requires: " + m.getType() + "; got: "
+ req.getParamsType()), req.getID());
}
switch (m.getType()) {
case NO_PARAMS:
return m.process(null);
case ARRAY:
return m.process(req.getPositionalParams());
case OBJECT:
return m.process(req.getNamedParams());
default:
break;
}
}
return new JSONRPC2Response(JSONRPC2Error.METHOD_NOT_FOUND, req.getID());
}
示例15: handleDatasets
import com.thetransactioncompany.jsonrpc2.server.MessageContext; //导入依赖的package包/类
private JSONRPC2Response handleDatasets(JSONRPC2Request request, MessageContext context){
return new JSONRPC2Response(kidneyDataBase.availableDatasets(),request.getID());
}