info.xiancloud.core.Handler.handle()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(155)

本文整理了Java中info.xiancloud.core.Handler.handle()方法的一些代码示例,展示了Handler.handle()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Handler.handle()方法的具体详情如下:
包路径:info.xiancloud.core.Handler
类名称:Handler
方法名:handle

Handler.handle介绍

暂无

代码示例

代码示例来源:origin: xiancloud/xian

@Override
public void execute(UnitRequest request, Handler<UnitResponse> handler) {
  try {
    Thread.sleep(10 * 1000);
  } catch (InterruptedException e) {
  }
  handler.handle(UnitResponse.createSuccess());
}

代码示例来源:origin: xiancloud/xian

@Override
public void execute(UnitRequest msg, Handler<UnitResponse> handler) {
  File file = new File(msg.getString("file"));
  try {
    InputStream inputStream = new FileInputStream(file);
    handler.handle(UnitResponse.createSuccess(inputStream));
    return;
  } catch (FileNotFoundException e) {
    handler.handle(UnitResponse.createException(e, "文件不存在"));
    return;
  }
}

代码示例来源:origin: xiancloud/xian

@Override
public void execute(UnitRequest msg, Handler<UnitResponse> handler) {
  boolean enable = msg.get("enable", boolean.class);
  ENABLE_RPC.set(enable);
  handler.handle(UnitResponse.createSuccess());
}

代码示例来源:origin: xiancloud/xian

@Override
  public void execute(UnitRequest request, Handler<UnitResponse> handler) throws ExecutionException {
    handler.handle(UnitResponse.createSuccess(
        new JSONObject()
            .fluentPut("cols", TableMetaCache.COLS.get(TABLE_NAME))
            .fluentPut("idCol", TableMetaCache.ID_COL.get(TABLE_NAME))
    ));
  }
}

代码示例来源:origin: xiancloud/xian

@Override
public void execute(UnitRequest msg, Handler<UnitResponse> handler) throws Exception {
  String key = msg.getArgMap().get("key").toString();
  CacheConfigBean cacheConfigBean = msg.get("cacheConfig", CacheConfigBean.class);
  Object result = Redis.call(cacheConfigBean, jedis -> jedis.get(key));
  if (result != null && result.toString().equals("nil"))
    result = null;
  handler.handle(UnitResponse.createSuccess(result));
}

代码示例来源:origin: xiancloud/xian

@Override
public void execute(UnitRequest msg, Handler<UnitResponse> handler) throws Exception {
  String key = msg.getArgMap().get("key").toString();
  CacheConfigBean cacheConfigBean = msg.get("cacheConfig", CacheConfigBean.class);
  long size = Redis.call(cacheConfigBean, jedis -> jedis.del(key));
  handler.handle(UnitResponse.createSuccess(size));
}

代码示例来源:origin: xiancloud/xian

@Override
public void execute(UnitRequest msg, Handler<UnitResponse> consumer) {
  String key = msg.getArgMap().get("key").toString();
  CacheConfigBean cacheConfigBean = msg.get("cacheConfig", CacheConfigBean.class);
  try {
    boolean result = Redis.call(cacheConfigBean, jedis -> jedis.exists(key));
    consumer.handle(UnitResponse.createSuccess(result));
  } catch (Exception e) {
    consumer.handle(UnitResponse.createException(e));
  }
}

代码示例来源:origin: xiancloud/xian

@Override
public void execute(UnitRequest msg, Handler<UnitResponse> handler) throws Exception {
  String key = msg.getArgMap().get("key").toString();
  Long index = msg.getArgMap().get("index") != null ? Long.parseLong(msg.getArgMap().get("index").toString()) : 0;
  CacheConfigBean cacheConfigBean = msg.get("cacheConfig", CacheConfigBean.class);
  String element;
  element = Redis.call(cacheConfigBean, (jedis) -> jedis.lindex(key, index));
  if (element != null && element.equals("nil"))
    element = null;
  handler.handle(UnitResponse.createSuccess(element));
}

代码示例来源:origin: xiancloud/xian

@Override
public void execute(UnitRequest msg, Handler<UnitResponse> handler) throws Exception {
  String key = msg.getArgMap().get("key").toString();
  String field = msg.getArgMap().get("field").toString();
  CacheConfigBean cacheConfigBean = msg.get("cacheConfig", CacheConfigBean.class);
  long length;
  length = Redis.call(cacheConfigBean, jedis -> jedis.hdel(key, field));
  handler.handle(UnitResponse.createSuccess(length));
}

代码示例来源:origin: xiancloud/xian

@Override
public void execute(UnitRequest msg, Handler<UnitResponse> handler) throws Exception {
  String key = msg.getArgMap().get("key").toString();
  CacheConfigBean cacheConfigBean = msg.get("cacheConfig", CacheConfigBean.class);
  Set<String> keys = Redis.call(cacheConfigBean, jedis -> jedis.hkeys(key));
  handler.handle(UnitResponse.createSuccess(keys));
}

代码示例来源:origin: xiancloud/xian

@Override
public void execute(UnitRequest msg, Handler<UnitResponse> handler) {
  String key = msg.get("key");
  CacheConfigBean cacheConfigBean = msg.get("cacheConfig", CacheConfigBean.class);
  try {
    Redis.call(cacheConfigBean, (jedis) -> jedis.ltrim(key, 1, 0));
    handler.handle(UnitResponse.createSuccess());
  } catch (Exception e) {
    handler.handle(UnitResponse.createException(e));
  }
}

代码示例来源:origin: xiancloud/xian

@Override
public void execute(UnitRequest msg, Handler<UnitResponse> handler) throws Exception {
  String key = msg.getArgMap().get("key").toString();
  CacheConfigBean cacheConfigBean = msg.get("cacheConfig", CacheConfigBean.class);
  List<String> values = Redis.call(cacheConfigBean, jedis -> jedis.hvals(key));
  handler.handle(UnitResponse.createSuccess(values));
}

代码示例来源:origin: xiancloud/xian

@Override
  public void execute(UnitRequest msg, Handler<UnitResponse> handler) {
    String value = XianConfig.get(msg.get("key"));
    if (StringUtil.isEmpty(value))
      handler.handle(UnitResponse.createDataDoesNotExists(msg.getString("key"), "config not found."));
    else
      handler.handle(UnitResponse.createSuccess(value));
  }
}

代码示例来源:origin: xiancloud/xian

@Override
public void execute(UnitRequest msg, Handler<UnitResponse> handler) throws Exception {
  String key = msg.getArgMap().get("key").toString();
  CacheConfigBean cacheConfigBean = msg.get("cacheConfig", CacheConfigBean.class);
  boolean result = Redis.call(cacheConfigBean, jedis -> jedis.exists(key));
  handler.handle(UnitResponse.createSuccess(result));
}

代码示例来源:origin: xiancloud/xian

@Override
public void execute(UnitRequest msg, Handler<UnitResponse> handler) {
  String host = msg.get("host", String.class);
  int port = msg.getArgMap().containsKey("port") ? msg.get("port", int.class) : Redis.PORT;
  String password = msg.getArgMap().containsKey("password") ? msg.get("password", String.class) : "";
  int dbIndex = msg.getArgMap().containsKey("dbIndex") ? msg.get("dbIndex", int.class) : Redis.DB_INDEX;
  Redis.initRedis(host, port, password, dbIndex);
  handler.handle(UnitResponse.createSuccess());
}

代码示例来源:origin: xiancloud/xian

@Override
public void execute(UnitRequest msg, Handler<UnitResponse> handler) throws Exception {
  String key = msg.get("key", String.class);
  Long score = (Long) msg.getArgMap().get("score");
  Object member = msg.getArgMap().get("member");
  CacheConfigBean cacheConfigBean = msg.get("cacheConfig", CacheConfigBean.class);
  Long result = Redis.call(cacheConfigBean, jedis -> jedis.zadd(key, score, FormatUtil.formatValue(member)));
  handler.handle(UnitResponse.createSuccess(result));
}

代码示例来源:origin: info.xiancloud/xian-daocore

@Override
public void execute(UnitRequest msg, Handler<UnitResponse> handler) {
  LOG.info(String.format("事务开始...transId=%s", MsgIdHolder.get()));
  TransactionFactory.getTransaction(MsgIdHolder.get())
      .subscribe(xianTransaction -> xianTransaction.begin()
          .subscribe(() ->
              handler.handle(UnitResponse.createSuccess("Begin Transaction OK! transId=  " + MsgIdHolder.get())))
      );
}

代码示例来源:origin: xiancloud/xian

@Override
public void execute(UnitRequest msg, Handler<UnitResponse> handler) throws Exception {
  String key = msg.get("key", String.class);
  CacheConfigBean cacheConfigBean = msg.get("cacheConfig", CacheConfigBean.class);
  Set<String> values = Redis.call(cacheConfigBean, jedis -> jedis.smembers(key));
  handler.handle(UnitResponse.createSuccess(values));
}

代码示例来源:origin: xiancloud/xian

@Override
  public void execute(UnitRequest msg, Handler<UnitResponse> handler) {
    SingleRxXian
        .call(CustomizedMdApidocUnit.class, msg.getArgMap())
        .subscribe(unitResponse -> {
          unitResponse.throwExceptionIfNotSuccess();
          String md = unitResponse.dataToStr();
          UnitResponse myResponse = UnitResponse.createSuccess(MdToHtml.mdToHtml(md)).setContext(UnitResponse.Context.create().setHttpContentType(HttpContentType.TEXT_HTML));
          handler.handle(myResponse);
        });
  }
}

代码示例来源:origin: xiancloud/xian

@Override
public void execute(UnitRequest msg, Handler<UnitResponse> handler) throws Exception {
  String key = msg.get("key", String.class);
  Object member = msg.get("member", Object.class);
  CacheConfigBean cacheConfigBean = msg.get("cacheConfig", CacheConfigBean.class);
  Boolean result = Redis.call(cacheConfigBean, jedis -> jedis.sismember(key, FormatUtil.formatValue(member)));
  handler.handle(UnitResponse.createSuccess(result));
}

相关文章

Handler类方法