Class AsyncProxyDelegate<S>
java.lang.Object
org.gcube.common.clients.delegates.AsyncProxyDelegate<S>
- Type Parameters:
S- the type of service stubs
- All Implemented Interfaces:
ProxyDelegate<S>
A
ProxyDelegate that delivers the outcome of Calls asynchronously, either through polling or
notifications.
The delegates use ExecutorServices to make calls in separate threads. If required, clients may provide their own
ExecutorServices at the point of call submission.
- Author:
- Fabio Simeoni
-
Constructor Summary
ConstructorsConstructorDescriptionAsyncProxyDelegate(ProxyDelegate<S> delegate) Creates an instance with a (synchronous)ProxyDelegate -
Method Summary
Modifier and TypeMethodDescriptionProxyConfig<?,S> config()Returns the configuration of the proxy.<V> VMakes aCallto a given service endpoint.<V> Future<V><V> Future<V>makeAsync(Call<S, V> call, ExecutorService service) <V> Future<?><V> Future<?>makeAsync(Call<S, V> call, Callback<V> callback, ExecutorService service)
-
Constructor Details
-
AsyncProxyDelegate
Creates an instance with a (synchronous)ProxyDelegate- Parameters:
delegate- the delegate
-
-
Method Details
-
make
Description copied from interface:ProxyDelegateMakes aCallto a given service endpoint.- Specified by:
makein interfaceProxyDelegate<S>- Type Parameters:
V- the type of the value returned from the call- Parameters:
call- the call- Returns:
- the value returned from the call
- Throws:
Exception- if the call fails
-
config
Description copied from interface:ProxyDelegateReturns the configuration of the proxy.- Specified by:
configin interfaceProxyDelegate<S>- Returns:
- the configuration
-
makeAsync
Makes aCallto a service endpoint asynchronously, returning aFuturethat clients can use to poll for and obtain the call outcome, or to cancel the call (assuming that the call is designed for cancellation or has not been made yet).- Type Parameters:
V- the type of the value returned from theCall- Parameters:
call- theCallto be made asynchronously- Returns:
- the
Futureof theCalloutcome - Throws:
RejectedExecutionException- if the call cannot not be submitted for asynchronous execution
-
makeAsync
public <V> Future<V> makeAsync(Call<S, V> call, ExecutorService service) throws RejectedExecutionExceptionMakes aCallto a service endpoint asynchronously, returning aFuturethat clients can use to poll for and obtain the call outcome, or to cancel the call (assuming that the call is designed for cancellation or has not been made yet).- Type Parameters:
V- the type of the value returned from theCall- Parameters:
call- theCallto be executed asynchronouslyservice- aExecutorServiceto which theCallshould be submitted for execution- Returns:
- the
Futureof theCalloutcome - Throws:
RejectedExecutionException- if the call cannot not be submitted for asynchronous execution
-
makeAsync
public <V> Future<?> makeAsync(Call<S, V> call, Callback<V> callback) throws RejectedExecutionExceptionMakes aCallto a service endpoint asynchronously, notifying aCallbackof its outcome. Returns aFuturethat clients can use to cancel the execution of the call (assuming that the call is designed for cancellation or has not been made yet).- Type Parameters:
V- the type of the value returned from theCall- Parameters:
call- theCallcallback- theCallback- Returns:
- the
Futureof call submission - Throws:
RejectedExecutionException- if the call cannot not be submitted for asynchronous execution
-
makeAsync
public <V> Future<?> makeAsync(Call<S, V> call, Callback<V> callback, ExecutorService service) throws RejectedExecutionExceptionMakes aCallto a service endpoint asynchronously, notifying aCallbackof its outcome. Returns aFuturethat clients can use to cancel the execution of the call (assuming that the call is designed for cancellation or has not been made yet).- Type Parameters:
V- the type of the value returned from theCall- Parameters:
call- theCallcallback- theCallbackservice- theExecutorServicethat executes the call- Returns:
- the
Futureof call submission - Throws:
RejectedExecutionException- if the call cannot not be submitted for asynchronous execution
-