Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Java SDK Core API

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.

Installation

Gradle

compile 'com.optimizely.ab:core-api:{VERSION}'

Maven

<dependency>
    <groupId>com.optimizely.ab</groupId>
    <artifactId>core-api</artifactId>
    <version>{VERSION}</version>
</dependency>

Optimizely

Optimizely provides top level API access to the Feature Experimentation project.

Usage

Optimizely optimizely = Optimizely.builder()
    .withConfigManager(configManager)
    .withEventProcessor(eventProcessor)
    .build();

Variation variation = optimizely.activate("ad-test");
optimizely.track("conversion");

ErrorHandler

The ErrorHandler interface is available for handling errors from the SDK without interfering with the host application.

NoOpErrorHandler

The NoOpErrorHandler is the default ErrorHandler implementation that silently consumes all errors raised from the SDK.

RaiseExceptionErrorHandler

The RaiseExceptionErrorHandler is an implementation of ErrorHandler best suited for testing and development where all errors are raised, potentially crashing the hosting application.

EventProcessor

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

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.

ForwardingEventProcessor

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.

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.

NoopEventHandler

The NoopEventHandler implements EventHandler with no side-effects. NoopEventHandler is useful for testing or non-production environments.

NotificationCenter

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.

ProjectConfig

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.

DatafileProjectConfig

The DatafileProjectConfig is an implementation of ProjectConfig backed by a file, typically sourced from the Optimizely CDN.

ProjectConfigManager

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.

AtomicProjectConfigManager

The AtomicProjectConfigManager is a static provider that can be updated atomically to provide a consistent view of a ProjectConfig.

PollingProjectConfigManager

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.