org.springframework.util.concurrent.SettableListenableFuture Java Examples

The following examples show how to use org.springframework.util.concurrent.SettableListenableFuture. 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: NettyRequest.java    From haven-platform with Apache License 2.0 6 votes vote down vote up
protected ListenableFuture<ClientHttpResponse> executeInternal(final HttpHeaders headers) {
    final SettableListenableFuture<ClientHttpResponse> responseFuture = new SettableListenableFuture<>();

    ChannelFutureListener connectionListener = future -> {
        if (future.isSuccess()) {
            Channel channel = future.channel();
            channel.pipeline().addLast(new NettyResponseHandler(responseFuture));
            FullHttpRequest nettyRequest = createFullHttpRequest(headers);
            channel.writeAndFlush(nettyRequest);
        }
        else {
            responseFuture.setException(future.cause());
        }
    };

    this.bootstrap.connect(this.uri.getHost(), getPort(this.uri)).addListener(connectionListener);

    return responseFuture;
}
 
Example #2
Source File: Netty4ClientHttpRequest.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Override
protected ListenableFuture<ClientHttpResponse> executeInternal(final HttpHeaders headers) throws IOException {
	final SettableListenableFuture<ClientHttpResponse> responseFuture = new SettableListenableFuture<>();

	ChannelFutureListener connectionListener = future -> {
		if (future.isSuccess()) {
			Channel channel = future.channel();
			channel.pipeline().addLast(new RequestExecuteHandler(responseFuture));
			FullHttpRequest nettyRequest = createFullHttpRequest(headers);
			channel.writeAndFlush(nettyRequest);
		}
		else {
			responseFuture.setException(future.cause());
		}
	};

	this.bootstrap.connect(this.uri.getHost(), getPort(this.uri)).addListener(connectionListener);
	return responseFuture;
}
 
Example #3
Source File: Netty4ClientHttpRequest.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Override
protected ListenableFuture<ClientHttpResponse> executeInternal(final HttpHeaders headers) throws IOException {
	final SettableListenableFuture<ClientHttpResponse> responseFuture = new SettableListenableFuture<>();

	ChannelFutureListener connectionListener = future -> {
		if (future.isSuccess()) {
			Channel channel = future.channel();
			channel.pipeline().addLast(new RequestExecuteHandler(responseFuture));
			FullHttpRequest nettyRequest = createFullHttpRequest(headers);
			channel.writeAndFlush(nettyRequest);
		}
		else {
			responseFuture.setException(future.cause());
		}
	};

	this.bootstrap.connect(this.uri.getHost(), getPort(this.uri)).addListener(connectionListener);
	return responseFuture;
}
 
Example #4
Source File: WebSocketStompClient.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@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 #5
Source File: Netty4ClientHttpRequest.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected ListenableFuture<ClientHttpResponse> executeInternal(final HttpHeaders headers) throws IOException {
	final SettableListenableFuture<ClientHttpResponse> responseFuture =
			new SettableListenableFuture<ClientHttpResponse>();

	ChannelFutureListener connectionListener = new ChannelFutureListener() {
		@Override
		public void operationComplete(ChannelFuture future) throws Exception {
			if (future.isSuccess()) {
				Channel channel = future.channel();
				channel.pipeline().addLast(new RequestExecuteHandler(responseFuture));
				FullHttpRequest nettyRequest = createFullHttpRequest(headers);
				channel.writeAndFlush(nettyRequest);
			}
			else {
				responseFuture.setException(future.cause());
			}
		}
	};

	this.bootstrap.connect(this.uri.getHost(), getPort(this.uri)).addListener(connectionListener);
	return responseFuture;
}
 
Example #6
Source File: PubSubSubscriberTemplate.java    From spring-cloud-gcp with Apache License 2.0 6 votes vote down vote up
/**
 * Pulls messages asynchronously, on demand, using the pull request in argument.
 *
 * @param pullRequest pull request containing the subscription name
 * @return the ListenableFuture for the asynchronous execution, returning
 * the list of {@link AcknowledgeablePubsubMessage} containing the ack ID, subscription
 * and acknowledger
 */
private ListenableFuture<List<AcknowledgeablePubsubMessage>> pullAsync(PullRequest pullRequest) {
	Assert.notNull(pullRequest, "The pull request can't be null.");

	ApiFuture<PullResponse> pullFuture = this.subscriberStub.pullCallable().futureCall(pullRequest);

	final SettableListenableFuture<List<AcknowledgeablePubsubMessage>> settableFuture = new SettableListenableFuture<>();
	ApiFutures.addCallback(pullFuture, new ApiFutureCallback<PullResponse>() {

		@Override
		public void onFailure(Throwable throwable) {
			settableFuture.setException(throwable);
		}

		@Override
		public void onSuccess(PullResponse pullResponse) {
			List<AcknowledgeablePubsubMessage> result = toAcknowledgeablePubsubMessageList(
					pullResponse.getReceivedMessagesList(), pullRequest.getSubscription());

			settableFuture.set(result);
		}

	}, asyncPullExecutor);

	return settableFuture;
}
 
Example #7
Source File: SockJsClient.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
public final ListenableFuture<WebSocketSession> doHandshake(
		WebSocketHandler handler, WebSocketHttpHeaders headers, URI url) {

	Assert.notNull(handler, "WebSocketHandler is required");
	Assert.notNull(url, "URL is required");

	String scheme = url.getScheme();
	if (!supportedProtocols.contains(scheme)) {
		throw new IllegalArgumentException("Invalid scheme: '" + scheme + "'");
	}

	SettableListenableFuture<WebSocketSession> connectFuture = new SettableListenableFuture<WebSocketSession>();
	try {
		SockJsUrlInfo sockJsUrlInfo = new SockJsUrlInfo(url);
		ServerInfo serverInfo = getServerInfo(sockJsUrlInfo, getHttpRequestHeaders(headers));
		createRequest(sockJsUrlInfo, headers, serverInfo).connect(handler, connectFuture);
	}
	catch (Throwable exception) {
		if (logger.isErrorEnabled()) {
			logger.error("Initial SockJS \"Info\" request to server failed, url=" + url, exception);
		}
		connectFuture.setException(exception);
	}
	return connectFuture;
}
 
Example #8
Source File: AbstractXhrTransport.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Override
public ListenableFuture<WebSocketSession> connect(TransportRequest request, WebSocketHandler handler) {
	SettableListenableFuture<WebSocketSession> connectFuture = new SettableListenableFuture<>();
	XhrClientSockJsSession session = new XhrClientSockJsSession(request, handler, this, connectFuture);
	request.addTimeoutTask(session.getTimeoutTask());

	URI receiveUrl = request.getTransportUrl();
	if (logger.isDebugEnabled()) {
		logger.debug("Starting XHR " +
				(isXhrStreamingDisabled() ? "Polling" : "Streaming") + "session url=" + receiveUrl);
	}

	HttpHeaders handshakeHeaders = new HttpHeaders();
	handshakeHeaders.putAll(request.getHandshakeHeaders());

	connectInternal(request, handler, receiveUrl, handshakeHeaders, session, connectFuture);
	return connectFuture;
}
 
Example #9
Source File: SockJsClient.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Override
public final ListenableFuture<WebSocketSession> doHandshake(
		WebSocketHandler handler, @Nullable WebSocketHttpHeaders headers, URI url) {

	Assert.notNull(handler, "WebSocketHandler is required");
	Assert.notNull(url, "URL is required");

	String scheme = url.getScheme();
	if (!supportedProtocols.contains(scheme)) {
		throw new IllegalArgumentException("Invalid scheme: '" + scheme + "'");
	}

	SettableListenableFuture<WebSocketSession> connectFuture = new SettableListenableFuture<>();
	try {
		SockJsUrlInfo sockJsUrlInfo = new SockJsUrlInfo(url);
		ServerInfo serverInfo = getServerInfo(sockJsUrlInfo, getHttpRequestHeaders(headers));
		createRequest(sockJsUrlInfo, headers, serverInfo).connect(handler, connectFuture);
	}
	catch (Throwable exception) {
		if (logger.isErrorEnabled()) {
			logger.error("Initial SockJS \"Info\" request to server failed, url=" + url, exception);
		}
		connectFuture.setException(exception);
	}
	return connectFuture;
}
 
Example #10
Source File: AbstractXhrTransport.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Override
public ListenableFuture<WebSocketSession> connect(TransportRequest request, WebSocketHandler handler) {
	SettableListenableFuture<WebSocketSession> connectFuture = new SettableListenableFuture<>();
	XhrClientSockJsSession session = new XhrClientSockJsSession(request, handler, this, connectFuture);
	request.addTimeoutTask(session.getTimeoutTask());

	URI receiveUrl = request.getTransportUrl();
	if (logger.isDebugEnabled()) {
		logger.debug("Starting XHR " +
				(isXhrStreamingDisabled() ? "Polling" : "Streaming") + "session url=" + receiveUrl);
	}

	HttpHeaders handshakeHeaders = new HttpHeaders();
	handshakeHeaders.putAll(request.getHandshakeHeaders());

	connectInternal(request, handler, receiveUrl, handshakeHeaders, session, connectFuture);
	return connectFuture;
}
 
Example #11
Source File: BigQueryTemplate.java    From spring-cloud-gcp with Apache License 2.0 6 votes vote down vote up
private SettableListenableFuture<Job> createJobFuture(Job pendingJob) {
	// Prepare the polling task for the ListenableFuture result returned to end-user
	SettableListenableFuture<Job> result = new SettableListenableFuture<>();

	ScheduledFuture<?> scheduledFuture = taskScheduler.scheduleAtFixedRate(() -> {
		Job job = pendingJob.reload();
		if (State.DONE.equals(job.getStatus().getState())) {
			if (job.getStatus().getError() != null) {
				result.setException(
						new BigQueryException(job.getStatus().getError().getMessage()));
			}
			else {
				result.set(job);
			}
		}
	}, this.jobPollInterval);

	result.addCallback(
			response -> scheduledFuture.cancel(true),
			response -> {
				pendingJob.cancel();
				scheduledFuture.cancel(true);
			});

	return result;
}
 
Example #12
Source File: DefaultStompSessionTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void sendWithExecutionException() {
	this.session.afterConnected(this.connection);
	assertTrue(this.session.isConnected());

	IllegalStateException exception = new IllegalStateException("simulated exception");
	SettableListenableFuture<Void> future = new SettableListenableFuture<>();
	future.setException(exception);

	when(this.connection.send(any())).thenReturn(future);
	this.expected.expect(MessageDeliveryException.class);
	this.expected.expectCause(Matchers.sameInstance(exception));

	this.session.send("/topic/foo", "sample payload".getBytes(StandardCharsets.UTF_8));

	verifyNoMoreInteractions(this.connection);
}
 
Example #13
Source File: DefaultStompSessionTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void sendWithExecutionException() throws Exception {

	this.session.afterConnected(this.connection);
	assertTrue(this.session.isConnected());

	IllegalStateException exception = new IllegalStateException("simulated exception");
	SettableListenableFuture<Void> future = new SettableListenableFuture<>();
	future.setException(exception);

	when(this.connection.send(any())).thenReturn(future);
	this.expected.expect(MessageDeliveryException.class);
	this.expected.expectCause(Matchers.sameInstance(exception));

	this.session.send("/topic/foo", "sample payload".getBytes(UTF_8));

	verifyNoMoreInteractions(this.connection);
}
 
Example #14
Source File: WebSocketTransport.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
public ListenableFuture<WebSocketSession> connect(TransportRequest request, WebSocketHandler handler) {
	final SettableListenableFuture<WebSocketSession> future = new SettableListenableFuture<WebSocketSession>();
	WebSocketClientSockJsSession session = new WebSocketClientSockJsSession(request, handler, future);
	handler = new ClientSockJsWebSocketHandler(session);
	request.addTimeoutTask(session.getTimeoutTask());

	URI url = request.getTransportUrl();
	WebSocketHttpHeaders headers = new WebSocketHttpHeaders(request.getHandshakeHeaders());
	if (logger.isDebugEnabled()) {
		logger.debug("Starting WebSocket session url=" + url);
	}
	this.webSocketClient.doHandshake(handler, headers, url).addCallback(
			new ListenableFutureCallback<WebSocketSession>() {
				@Override
				public void onSuccess(WebSocketSession webSocketSession) {
					// WebSocket session ready, SockJS Session not yet
				}
				@Override
				public void onFailure(Throwable ex) {
					future.setException(ex);
				}
			});
	return future;
}
 
Example #15
Source File: SockJsClient.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Override
public final ListenableFuture<WebSocketSession> doHandshake(
		WebSocketHandler handler, @Nullable WebSocketHttpHeaders headers, URI url) {

	Assert.notNull(handler, "WebSocketHandler is required");
	Assert.notNull(url, "URL is required");

	String scheme = url.getScheme();
	if (!supportedProtocols.contains(scheme)) {
		throw new IllegalArgumentException("Invalid scheme: '" + scheme + "'");
	}

	SettableListenableFuture<WebSocketSession> connectFuture = new SettableListenableFuture<>();
	try {
		SockJsUrlInfo sockJsUrlInfo = new SockJsUrlInfo(url);
		ServerInfo serverInfo = getServerInfo(sockJsUrlInfo, getHttpRequestHeaders(headers));
		createRequest(sockJsUrlInfo, headers, serverInfo).connect(handler, connectFuture);
	}
	catch (Throwable exception) {
		if (logger.isErrorEnabled()) {
			logger.error("Initial SockJS \"Info\" request to server failed, url=" + url, exception);
		}
		connectFuture.setException(exception);
	}
	return connectFuture;
}
 
Example #16
Source File: WebSocketTransport.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Override
public ListenableFuture<WebSocketSession> connect(TransportRequest request, WebSocketHandler handler) {
	final SettableListenableFuture<WebSocketSession> future = new SettableListenableFuture<>();
	WebSocketClientSockJsSession session = new WebSocketClientSockJsSession(request, handler, future);
	handler = new ClientSockJsWebSocketHandler(session);
	request.addTimeoutTask(session.getTimeoutTask());

	URI url = request.getTransportUrl();
	WebSocketHttpHeaders headers = new WebSocketHttpHeaders(request.getHandshakeHeaders());
	if (logger.isDebugEnabled()) {
		logger.debug("Starting WebSocket session on " + url);
	}
	this.webSocketClient.doHandshake(handler, headers, url).addCallback(
			new ListenableFutureCallback<WebSocketSession>() {
				@Override
				public void onSuccess(@Nullable WebSocketSession webSocketSession) {
					// WebSocket session ready, SockJS Session not yet
				}
				@Override
				public void onFailure(Throwable ex) {
					future.setException(ex);
				}
			});
	return future;
}
 
Example #17
Source File: WebSocketStompClient.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@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 #18
Source File: RestTemplateXhrTransport.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
protected void connectInternal(final TransportRequest transportRequest, final WebSocketHandler handler,
		final URI receiveUrl, final HttpHeaders handshakeHeaders, final XhrClientSockJsSession session,
		final SettableListenableFuture<WebSocketSession> connectFuture) {

	getTaskExecutor().execute(new Runnable() {
		@Override
		public void run() {
			HttpHeaders httpHeaders = transportRequest.getHttpRequestHeaders();
			XhrRequestCallback requestCallback = new XhrRequestCallback(handshakeHeaders);
			XhrRequestCallback requestCallbackAfterHandshake = new XhrRequestCallback(httpHeaders);
			XhrReceiveExtractor responseExtractor = new XhrReceiveExtractor(session);
			while (true) {
				if (session.isDisconnected()) {
					session.afterTransportClosed(null);
					break;
				}
				try {
					if (logger.isTraceEnabled()) {
						logger.trace("Starting XHR receive request, url=" + receiveUrl);
					}
					getRestTemplate().execute(receiveUrl, HttpMethod.POST, requestCallback, responseExtractor);
					requestCallback = requestCallbackAfterHandshake;
				}
				catch (Throwable ex) {
					if (!connectFuture.isDone()) {
						connectFuture.setException(ex);
					}
					else {
						session.handleTransportError(ex);
						session.afterTransportClosed(new CloseStatus(1006, ex.getMessage()));
					}
					break;
				}
			}
		}
	});
}
 
Example #19
Source File: AbstractClientSockJsSession.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
protected AbstractClientSockJsSession(TransportRequest request, WebSocketHandler handler,
		SettableListenableFuture<WebSocketSession> connectFuture) {

	Assert.notNull(request, "'request' is required");
	Assert.notNull(handler, "'handler' is required");
	Assert.notNull(connectFuture, "'connectFuture' is required");
	this.request = request;
	this.webSocketHandler = handler;
	this.connectFuture = connectFuture;
}
 
Example #20
Source File: DefaultStompSessionTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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 #21
Source File: PubSubMessageHandlerTests.java    From spring-cloud-gcp with Apache License 2.0 5 votes vote down vote up
@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 #22
Source File: PubSubPublisherTemplate.java    From spring-cloud-gcp with Apache License 2.0 5 votes vote down vote up
@Override
public ListenableFuture<String> publish(final String topic, PubsubMessage pubsubMessage) {
	Assert.hasText(topic, "The topic can't be null or empty.");
	Assert.notNull(pubsubMessage, "The pubsubMessage can't be null.");

	ApiFuture<String> publishFuture =
			this.publisherFactory.createPublisher(topic).publish(pubsubMessage);

	final SettableListenableFuture<String> settableFuture = new SettableListenableFuture<>();
	ApiFutures.addCallback(publishFuture, new ApiFutureCallback<String>() {

		@Override
		public void onFailure(Throwable throwable) {
			String errorMessage = "Publishing to " + topic + " topic failed.";
			LOGGER.warn(errorMessage, throwable);
			PubSubDeliveryException pubSubDeliveryException = new PubSubDeliveryException(pubsubMessage, errorMessage, throwable);
			settableFuture.setException(pubSubDeliveryException);
		}

		@Override
		public void onSuccess(String result) {
			if (LOGGER.isDebugEnabled()) {
				LOGGER.debug(
						"Publishing to " + topic + " was successful. Message ID: " + result);
			}
			settableFuture.set(result);
		}

	});

	return settableFuture;
}
 
Example #23
Source File: UndertowXhrTransport.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private void executeReceiveRequest(final TransportRequest transportRequest,
		final URI url, final HttpHeaders headers, final XhrClientSockJsSession session,
		final SettableListenableFuture<WebSocketSession> connectFuture) {

	if (logger.isTraceEnabled()) {
		logger.trace("Starting XHR receive request for " + url);
	}

	ClientCallback<ClientConnection> clientCallback = new ClientCallback<ClientConnection>() {
		@Override
		public void completed(ClientConnection connection) {
			ClientRequest request = new ClientRequest().setMethod(Methods.POST).setPath(url.getPath());
			HttpString headerName = HttpString.tryFromString(HttpHeaders.HOST);
			request.getRequestHeaders().add(headerName, url.getHost());
			addHttpHeaders(request, headers);
			HttpHeaders httpHeaders = transportRequest.getHttpRequestHeaders();
			connection.sendRequest(request, createReceiveCallback(transportRequest,
					url, httpHeaders, session, connectFuture));
		}

		@Override
		public void failed(IOException ex) {
			throw new SockJsTransportFailureException("Failed to execute request to " + url, ex);
		}
	};

	this.undertowBufferSupport.httpClientConnect(this.httpClient, clientCallback, url, worker, this.optionMap);
}
 
Example #24
Source File: UndertowXhrTransport.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
protected void connectInternal(TransportRequest request, WebSocketHandler handler, URI receiveUrl,
		HttpHeaders handshakeHeaders, XhrClientSockJsSession session,
		SettableListenableFuture<WebSocketSession> connectFuture) {

	executeReceiveRequest(request, receiveUrl, handshakeHeaders, session, connectFuture);
}
 
Example #25
Source File: DefaultTransportRequestTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Before
public void setup() throws Exception {
	this.connectCallback = mock(ListenableFutureCallback.class);
	this.connectFuture = new SettableListenableFuture<>();
	this.connectFuture.addCallback(this.connectCallback);
	this.webSocketTransport = new TestTransport("WebSocketTestTransport");
	this.xhrTransport = new TestTransport("XhrTestTransport");
}
 
Example #26
Source File: XhrTransportTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
protected void connectInternal(TransportRequest request, WebSocketHandler handler, URI receiveUrl,
		HttpHeaders handshakeHeaders, XhrClientSockJsSession session,
		SettableListenableFuture<WebSocketSession> connectFuture) {

	this.actualHandshakeHeaders = handshakeHeaders;
	this.actualSession = session;
}
 
Example #27
Source File: JettyXhrTransport.java    From java-technology-stack with MIT License 5 votes vote down vote up
public SockJsResponseListener(URI url, HttpHeaders headers,	XhrClientSockJsSession sockJsSession,
		SettableListenableFuture<WebSocketSession> connectFuture) {

	this.transportUrl = url;
	this.receiveHeaders = headers;
	this.connectFuture = connectFuture;
	this.sockJsSession = sockJsSession;
}
 
Example #28
Source File: JettyXhrTransport.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
protected void connectInternal(TransportRequest transportRequest, WebSocketHandler handler,
		URI url, HttpHeaders handshakeHeaders, XhrClientSockJsSession session,
		SettableListenableFuture<WebSocketSession> connectFuture) {

	HttpHeaders httpHeaders = transportRequest.getHttpRequestHeaders();
	SockJsResponseListener listener = new SockJsResponseListener(url, httpHeaders, session, connectFuture);
	executeReceiveRequest(url, handshakeHeaders, listener);
}
 
Example #29
Source File: UndertowXhrTransport.java    From java-technology-stack with MIT License 5 votes vote down vote up
public SockJsResponseListener(TransportRequest request, ClientConnection connection, URI url,
		HttpHeaders headers, XhrClientSockJsSession sockJsSession,
		SettableListenableFuture<WebSocketSession> connectFuture) {

	this.request = request;
	this.connection = connection;
	this.url = url;
	this.headers = headers;
	this.session = sockJsSession;
	this.connectFuture = connectFuture;
}
 
Example #30
Source File: UndertowXhrTransport.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
protected void connectInternal(TransportRequest request, WebSocketHandler handler, URI receiveUrl,
		HttpHeaders handshakeHeaders, XhrClientSockJsSession session,
		SettableListenableFuture<WebSocketSession> connectFuture) {

	executeReceiveRequest(request, receiveUrl, handshakeHeaders, session, connectFuture);
}