|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectio.keen.client.java.KeenClient.Builder
public abstract static class KeenClient.Builder
Builder class for instantiating Keen clients. Subclasses should override this and implement the getDefault* methods to provide new default behavior.
This builder doesn't include any default implementation for handling JSON serialization and de-serialization. Subclasses must provide one. This builder defaults to using HttpURLConnection to handle HTTP requests. To cache events in between batch uploads, this builder defaults to a RAM-based event store. This builder defaults to a fixed thread pool (constructed withExecutors.newFixedThreadPool(int)) to run asynchronous requests.
| Constructor Summary | |
|---|---|
KeenClient.Builder()
|
|
| Method Summary | |
|---|---|
KeenClient |
build()
Builds a new Keen client using the interfaces which have been specified explicitly on this builder instance via the set* or with* methods, or the default interfaces if none have been specified. |
protected KeenClient |
buildInstance()
Builds an instance based on this builder. |
protected KeenEventStore |
getDefaultEventStore()
Gets the default KeenEventStore to use if none is explicitly set for this builder. |
protected HttpHandler |
getDefaultHttpHandler()
Gets the default HttpHandler to use if none is explicitly set for this builder. |
protected abstract KeenJsonHandler |
getDefaultJsonHandler()
Gets the default KeenJsonHandler to use if none is explicitly set for this builder. |
protected java.util.concurrent.Executor |
getDefaultPublishExecutor()
Gets the default Executor to use if none is explicitly set for this builder. |
KeenEventStore |
getEventStore()
Gets the KeenEventStore that this builder is currently configured to use for
storing events between batch publish operations. |
HttpHandler |
getHttpHandler()
Gets the HttpHandler that this builder is currently configured to use for making
HTTP requests. |
KeenJsonHandler |
getJsonHandler()
Gets the KeenJsonHandler that this builder is currently configured to use for
handling JSON operations. |
java.util.concurrent.Executor |
getPublishExecutor()
Gets the Executor that this builder is currently configured to use for
asynchronous publishing operations. |
void |
setEventStore(KeenEventStore eventStore)
Sets the KeenEventStore to use for storing events in between batch publish
operations. |
void |
setHttpHandler(HttpHandler httpHandler)
Sets the HttpHandler to use for making HTTP requests. |
void |
setJsonHandler(KeenJsonHandler jsonHandler)
Sets the KeenJsonHandler to use for handling JSON operations. |
void |
setPublishExecutor(java.util.concurrent.Executor publishExecutor)
Sets the Executor to use for asynchronous publishing operations. |
KeenClient.Builder |
withEventStore(KeenEventStore eventStore)
Sets the KeenEventStore to use for storing events in between batch publish
operations. |
KeenClient.Builder |
withHttpHandler(HttpHandler httpHandler)
Sets the HttpHandler to use for making HTTP requests. |
KeenClient.Builder |
withJsonHandler(KeenJsonHandler jsonHandler)
Sets the KeenJsonHandler to use for handling JSON operations. |
KeenClient.Builder |
withPublishExecutor(java.util.concurrent.Executor publishExecutor)
Sets the Executor to use for asynchronous publishing operations. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public KeenClient.Builder()
| Method Detail |
|---|
protected HttpHandler getDefaultHttpHandler()
throws java.lang.Exception
HttpHandler to use if none is explicitly set for this builder.
This implementation returns a handler that will use HttpURLConnection
to make HTTP requests.
Subclasses should override this to provide an alternative default HttpHandler.
HttpHandler.
java.lang.Exception - If there is an error creating the HttpHandler.public HttpHandler getHttpHandler()
HttpHandler that this builder is currently configured to use for making
HTTP requests. If null, a default will be used instead.
HttpHandler to use.public void setHttpHandler(HttpHandler httpHandler)
HttpHandler to use for making HTTP requests.
httpHandler - The HttpHandler to use.public KeenClient.Builder withHttpHandler(HttpHandler httpHandler)
HttpHandler to use for making HTTP requests.
httpHandler - The HttpHandler to use.
protected abstract KeenJsonHandler getDefaultJsonHandler()
throws java.lang.Exception
KeenJsonHandler to use if none is explicitly set for this builder.
Subclasses must override this to provide a default KeenJsonHandler.
KeenJsonHandler.
java.lang.Exception - If there is an error creating the KeenJsonHandler.public KeenJsonHandler getJsonHandler()
KeenJsonHandler that this builder is currently configured to use for
handling JSON operations. If null, a default will be used instead.
KeenJsonHandler to use.public void setJsonHandler(KeenJsonHandler jsonHandler)
KeenJsonHandler to use for handling JSON operations.
jsonHandler - The KeenJsonHandler to use.public KeenClient.Builder withJsonHandler(KeenJsonHandler jsonHandler)
KeenJsonHandler to use for handling JSON operations.
jsonHandler - The KeenJsonHandler to use.
protected KeenEventStore getDefaultEventStore()
throws java.lang.Exception
KeenEventStore to use if none is explicitly set for this builder.
This implementation returns a RAM-based store.
Subclasses should override this to provide an alternative default KeenEventStore.
KeenEventStore.
java.lang.Exception - If there is an error creating the KeenEventStore.public KeenEventStore getEventStore()
KeenEventStore that this builder is currently configured to use for
storing events between batch publish operations. If null, a default will be used instead.
KeenEventStore to use.public void setEventStore(KeenEventStore eventStore)
KeenEventStore to use for storing events in between batch publish
operations.
eventStore - The KeenEventStore to use.public KeenClient.Builder withEventStore(KeenEventStore eventStore)
KeenEventStore to use for storing events in between batch publish
operations.
eventStore - The KeenEventStore to use.
protected java.util.concurrent.Executor getDefaultPublishExecutor()
throws java.lang.Exception
Executor to use if none is explicitly set for this builder.
This implementation returns a simple fixed thread pool with the number of threads equal
to the number of available processors.
Subclasses should override this to provide an alternative default Executor.
Executor.
java.lang.Exception - If there is an error creating the Executor.public java.util.concurrent.Executor getPublishExecutor()
Executor that this builder is currently configured to use for
asynchronous publishing operations. If null, a default will be used instead.
Executor to use.public void setPublishExecutor(java.util.concurrent.Executor publishExecutor)
Executor to use for asynchronous publishing operations.
publishExecutor - The Executor to use.public KeenClient.Builder withPublishExecutor(java.util.concurrent.Executor publishExecutor)
Executor to use for asynchronous publishing operations.
publishExecutor - The Executor to use.
public KeenClient build()
protected KeenClient buildInstance()
KeenClient is constructed (i.e. by
providing a mock Environment.
KeenClient.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||