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>
public class AsyncProxyDelegate<S> extends Object implements ProxyDelegate<S>
AProxyDelegatethat delivers the outcome ofCalls asynchronously, either through polling or notifications.The delegates use
ExecutorServices to make calls in separate threads. If required, clients may provide their ownExecutorServices at the point of call submission.- Author:
- Fabio Simeoni
-
-
Constructor Summary
Constructors Constructor Description AsyncProxyDelegate(ProxyDelegate<S> delegate)Creates an instance with a (synchronous)ProxyDelegate
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ProxyConfig<?,S>config()Returns the configuration of the proxy.<V> Vmake(Call<S,V> call)Makes aCallto a given service endpoint.<V> Future<V>makeAsync(Call<S,V> call)<V> Future<V>makeAsync(Call<S,V> call, ExecutorService service)<V> Future<?>makeAsync(Call<S,V> call, Callback<V> callback)<V> Future<?>makeAsync(Call<S,V> call, Callback<V> callback, ExecutorService service)
-
-
-
Constructor Detail
-
AsyncProxyDelegate
public AsyncProxyDelegate(ProxyDelegate<S> delegate)
Creates an instance with a (synchronous)ProxyDelegate- Parameters:
delegate- the delegate
-
-
Method Detail
-
make
public <V> V make(Call<S,V> call) throws Exception
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
public ProxyConfig<?,S> config()
Description copied from interface:ProxyDelegateReturns the configuration of the proxy.- Specified by:
configin interfaceProxyDelegate<S>- Returns:
- the configuration
-
makeAsync
public <V> Future<V> makeAsync(Call<S,V> call) throws RejectedExecutionException
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 RejectedExecutionException
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 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 RejectedExecutionException
Makes 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).- 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 RejectedExecutionException
Makes 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).- 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
-
-