package org.gcube.common.clients.builders; import java.net.URI; import java.net.URL; import java.util.concurrent.TimeUnit; import org.gcube.common.clients.builders.StatelessBuilderAPI.Builder; import org.gcube.common.clients.builders.StatelessBuilderAPI.FinalClause; import org.gcube.common.clients.builders.StatelessBuilderAPI.SecondClause; import org.gcube.common.clients.cache.EndpointCache; import org.gcube.common.clients.config.Property; import org.gcube.common.clients.delegates.ProxyPlugin; import org.gcube.common.clients.queries.Query; /** * Partial implementation of proxy builders for stateless services. * * @author Fabio Simeoni * * @param the type of service addresses * @param the type of service stubs * @param

the type of service proxies */ public abstract class AbstractStatelessBuilder extends AbstractBuilder implements Builder

,SecondClause

,FinalClause

{ /** * Constructs an instance with a given {@link ProxyPlugin}, an {@link EndpointCache}, a {@link Query}, and zero or more default {@link Property}s. * @param plugin the plugin * @param the cache * @param query the query * @param properties the properties */ protected AbstractStatelessBuilder(ProxyPlugin plugin,EndpointCache cache,Query query,Property ... properties) { super(plugin,cache,properties); setQuery(query); } @Override public SecondClause

at(String host, int port) { setAddress(AddressingUtils.address(contextPath(),plugin().name(), host, port)); return this; } @Override public SecondClause

at(URL address) { setAddress(AddressingUtils.address(contextPath(),plugin().name(), address)); return this; } @Override public SecondClause

at(URI address) { setAddress(AddressingUtils.address(contextPath(),plugin().name(), address)); return this; } @Override public FinalClause

withTimeout(int duration, TimeUnit unit) { setTimeout((int) unit.toMillis(duration)); return this; } @Override public Builder

with(Property property) { addProperty(property); return this; } @Override public Builder

with(String name, T value) { addProperty(new Property(name, value)); return this; } }