当前位置: 首页>>代码示例>>Java>>正文


Java DeferredResult.onCompletion方法代码示例

本文整理汇总了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;
}
 
开发者ID:EsupPortail,项目名称:esup-nfc-tag-server,代码行数:21,代码来源:ErrorLongPoolController.java

示例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;
}
 
开发者ID:EsupPortail,项目名称:esup-sgc,代码行数:29,代码来源:SearchLongPollController.java

示例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;
}
 
开发者ID:EsupPortail,项目名称:esup-nfc-tag-server,代码行数:28,代码来源:LiveLongPoolController.java

示例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;
}
 
开发者ID:music-for-all,项目名称:music-for-all-application,代码行数:11,代码来源:NotificationServiceImpl.java


注:本文中的org.springframework.web.context.request.async.DeferredResult.onCompletion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。