本文整理了Java中org.jooby.funzy.Try.onSuccess()
方法的一些代码示例,展示了Try.onSuccess()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Try.onSuccess()
方法的具体详情如下:
包路径:org.jooby.funzy.Try
类名称:Try
方法名:onSuccess
[英]Run the given action if and only if this is a success.
[中]当且仅当此操作成功时运行给定操作。
代码示例来源:origin: jooby-project/jooby
@Override
public void send(final ByteBuffer buffer) throws Exception {
Try.of(Channels.newChannel(rsp.getOutputStream()))
.run(channel -> channel.write(buffer))
.onSuccess(() -> committed = true);
}
代码示例来源:origin: jooby-project/jooby
public void end() {
try {
if (rollbackOnly) {
rollback();
} else {
commit();
}
} finally {
if (readOnly) {
setConnectionReadOnly(false);
}
String sessionId = oid(session);
log.debug("closing session: {}", sessionId);
Try.run(session::close)
.onFailure(x -> log.error("session.close() resulted in exception: {}", sessionId, x))
.onSuccess(() -> log.debug("session closed: {}", sessionId));
unbind(session.getSessionFactory());
}
}
代码示例来源:origin: jooby-project/jooby
.onSuccess(() -> callback.call(null, null))
.onFailure(x -> {
log.debug("png-fallback resulted in exception", x);
代码示例来源:origin: jooby-project/jooby
@Override
default void handle(final Request req, final Response rsp, final Chain chain) throws Throwable {
Sse sse = req.require(Sse.class);
String path = req.path();
rsp.send(new Deferred(deferred -> {
try {
sse.handshake(req, () -> {
Try.run(() -> handle(req, sse))
.onSuccess(() -> deferred.resolve(null))
.onFailure(ex -> {
deferred.reject(ex);
Logger log = LoggerFactory.getLogger(Sse.class);
log.error("execution of {} resulted in error", path, ex);
});
});
} catch (Exception ex) {
deferred.reject(ex);
}
}));
}
代码示例来源:origin: org.jooby/funzy
/**
* Run the given action if and only if this is a success.
*
* @param action Success listener.
* @return This try.
*/
@Override public Value<V> onSuccess(final Runnable action) {
super.onSuccess(action);
return this;
}
代码示例来源:origin: org.jooby/jooby-servlet
@Override
public void send(final ByteBuffer buffer) throws Exception {
Try.of(Channels.newChannel(rsp.getOutputStream()))
.run(channel -> channel.write(buffer))
.onSuccess(() -> committed = true);
}
代码示例来源:origin: org.jooby/jooby-hbm
public void end() {
try {
if (rollbackOnly) {
rollback();
} else {
commit();
}
} finally {
if (readOnly) {
setConnectionReadOnly(false);
}
String sessionId = oid(session);
log.debug("closing session: {}", sessionId);
Try.run(session::close)
.onFailure(x -> log.error("session.close() resulted in exception: {}", sessionId, x))
.onSuccess(() -> log.debug("session closed: {}", sessionId));
unbind(session.getSessionFactory());
}
}
代码示例来源:origin: org.jooby/jooby
@Override
default void handle(final Request req, final Response rsp, final Chain chain) throws Throwable {
Sse sse = req.require(Sse.class);
String path = req.path();
rsp.send(new Deferred(deferred -> {
try {
sse.handshake(req, () -> {
Try.run(() -> handle(req, sse))
.onSuccess(() -> deferred.resolve(null))
.onFailure(ex -> {
deferred.reject(ex);
Logger log = LoggerFactory.getLogger(Sse.class);
log.error("execution of {} resulted in error", path, ex);
});
});
} catch (Exception ex) {
deferred.reject(ex);
}
}));
}
内容来源于网络,如有侵权,请联系作者删除!