Java Code Examples for reactor.rx.Promises#prepare()

The following examples show how to use reactor.rx.Promises#prepare() . 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: Reactor2TcpClient.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
public Publisher<Void> apply(ChannelStream<Message<P>, Message<P>> channelStream) {
	Promise<Void> closePromise = Promises.prepare();
	this.connectionHandler.afterConnected(new Reactor2TcpConnection<P>(channelStream, closePromise));
	channelStream
			.finallyDo(new Consumer<Signal<Message<P>>>() {
				@Override
				public void accept(Signal<Message<P>> signal) {
					if (signal.isOnError()) {
						connectionHandler.handleFailure(signal.getThrowable());
					}
					else if (signal.isOnComplete()) {
						connectionHandler.afterConnectionClosed();
					}
				}
			})
			.consume(new Consumer<Message<P>>() {
				@Override
				public void accept(Message<P> message) {
					connectionHandler.handleMessage(message);
				}
			});

	return closePromise;
}
 
Example 2
Source File: Reactor2TcpConnection.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public ListenableFuture<Void> send(Message<P> message) {
	Promise<Void> afterWrite = Promises.prepare();
	this.channelStream.writeWith(Streams.just(message)).subscribe(afterWrite);
	return new PassThroughPromiseToListenableFutureAdapter<Void>(afterWrite);
}
 
Example 3
Source File: FreeIpaClientRequest.java    From cloudbreak with Apache License 2.0 4 votes vote down vote up
public FreeIpaClientRequest(Long stackId) {
    this.stackId = requireNonNull(stackId);
    result = Promises.prepare();
}
 
Example 4
Source File: CloudPlatformRequest.java    From cloudbreak with Apache License 2.0 4 votes vote down vote up
public CloudPlatformRequest(CloudContext cloudContext, CloudCredential cloudCredential) {
    this.cloudContext = cloudContext;
    this.cloudCredential = cloudCredential;
    result = Promises.prepare();
}
 
Example 5
Source File: ResourceNotification.java    From cloudbreak with Apache License 2.0 4 votes vote down vote up
public ResourceNotification(CloudResource cloudResource, CloudContext cloudContext, ResourceNotificationType type) {
    this.cloudResource = cloudResource;
    this.cloudContext = cloudContext;
    promise = Promises.prepare();
    this.type = type;
}