當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。