- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中com.jetdrone.vertx.yoke.core.YokeAsyncResult
类的一些代码示例,展示了YokeAsyncResult
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YokeAsyncResult
类的具体详情如下:
包路径:com.jetdrone.vertx.yoke.core.YokeAsyncResult
类名称:YokeAsyncResult
[英]# YokeAsyncResult Class to wrap a pair of Throwable + Result into a Vert.x AsyncResult Object.
[中]
代码示例来源:origin: pmlopes/yoke
@Override
public void handle(AsyncResult<String> asyncResult) {
if (asyncResult.failed()) {
handler.handle(new YokeAsyncResult<Buffer>(asyncResult.cause()));
} else {
try {
handler.handle(new YokeAsyncResult<>(parseStringValue(asyncResult.result(), context, new HashSet<String>())));
} catch (IllegalArgumentException iae) {
handler.handle(new YokeAsyncResult<Buffer>(iae));
}
}
}
});
代码示例来源:origin: pmlopes/yoke
@SuppressWarnings("unchecked")
public void resolve(T value) {
if (!canceled && !resolved) {
resolved = true;
if (handler != null) {
if (handler instanceof AsyncResultHandler) {
handler.handle(new YokeAsyncResult<>(value));
handler = null;
return;
}
handler.handle(value);
handler = null;
}
}
}
代码示例来源:origin: pmlopes/yoke
@SuppressWarnings("unchecked")
public void cancel(Object error) {
if (!canceled) {
canceled = true;
if (handler != null) {
if (handler instanceof AsyncResultHandler) {
handler.handle(new YokeAsyncResult<T>(error, null));
handler = null;
return;
}
handler.handle(error);
handler = null;
}
}
}
代码示例来源:origin: pmlopes/yoke
@Override
public void handle(Boolean fresh) {
if (fresh) {
String cachedValue = getFileFromCache(filename);
if (cachedValue != null) {
handler.handle(new YokeAsyncResult<>(null, cachedValue));
return;
}
}
// either fresh is false or cachedValue is null
loadToCache(filename, new Handler<Throwable>() {
@Override
public void handle(Throwable error) {
if (error != null) {
handler.handle(new YokeAsyncResult<String>(error, null));
return;
}
// no error
handler.handle(new YokeAsyncResult<>(null, getFileFromCache(filename)));
}
});
}
});
代码示例来源:origin: pmlopes/yoke
@Override
public void handle(AsyncResult<String> asyncResult) {
if (asyncResult.failed()) {
next.handle(new YokeAsyncResult<Buffer>(asyncResult.cause()));
} else {
try {
CompiledTemplate template = compile(prefix + filename, asyncResult.result());
next.handle(new YokeAsyncResult<>(Buffer.buffer((String) TemplateRuntime.execute(template, context))));
} catch (IOException ex) {
next.handle(new YokeAsyncResult<Buffer>(ex));
}
}
}
});
代码示例来源:origin: pmlopes/yoke
@Override
public void create(String entity, JsonObject object, AsyncResultHandler<String> response) {
final Map<String, JsonObject> collection = getCollection(entity);
final String _id = Integer.toString(collection.size());
object.put("id", _id);
collection.put(_id, object);
response.handle(new YokeAsyncResult<>(_id));
}
代码示例来源:origin: pmlopes/yoke
@Override
public void render(final String filename, final Map<String, Object> context, final Handler<AsyncResult<Buffer>> next) {
final Buffer buffer = Buffer.buffer();
try {
engine.process(filename, toIContext(context), new Writer() {
@Override
public void write(char[] cbuf, int off, int len) throws IOException {
buffer.appendString(new String(cbuf, off, len));
}
@Override
public void flush() throws IOException {}
@Override
public void close() throws IOException {}
});
next.handle(new YokeAsyncResult<>(buffer));
} catch (Exception ex) {
ex.printStackTrace();
next.handle(new YokeAsyncResult<Buffer>(ex));
}
}
代码示例来源:origin: pmlopes/yoke
@Override
public void update(String entity, String id, JsonObject object, AsyncResultHandler<Number> response) {
final Map<String, JsonObject> collection = getCollection(entity);
response.handle(new YokeAsyncResult<Number>(collection.put(id, object) == null ? 0 : 1));
}
代码示例来源:origin: pmlopes/yoke
@Override
public void delete(String entity, String id, AsyncResultHandler<Number> response) {
final Map<String, JsonObject> collection = getCollection(entity);
response.handle(new YokeAsyncResult<Number>(collection.remove(id) == null ? 0 : 1));
}
代码示例来源:origin: pmlopes/yoke
@Override
public void read(String entity, String id, AsyncResultHandler<JsonObject> response) {
final Map<String, JsonObject> collection = getCollection(entity);
response.handle(new YokeAsyncResult<>(collection.get(id)));
}
代码示例来源:origin: pmlopes/yoke
@Override
public void render(final String filename, final Map<String, Object> context, final Handler<AsyncResult<Buffer>> next) {
try {
Template template = getTemplateFromCache(resolve(filename));
if (template == null) {
// real compile
template = handlebars.compile(filename);
putTemplateToCache(resolve(filename), template);
}
next.handle(new YokeAsyncResult<>(Buffer.buffer(template.apply(context))));
} catch (Exception ex) {
ex.printStackTrace();
next.handle(new YokeAsyncResult<Buffer>(ex));
}
}
代码示例来源:origin: pmlopes/yoke
@Override
public void render(final String filename, final Map<String, Object> context, final Handler<AsyncResult<Buffer>> next) {
try {
JadeTemplate template = getTemplateFromCache(resolve(filename));
if (template == null) {
// real compile
template = config.getTemplate(filename);
putTemplateToCache(resolve(filename), template);
}
next.handle(new YokeAsyncResult<>(Buffer.buffer(config.renderTemplate(template, context))));
} catch (Exception ex) {
ex.printStackTrace();
next.handle(new YokeAsyncResult<Buffer>(ex));
}
}
}
代码示例来源:origin: pmlopes/yoke
@Override
public void count(String entity, JsonObject query, AsyncResultHandler<Number> response) {
final Map<String, JsonObject> collection = getCollection(entity);
final List<JsonObject> values = new ArrayList<>(collection.values());
List<JsonObject> filteredValues;
if (query.size() > 0) {
filteredValues = new ArrayList<>();
for (JsonObject item : values) {
for (String field : query.fieldNames()) {
Object f = item.getValue(field);
if (f != null && f.toString().equals(query.getString(field))) {
filteredValues.add(item);
break;
}
}
}
} else {
filteredValues = values;
}
response.handle(new YokeAsyncResult<Number>(filteredValues.size()));
}
}
代码示例来源:origin: pmlopes/yoke
response.handle(new YokeAsyncResult<>(array));
本文整理了Java中com.jetdrone.vertx.yoke.core.YokeAsyncResult.()方法的一些代码示例,展示了YokeAsyncResult.()的具体用法。这些代码示例
我是一名优秀的程序员,十分优秀!