Java Code Examples for org.springframework.util.concurrent.ListenableFutureTask#run()
The following examples show how to use
org.springframework.util.concurrent.ListenableFutureTask#run() .
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: StompBrokerRelayMessageHandlerTests.java From spring-analysis-note with MIT License | 5 votes |
private static ListenableFutureTask<Void> getVoidFuture() { ListenableFutureTask<Void> futureTask = new ListenableFutureTask<>(new Callable<Void>() { @Override public Void call() throws Exception { return null; } }); futureTask.run(); return futureTask; }
Example 2
Source File: StompBrokerRelayMessageHandlerTests.java From spring-analysis-note with MIT License | 5 votes |
private static ListenableFutureTask<Boolean> getBooleanFuture() { ListenableFutureTask<Boolean> futureTask = new ListenableFutureTask<>(new Callable<Boolean>() { @Override public Boolean call() throws Exception { return null; } }); futureTask.run(); return futureTask; }
Example 3
Source File: StandardWebSocketClient.java From spring-analysis-note with MIT License | 5 votes |
@Override protected ListenableFuture<WebSocketSession> doHandshakeInternal(WebSocketHandler webSocketHandler, HttpHeaders headers, final URI uri, List<String> protocols, List<WebSocketExtension> extensions, Map<String, Object> attributes) { int port = getPort(uri); InetSocketAddress localAddress = new InetSocketAddress(getLocalHost(), port); InetSocketAddress remoteAddress = new InetSocketAddress(uri.getHost(), port); final StandardWebSocketSession session = new StandardWebSocketSession(headers, attributes, localAddress, remoteAddress); final ClientEndpointConfig endpointConfig = ClientEndpointConfig.Builder.create() .configurator(new StandardWebSocketClientConfigurator(headers)) .preferredSubprotocols(protocols) .extensions(adaptExtensions(extensions)).build(); endpointConfig.getUserProperties().putAll(getUserProperties()); final Endpoint endpoint = new StandardWebSocketHandlerAdapter(webSocketHandler, session); Callable<WebSocketSession> connectTask = () -> { this.webSocketContainer.connectToServer(endpoint, endpointConfig, uri); return session; }; if (this.taskExecutor != null) { return this.taskExecutor.submitListenable(connectTask); } else { ListenableFutureTask<WebSocketSession> task = new ListenableFutureTask<>(connectTask); task.run(); return task; } }
Example 4
Source File: JettyWebSocketClient.java From spring-analysis-note with MIT License | 5 votes |
@Override public ListenableFuture<WebSocketSession> doHandshakeInternal(WebSocketHandler wsHandler, HttpHeaders headers, final URI uri, List<String> protocols, List<WebSocketExtension> extensions, Map<String, Object> attributes) { final ClientUpgradeRequest request = new ClientUpgradeRequest(); request.setSubProtocols(protocols); for (WebSocketExtension e : extensions) { request.addExtensions(new WebSocketToJettyExtensionConfigAdapter(e)); } headers.forEach(request::setHeader); Principal user = getUser(); final JettyWebSocketSession wsSession = new JettyWebSocketSession(attributes, user); final JettyWebSocketHandlerAdapter listener = new JettyWebSocketHandlerAdapter(wsHandler, wsSession); Callable<WebSocketSession> connectTask = () -> { Future<Session> future = this.client.connect(listener, uri, request); future.get(); return wsSession; }; if (this.taskExecutor != null) { return this.taskExecutor.submitListenable(connectTask); } else { ListenableFutureTask<WebSocketSession> task = new ListenableFutureTask<>(connectTask); task.run(); return task; } }
Example 5
Source File: AsyncTests.java From spring-analysis-note with MIT License | 5 votes |
void onMessage(String name) { for (DeferredResult<Person> deferredResult : this.deferredResults) { deferredResult.setResult(new Person(name)); this.deferredResults.remove(deferredResult); } for (ListenableFutureTask<Person> futureTask : this.futureTasks) { futureTask.run(); this.futureTasks.remove(futureTask); } }
Example 6
Source File: StompBrokerRelayMessageHandlerTests.java From java-technology-stack with MIT License | 5 votes |
private static ListenableFutureTask<Void> getVoidFuture() { ListenableFutureTask<Void> futureTask = new ListenableFutureTask<>(new Callable<Void>() { @Override public Void call() throws Exception { return null; } }); futureTask.run(); return futureTask; }
Example 7
Source File: StompBrokerRelayMessageHandlerTests.java From java-technology-stack with MIT License | 5 votes |
private static ListenableFutureTask<Boolean> getBooleanFuture() { ListenableFutureTask<Boolean> futureTask = new ListenableFutureTask<>(new Callable<Boolean>() { @Override public Boolean call() throws Exception { return null; } }); futureTask.run(); return futureTask; }
Example 8
Source File: StandardWebSocketClient.java From java-technology-stack with MIT License | 5 votes |
@Override protected ListenableFuture<WebSocketSession> doHandshakeInternal(WebSocketHandler webSocketHandler, HttpHeaders headers, final URI uri, List<String> protocols, List<WebSocketExtension> extensions, Map<String, Object> attributes) { int port = getPort(uri); InetSocketAddress localAddress = new InetSocketAddress(getLocalHost(), port); InetSocketAddress remoteAddress = new InetSocketAddress(uri.getHost(), port); final StandardWebSocketSession session = new StandardWebSocketSession(headers, attributes, localAddress, remoteAddress); final ClientEndpointConfig endpointConfig = ClientEndpointConfig.Builder.create() .configurator(new StandardWebSocketClientConfigurator(headers)) .preferredSubprotocols(protocols) .extensions(adaptExtensions(extensions)).build(); endpointConfig.getUserProperties().putAll(getUserProperties()); final Endpoint endpoint = new StandardWebSocketHandlerAdapter(webSocketHandler, session); Callable<WebSocketSession> connectTask = () -> { this.webSocketContainer.connectToServer(endpoint, endpointConfig, uri); return session; }; if (this.taskExecutor != null) { return this.taskExecutor.submitListenable(connectTask); } else { ListenableFutureTask<WebSocketSession> task = new ListenableFutureTask<>(connectTask); task.run(); return task; } }
Example 9
Source File: JettyWebSocketClient.java From java-technology-stack with MIT License | 5 votes |
@Override public ListenableFuture<WebSocketSession> doHandshakeInternal(WebSocketHandler wsHandler, HttpHeaders headers, final URI uri, List<String> protocols, List<WebSocketExtension> extensions, Map<String, Object> attributes) { final ClientUpgradeRequest request = new ClientUpgradeRequest(); request.setSubProtocols(protocols); for (WebSocketExtension e : extensions) { request.addExtensions(new WebSocketToJettyExtensionConfigAdapter(e)); } headers.forEach(request::setHeader); Principal user = getUser(); final JettyWebSocketSession wsSession = new JettyWebSocketSession(attributes, user); final JettyWebSocketHandlerAdapter listener = new JettyWebSocketHandlerAdapter(wsHandler, wsSession); Callable<WebSocketSession> connectTask = () -> { Future<Session> future = this.client.connect(listener, uri, request); future.get(); return wsSession; }; if (this.taskExecutor != null) { return this.taskExecutor.submitListenable(connectTask); } else { ListenableFutureTask<WebSocketSession> task = new ListenableFutureTask<>(connectTask); task.run(); return task; } }
Example 10
Source File: AsyncTests.java From java-technology-stack with MIT License | 5 votes |
void onMessage(String name) { for (DeferredResult<Person> deferredResult : this.deferredResults) { deferredResult.setResult(new Person(name)); this.deferredResults.remove(deferredResult); } for (ListenableFutureTask<Person> futureTask : this.futureTasks) { futureTask.run(); this.futureTasks.remove(futureTask); } }
Example 11
Source File: StompBrokerRelayMessageHandlerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
private static ListenableFutureTask<Void> getVoidFuture() { ListenableFutureTask<Void> futureTask = new ListenableFutureTask<>(new Callable<Void>() { @Override public Void call() throws Exception { return null; } }); futureTask.run(); return futureTask; }
Example 12
Source File: StompBrokerRelayMessageHandlerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
private static ListenableFutureTask<Boolean> getBooleanFuture() { ListenableFutureTask<Boolean> futureTask = new ListenableFutureTask<>(new Callable<Boolean>() { @Override public Boolean call() throws Exception { return null; } }); futureTask.run(); return futureTask; }
Example 13
Source File: StandardWebSocketClient.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override protected ListenableFuture<WebSocketSession> doHandshakeInternal(WebSocketHandler webSocketHandler, HttpHeaders headers, final URI uri, List<String> protocols, List<WebSocketExtension> extensions, Map<String, Object> attributes) { int port = getPort(uri); InetSocketAddress localAddress = new InetSocketAddress(getLocalHost(), port); InetSocketAddress remoteAddress = new InetSocketAddress(uri.getHost(), port); final StandardWebSocketSession session = new StandardWebSocketSession(headers, attributes, localAddress, remoteAddress); final ClientEndpointConfig endpointConfig = ClientEndpointConfig.Builder.create() .configurator(new StandardWebSocketClientConfigurator(headers)) .preferredSubprotocols(protocols) .extensions(adaptExtensions(extensions)).build(); endpointConfig.getUserProperties().putAll(getUserProperties()); final Endpoint endpoint = new StandardWebSocketHandlerAdapter(webSocketHandler, session); Callable<WebSocketSession> connectTask = new Callable<WebSocketSession>() { @Override public WebSocketSession call() throws Exception { webSocketContainer.connectToServer(endpoint, endpointConfig, uri); return session; } }; if (this.taskExecutor != null) { return this.taskExecutor.submitListenable(connectTask); } else { ListenableFutureTask<WebSocketSession> task = new ListenableFutureTask<WebSocketSession>(connectTask); task.run(); return task; } }
Example 14
Source File: JettyWebSocketClient.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public ListenableFuture<WebSocketSession> doHandshakeInternal(WebSocketHandler wsHandler, HttpHeaders headers, final URI uri, List<String> protocols, List<WebSocketExtension> extensions, Map<String, Object> attributes) { final ClientUpgradeRequest request = new ClientUpgradeRequest(); request.setSubProtocols(protocols); for (WebSocketExtension e : extensions) { request.addExtensions(new WebSocketToJettyExtensionConfigAdapter(e)); } for (String header : headers.keySet()) { request.setHeader(header, headers.get(header)); } Principal user = getUser(); final JettyWebSocketSession wsSession = new JettyWebSocketSession(attributes, user); final JettyWebSocketHandlerAdapter listener = new JettyWebSocketHandlerAdapter(wsHandler, wsSession); Callable<WebSocketSession> connectTask = new Callable<WebSocketSession>() { @Override public WebSocketSession call() throws Exception { Future<Session> future = client.connect(listener, uri, request); future.get(); return wsSession; } }; if (this.taskExecutor != null) { return this.taskExecutor.submitListenable(connectTask); } else { ListenableFutureTask<WebSocketSession> task = new ListenableFutureTask<WebSocketSession>(connectTask); task.run(); return task; } }
Example 15
Source File: AsyncTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
public void onMessage(String name) { for (DeferredResult<Person> deferredResult : this.deferredResults) { deferredResult.setResult(new Person(name)); this.deferredResults.remove(deferredResult); } for (ListenableFutureTask<Person> futureTask : this.futureTasks) { futureTask.run(); this.futureTasks.remove(futureTask); } }