T
- type extending SlingClientpublic abstract static class SlingClient.InternalBuilder<T extends SlingClient> extends Object
Extensible InternalBuilder for SlingClient. Can be used by calling: SlingClient.builder().create(...).build()
.
Between create() and build(), any number of set methods can be called to customize the client.
It also exposes the underling httpClientBuilder through httpClientBuilder()
which can be used to customize the client
at http level.
The InternalBuilder is created to be easily extensible. A class, e.g. MyClient extends SlingClient
, can have its own InternalBuilder.
This is worth creating if MyClient has fields that need to be initialized. The Skeleton of such InternalBuilder (created inside MyClient) is:
public static abstract class InternalBuilder<T extends MyClient> extends SlingClient.InternalBuilder<T> { private String additionalField; public InternalBuilder(URI url, String user, String password) { super(url, user, password); } public InternalBuilder<T> setAdditionalField(String s) { additionalField = s; } }
Besides this, two more methods need to be implemented directly inside MyClient
:
Of course, the Clients and InternalBuilder are extensible on several levels, so MyClient.InternalBuilder can be further extended.public static InternalBuilder<?> builder(URI url, String user, String password) { return new InternalBuilder<MyClient>(url, user, password) { {@literal @}Override public MyClient build() throws ClientException { return new MyClient(this); } }; } protected MyClient(InternalBuilder<MyClient> builder) throws ClientException { super(builder); additionalField = builder.additionalField; }
Modifier | Constructor and Description |
---|---|
protected |
InternalBuilder(URI url,
String user,
String password) |
Modifier and Type | Method and Description |
---|---|
SlingClient.InternalBuilder<T> |
addInterceptorFirst(org.apache.http.HttpRequestInterceptor itcp)
Adds this protocol interceptor to the head of the protocol processing list.
|
SlingClient.InternalBuilder<T> |
addInterceptorFirst(org.apache.http.HttpResponseInterceptor itcp) |
SlingClient.InternalBuilder<T> |
addInterceptorLast(org.apache.http.HttpRequestInterceptor itcp)
Adds this protocol interceptor to the tail of the protocol processing list.
|
SlingClient.InternalBuilder<T> |
addInterceptorLast(org.apache.http.HttpResponseInterceptor itcp)
Adds this protocol interceptor to the tail of the protocol processing list.
|
abstract T |
build() |
protected org.apache.http.impl.client.CloseableHttpClient |
buildHttpClient() |
protected SlingClientConfig |
buildSlingClientConfig() |
SlingClient.InternalBuilder<T> |
disableRedirectHandling()
Disables automatic redirect handling.
|
org.apache.http.impl.client.HttpClientBuilder |
httpClientBuilder() |
SlingClient.InternalBuilder<T> |
setCookieStore(org.apache.http.client.CookieStore cs) |
SlingClient.InternalBuilder<T> |
setCredentialsProvider(org.apache.http.client.CredentialsProvider cp) |
SlingClient.InternalBuilder<T> |
setPassword(String password) |
SlingClient.InternalBuilder<T> |
setPreemptiveAuth(boolean isPreemptiveAuth) |
SlingClient.InternalBuilder<T> |
setRedirectStrategy(org.apache.http.client.RedirectStrategy redirectStrategy)
Assigns
RedirectStrategy instance. |
SlingClient.InternalBuilder<T> |
setUrl(URI url) |
SlingClient.InternalBuilder<T> |
setUser(String user) |
public SlingClient.InternalBuilder<T> setUrl(URI url)
public SlingClient.InternalBuilder<T> setUser(String user)
public SlingClient.InternalBuilder<T> setPassword(String password)
public SlingClient.InternalBuilder<T> setCredentialsProvider(org.apache.http.client.CredentialsProvider cp)
public SlingClient.InternalBuilder<T> setPreemptiveAuth(boolean isPreemptiveAuth)
public SlingClient.InternalBuilder<T> setCookieStore(org.apache.http.client.CookieStore cs)
public org.apache.http.impl.client.HttpClientBuilder httpClientBuilder()
public abstract T build() throws ClientException
ClientException
protected org.apache.http.impl.client.CloseableHttpClient buildHttpClient()
protected SlingClientConfig buildSlingClientConfig()
public final SlingClient.InternalBuilder<T> addInterceptorFirst(org.apache.http.HttpResponseInterceptor itcp)
public final SlingClient.InternalBuilder<T> addInterceptorLast(org.apache.http.HttpResponseInterceptor itcp)
Please note this value can be overridden by the HttpClientBuilder.setHttpProcessor(
org.apache.http.protocol.HttpProcessor)
method.
itcp
- the interceptorpublic final SlingClient.InternalBuilder<T> addInterceptorFirst(org.apache.http.HttpRequestInterceptor itcp)
Please note this value can be overridden by the HttpClientBuilder.setHttpProcessor(
org.apache.http.protocol.HttpProcessor)
method.
itcp
- the interceptorpublic final SlingClient.InternalBuilder<T> addInterceptorLast(org.apache.http.HttpRequestInterceptor itcp)
Please note this value can be overridden by the HttpClientBuilder.setHttpProcessor(
org.apache.http.protocol.HttpProcessor)
method.
itcp
- the interceptorpublic final SlingClient.InternalBuilder<T> setRedirectStrategy(org.apache.http.client.RedirectStrategy redirectStrategy)
RedirectStrategy
instance.
Please note this value can be overridden by the disableRedirectHandling()
method.
redirectStrategy
- custom redirect strategypublic final SlingClient.InternalBuilder<T> disableRedirectHandling()
Copyright © 2007–2018 The Apache Software Foundation. All rights reserved.