Spring Framework DeferredResult - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework DeferredResult class.

This code example shows how to use the following methods:
public class MyDefferedResultController { 
 
    @RequestMapping("/myDefferedResult1") 
    @ResponseBody 
    public DeferredResult<String> myDefferedResult1() {
        final DeferredResult<String> result = new DeferredResult<String>();
        new Thread(new Runnable() {
            @Override 
            public void run() { 
                try { 
                    Thread.sleep(2 * 1000L);
                } catch (InterruptedException e) {
                } 
                System.out.println("设置DeferredResult的成功时结果");
                result.setResult("success");
            } 
        }).start();
        return result;
    } 
 
4
CodeRank
This code example shows how to use the following methods:
	DeferredResult<String> deferredResult;
	 
	@RequestMapping("/get_message") 
	@ResponseBody 
	public DeferredResult<String> mainPage() {
		deferredResult = new DeferredResult<String>(null, "timeout");
		return deferredResult;
	} 
	 
	@RequestMapping("/send_message") 
	@ResponseBody 
	public String sendMessage() {
		deferredResult.setResult("message");
		return "sent message"; 
	} 
 
	@ExceptionHandler 
	@ResponseBody 
	public String handleException(IllegalStateException ex) {
		return "Handled exception: " + ex.getMessage();
4
CodeRank
This code example shows how to use the following methods:
 
	@RequestMapping("/matchupdate/deferred") 
	@ResponseBody 
	public DeferredResult<Message> getUpdate() { 
 
		final DeferredResult<Message> result = new DeferredResult<Message>(); 
		updateService.getUpdate(result); 
		return result; 
	} 
} 
5
CodeRank
This code example shows how to use the following methods:
 
	private static class MethodLevelResponseBodyHandler { 
 
		@ResponseBody 
		public DeferredResult<String> handle() { 
			return new DeferredResult<>(); 
		} 
	} 
 
	@ResponseBody 
	private static class TypeLevelResponseBodyHandler { 
 
		@SuppressWarnings("unused") 
		public DeferredResult<String> handle() { 
			return new DeferredResult<String>(); 
		} 
	} 
 
	private static class ResponseEntityHandler { 
 
5
CodeRank
See Code Examples for Spring Framework DeferredResult Methods: