本文整理汇总了Java中org.springframework.web.context.request.async.DeferredResult.onCompletion方法的典型用法代码示例。如果您正苦于以下问题:Java DeferredResult.onCompletion方法的具体用法?Java DeferredResult.onCompletion怎么用?Java DeferredResult.onCompletion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.web.context.request.async.DeferredResult
的用法示例。
在下文中一共展示了DeferredResult.onCompletion方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tagError
import org.springframework.web.context.request.async.DeferredResult; //导入方法依赖的package包/类
@RequestMapping(value = "/tagerror")
@ResponseBody
public DeferredResult<List<TagError>> tagError(@RequestParam Long errorDateTimestamp, @RequestParam(required=false) String numeroId) {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if(numeroId==null && !auth.getAuthorities().contains(new GrantedAuthorityImpl("ROLE_ADMIN")) && !auth.getAuthorities().contains(new GrantedAuthorityImpl("ROLE_SUPERVISOR"))) {
return null;
}
LiveQuery liveQuery = new LiveQuery(errorDateTimestamp, numeroId);
final DeferredResult<List<TagError>> tagErrors = new DeferredResult<List<TagError>>(null, Collections.emptyList());
this.suspendedTagErrorsRequests.put(tagErrors, liveQuery);
tagErrors.onCompletion(new Runnable() {
public void run() {
suspendedTagErrorsRequests.remove(tagErrors);
}
});
return tagErrors;
}
示例2: searchPoll
import org.springframework.web.context.request.async.DeferredResult; //导入方法依赖的package包/类
@RequestMapping
@ResponseBody
public DeferredResult<String> searchPoll(HttpServletRequest request) {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
final String authName = auth.getName();
final DeferredResult<String> searchEppn = new DeferredResult<String>(null, null);
if(this.suspendedSearchPollRequests.containsKey(authName)) {
this.suspendedSearchPollRequests.get(authName).setResult("stop");
}
this.suspendedSearchPollRequests.put(authName, searchEppn);
searchEppn.onCompletion(new Runnable() {
public void run() {
synchronized (searchEppn) {
if(searchEppn.equals(suspendedSearchPollRequests.get(authName))) {
suspendedSearchPollRequests.remove(authName);
}
}
}
});
// log.info("this.suspendedSearchPollRequests.size : " + this.suspendedSearchPollRequests.size());
return searchEppn;
}
示例3: listLeoAuth
import org.springframework.web.context.request.async.DeferredResult; //导入方法依赖的package包/类
@RequestMapping(value = "/taglogs")
@ResponseBody
public DeferredResult<List<TagLog>> listLeoAuth(@RequestParam Long authDateTimestamp, @RequestParam(required=false) String numeroId) {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
// admin ou tel
if(numeroId==null && !isLiveLongPoolAuthorized(auth)) {
return null;
}
LiveQuery liveQuery = new LiveQuery(authDateTimestamp, numeroId);
final DeferredResult<List<TagLog>> tagLogs = new DeferredResult<List<TagLog>>(null, Collections.emptyList());
this.suspendedLeoAuthsRequests.put(tagLogs, liveQuery);
tagLogs.onCompletion(new Runnable() {
public void run() {
suspendedLeoAuthsRequests.remove(tagLogs);
}
});
List<TagLog> list = getLatestLeoAuths(liveQuery);
if (!list.isEmpty()) {
tagLogs.setResult(list);
}
return tagLogs;
}
示例4: subscribe
import org.springframework.web.context.request.async.DeferredResult; //导入方法依赖的package包/类
@Override
public DeferredResult<Collection<Notification>> subscribe(Integer userId, Object timeoutResult) {
final DeferredResult<Collection<Notification>> result = new DeferredResult<>(TIMEOUT, timeoutResult);
result.onCompletion(() -> notifier.unsubscribe(userId));
final DeferredConnection<Collection<Notification>> connection = new DeferredConnection<>(result,
() -> getUnread(userId));
notifier.subscribe(userId, connection);
return result;
}