Java Code Examples for org.springframework.util.concurrent.SettableListenableFuture#set()
The following examples show how to use
org.springframework.util.concurrent.SettableListenableFuture#set() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebSocketStompClient.java From spring-analysis-note with MIT License | 6 votes |
@Override public ListenableFuture<Void> send(Message<byte[]> message) { updateLastWriteTime(); SettableListenableFuture<Void> future = new SettableListenableFuture<>(); try { WebSocketSession session = this.session; Assert.state(session != null, "No WebSocketSession available"); session.sendMessage(this.codec.encode(message, session.getClass())); future.set(null); } catch (Throwable ex) { future.setException(ex); } finally { updateLastWriteTime(); } return future; }
Example 2
Source File: WebSocketStompClient.java From java-technology-stack with MIT License | 6 votes |
@Override public ListenableFuture<Void> send(Message<byte[]> message) { updateLastWriteTime(); SettableListenableFuture<Void> future = new SettableListenableFuture<>(); try { WebSocketSession session = this.session; Assert.state(session != null, "No WebSocketSession available"); session.sendMessage(this.codec.encode(message, session.getClass())); future.set(null); } catch (Throwable ex) { future.setException(ex); } finally { updateLastWriteTime(); } return future; }
Example 3
Source File: WebSocketStompClient.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Override public ListenableFuture<Void> send(Message<byte[]> message) { updateLastWriteTime(); SettableListenableFuture<Void> future = new SettableListenableFuture<Void>(); try { this.session.sendMessage(this.codec.encode(message, this.session.getClass())); future.set(null); } catch (Throwable ex) { future.setException(ex); } finally { updateLastWriteTime(); } return future; }
Example 4
Source File: ReactorNettyTcpClient.java From spring-analysis-note with MIT License | 5 votes |
@Override public ListenableFuture<Void> shutdown() { if (this.stopping) { SettableListenableFuture<Void> future = new SettableListenableFuture<>(); future.set(null); return future; } this.stopping = true; Mono<Void> result; if (this.channelGroup != null) { result = FutureMono.from(this.channelGroup.close()); if (this.loopResources != null) { result = result.onErrorResume(ex -> Mono.empty()).then(this.loopResources.disposeLater()); } if (this.poolResources != null) { result = result.onErrorResume(ex -> Mono.empty()).then(this.poolResources.disposeLater()); } result = result.onErrorResume(ex -> Mono.empty()).then(stopScheduler()); } else { result = stopScheduler(); } return new MonoToListenableFutureAdapter<>(result); }
Example 5
Source File: DefaultStompSessionTests.java From spring-analysis-note with MIT License | 5 votes |
@Before public void setUp() { MockitoAnnotations.initMocks(this); this.sessionHandler = mock(StompSessionHandler.class); this.connectHeaders = new StompHeaders(); this.session = new DefaultStompSession(this.sessionHandler, this.connectHeaders); this.session.setMessageConverter(new StringMessageConverter()); SettableListenableFuture<Void> future = new SettableListenableFuture<>(); future.set(null); given(this.connection.send(this.messageCaptor.capture())).willReturn(future); }
Example 6
Source File: ReactorNettyTcpClient.java From java-technology-stack with MIT License | 5 votes |
@Override public ListenableFuture<Void> shutdown() { if (this.stopping) { SettableListenableFuture<Void> future = new SettableListenableFuture<>(); future.set(null); return future; } this.stopping = true; Mono<Void> result; if (this.channelGroup != null) { result = FutureMono.from(this.channelGroup.close()); if (this.loopResources != null) { result = result.onErrorResume(ex -> Mono.empty()).then(this.loopResources.disposeLater()); } if (this.poolResources != null) { result = result.onErrorResume(ex -> Mono.empty()).then(this.poolResources.disposeLater()); } result = result.onErrorResume(ex -> Mono.empty()).then(stopScheduler()); } else { result = stopScheduler(); } return new MonoToListenableFutureAdapter<>(result); }
Example 7
Source File: DefaultStompSessionTests.java From java-technology-stack with MIT License | 5 votes |
@Before public void setUp() { MockitoAnnotations.initMocks(this); this.sessionHandler = mock(StompSessionHandler.class); this.connectHeaders = new StompHeaders(); this.session = new DefaultStompSession(this.sessionHandler, this.connectHeaders); this.session.setMessageConverter(new StringMessageConverter()); SettableListenableFuture<Void> future = new SettableListenableFuture<>(); future.set(null); when(this.connection.send(this.messageCaptor.capture())).thenReturn(future); }
Example 8
Source File: PubSubSubscriberTemplate.java From spring-cloud-gcp with Apache License 2.0 | 5 votes |
@Override public ListenableFuture<Void> ack() { SettableListenableFuture<Void> settableListenableFuture = new SettableListenableFuture<>(); try { this.ackReplyConsumer.ack(); settableListenableFuture.set(null); } catch (Throwable throwable) { settableListenableFuture.setException(throwable); } return settableListenableFuture; }
Example 9
Source File: PubSubSubscriberTemplate.java From spring-cloud-gcp with Apache License 2.0 | 5 votes |
@Override public ListenableFuture<Void> nack() { SettableListenableFuture<Void> settableListenableFuture = new SettableListenableFuture<>(); try { this.ackReplyConsumer.nack(); settableListenableFuture.set(null); } catch (Throwable throwable) { settableListenableFuture.setException(throwable); } return settableListenableFuture; }
Example 10
Source File: PubSubMessageHandlerTests.java From spring-cloud-gcp with Apache License 2.0 | 5 votes |
@Before public void setUp() { this.message = new GenericMessage<byte[]>("testPayload".getBytes(), new MapBuilder<String, Object>() .put("key1", "value1") .put("key2", "value2") .build()); SettableListenableFuture<String> future = new SettableListenableFuture<>(); future.set("benfica"); when(this.pubSubTemplate.publish(eq("testTopic"), eq("testPayload".getBytes()), isA(Map.class))) .thenReturn(future); this.adapter = new PubSubMessageHandler(this.pubSubTemplate, "testTopic"); }
Example 11
Source File: DefaultStompSessionTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); this.sessionHandler = mock(StompSessionHandler.class); this.connectHeaders = new StompHeaders(); this.session = new DefaultStompSession(this.sessionHandler, this.connectHeaders); this.session.setMessageConverter(new StringMessageConverter()); SettableListenableFuture<Void> future = new SettableListenableFuture<>(); future.set(null); when(this.connection.send(this.messageCaptor.capture())).thenReturn(future); }
Example 12
Source File: MockAsyncClientHttpRequest.java From spring-analysis-note with MIT License | 4 votes |
@Override public ListenableFuture<ClientHttpResponse> executeAsync() throws IOException { SettableListenableFuture<ClientHttpResponse> future = new SettableListenableFuture<>(); future.set(execute()); return future; }
Example 13
Source File: MockAsyncClientHttpRequest.java From java-technology-stack with MIT License | 4 votes |
@Override public ListenableFuture<ClientHttpResponse> executeAsync() throws IOException { SettableListenableFuture<ClientHttpResponse> future = new SettableListenableFuture<>(); future.set(execute()); return future; }
Example 14
Source File: MockAsyncClientHttpRequest.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public ListenableFuture<ClientHttpResponse> executeAsync() throws IOException { SettableListenableFuture<ClientHttpResponse> future = new SettableListenableFuture<ClientHttpResponse>(); future.set(execute()); return future; }
Example 15
Source File: SpringOriginalFutureTestHelper.java From future-converter with Apache License 2.0 | 4 votes |
@Override public ListenableFuture<String> createFinishedFuture() { SettableListenableFuture<String> future = new SettableListenableFuture<>(); future.set(AbstractConverterTest.VALUE); return future; }