This package contains the core APIs and interfaces for the Optimizely Feature Experimentation API in Java.
Full product documentation is in the Optimizely developers documentation.
compile 'com.optimizely.ab:core-api:{VERSION}'<dependency>
<groupId>com.optimizely.ab</groupId>
<artifactId>core-api</artifactId>
<version>{VERSION}</version>
</dependency>
Optimizely
provides top level API access to the Feature Experimentation project.
Optimizely optimizely = Optimizely.builder()
.withConfigManager(configManager)
.withEventProcessor(eventProcessor)
.build();
Variation variation = optimizely.activate("ad-test");
optimizely.track("conversion");The ErrorHandler
interface is available for handling errors from the SDK without interfering with the host application.
The NoOpErrorHandler
is the default ErrorHandler implementation that silently consumes all errors raised from the SDK.
The RaiseExceptionErrorHandler
is an implementation of ErrorHandler best suited for testing and development where all errors are raised, potentially crashing
the hosting application.
The EventProcessor
interface is used to provide an intermediary processing stage within event production.
It's assumed that the EventProcessor dispatches events via a provided EventHandler.
BatchEventProcessor
is an implementation of EventProcessor where events are batched. The class maintains a single consumer thread that pulls
events off of the BlockingQueue and buffers them for either a
configured batch size or a maximum duration before the resulting LogEvent is sent to the EventDispatcher and NotificationCenter.
The ForwardingEventProcessor
implements EventProcessor for backwards compatibility. Each event processed is converted into a LogEvent
message before it is sent synchronously to the supplied EventHandler.
The EventHandler
interface is used for dispatching events to the Optimizely event endpoint. Implementations of EventHandler#dispatchEvent(LogEvent) are expected
to make an HTTP request of type getRequestMethod() to the LogEvent#getEndpointUrl() location. The corresponding request parameters and body
are available via LogEvent#getRequestParams() and LogEvent#getBody() respectively.
The NoopEventHandler
implements EventHandler with no side-effects. NoopEventHandler is useful for testing or non-production environments.
The NotificationCenter
is the centralized component for subscribing to notifications from the SDK. Subscribers must implement the NotificationHandler<T> interface
and are registered via NotificationCenterxaddNotificationHandler. Note that notifications are called synchronously and have the potential to
block the main thread.
The ProjectConfig
represents the current state of the Optimizely project as configured through optimizely.com.
The interface is currently unstable and only used internally. All public access to this implementation is subject to change
with each subsequent version.
The DatafileProjectConfig
is an implementation of ProjectConfig backed by a file, typically sourced from the Optimizely CDN.
The ProjectConfigManager
is a factory class that provides ProjectConfig. Implementations of this class provide a consistent representation
of a ProjectConfig that can be references between service calls.
The AtomicProjectConfigManager
is a static provider that can be updated atomically to provide a consistent view of a ProjectConfig.
The PollingProjectConfigManager
is an abstract class that provides the framework for a dynamic factory that updates asynchronously within a background thread.
Implementations of this class can be used to poll from an externalized sourced without blocking the main application thread.