org.gcube.common.clients.builders
Class AbstractSingletonBuilder<A,S,P>

java.lang.Object
  extended by org.gcube.common.clients.builders.AbstractBuilder<A,S,P>
      extended by org.gcube.common.clients.builders.AbstractSingletonBuilder<A,S,P>
Type Parameters:
A - the type of service addresses
S - the type of service stubs
P - the type of service proxies
All Implemented Interfaces:
SingletonBuilderAPI.Builder<A,P>, SingletonBuilderAPI.FinalClause<P>, SingletonBuilderAPI.SecondClause<P>

public abstract class AbstractSingletonBuilder<A,S,P>
extends AbstractBuilder<A,S,P>
implements SingletonBuilderAPI.Builder<A,P>, SingletonBuilderAPI.SecondClause<P>, SingletonBuilderAPI.FinalClause<P>

Partial implementation of proxy builders for singleton services, i.e. stateful services with a known single instance.

Author:
Fabio Simeoni

Field Summary
 
Fields inherited from class org.gcube.common.clients.builders.AbstractBuilder
defaultTimeout
 
Constructor Summary
protected AbstractSingletonBuilder(ProxyPlugin<A,S,P> plugin, EndpointCache<A> cache, Property<?>... properties)
          Constructs an instance with a given ProxyPlugin, and EndpointCache, and zero or more default Propertys.
 
Method Summary
 SingletonBuilderAPI.SecondClause<P> at(String host, int port)
          Configures the address of a given service instance.
 SingletonBuilderAPI.SecondClause<P> at(URI address)
          Configures the address of a given service endpoint.
 SingletonBuilderAPI.SecondClause<P> at(URL address)
          Configures the address of a given service endpoint.
 SingletonBuilderAPI.SecondClause<P> matching(Query<A> query)
          Configures a query for service instances.
 SingletonBuilderAPI.SecondClause<P> with(Property<?> property)
          Set a configuration property for the proxy.
<T> SingletonBuilderAPI.SecondClause<P>
with(String name, T value)
          Set a configuration property for the proxy.
 SingletonBuilderAPI.FinalClause<P> withTimeout(int duration, TimeUnit unit)
          Configures the timeout for the proxy.
 
Methods inherited from class org.gcube.common.clients.builders.AbstractBuilder
addProperty, build, contextPath, convertAddress, plugin, setAddress, setQuery, setTimeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.gcube.common.clients.builders.SingletonBuilderAPI.SecondClause
build
 
Methods inherited from interface org.gcube.common.clients.builders.SingletonBuilderAPI.FinalClause
build
 

Constructor Detail

AbstractSingletonBuilder

protected AbstractSingletonBuilder(ProxyPlugin<A,S,P> plugin,
                                   EndpointCache<A> cache,
                                   Property<?>... properties)
Constructs an instance with a given ProxyPlugin, and EndpointCache, and zero or more default Propertys.

Parameters:
plugin - the plugin
plugin - the cache
properties - the properties
Method Detail

matching

public SingletonBuilderAPI.SecondClause<P> matching(Query<A> query)
Description copied from interface: SingletonBuilderAPI.Builder
Configures a query for service instances.

Specified by:
matching in interface SingletonBuilderAPI.Builder<A,P>
Parameters:
query - the query
Returns:
further configuration options

at

public SingletonBuilderAPI.SecondClause<P> at(String host,
                                              int port)
Description copied from interface: SingletonBuilderAPI.Builder
Configures the address of a given service instance.

Specified by:
at in interface SingletonBuilderAPI.Builder<A,P>
Returns:
further configuration options

at

public SingletonBuilderAPI.SecondClause<P> at(URL address)
Description copied from interface: SingletonBuilderAPI.Builder
Configures the address of a given service endpoint.

Specified by:
at in interface SingletonBuilderAPI.Builder<A,P>
Parameters:
address - the address of the endpoint
Returns:
further configuration options

at

public SingletonBuilderAPI.SecondClause<P> at(URI address)
Description copied from interface: SingletonBuilderAPI.Builder
Configures the address of a given service endpoint.

Specified by:
at in interface SingletonBuilderAPI.Builder<A,P>
Parameters:
address - the address of the endpoint
Returns:
further configuration options

withTimeout

public SingletonBuilderAPI.FinalClause<P> withTimeout(int duration,
                                                      TimeUnit unit)
Description copied from interface: SingletonBuilderAPI.SecondClause
Configures the timeout for the proxy.

Specified by:
withTimeout in interface SingletonBuilderAPI.SecondClause<P>
Parameters:
duration - the duration of the timeout
unit - the time unit of the timeout
Returns:
further configuration options

with

public SingletonBuilderAPI.SecondClause<P> with(Property<?> property)
Description copied from interface: SingletonBuilderAPI.SecondClause
Set a configuration property for the proxy.

Specified by:
with in interface SingletonBuilderAPI.SecondClause<P>
Returns:
further configuration options

with

public <T> SingletonBuilderAPI.SecondClause<P> with(String name,
                                                    T value)
Description copied from interface: SingletonBuilderAPI.SecondClause
Set a configuration property for the proxy.

Specified by:
with in interface SingletonBuilderAPI.SecondClause<P>
Type Parameters:
T - the type of the property value
Parameters:
name - the name of the property
value - the value of the property
Returns:
further configuration options


Copyright © 2013. All Rights Reserved.