AbstractConcurrentInitializer

public abstract class org.apache.commons.lang3.concurrent.AbstractConcurrentInitializer<T, E extends Exception> implements ConcurrentInitializer<T>[source]

Abstracts and defines operations for ConcurrentInitializer implementations.

Parameters:
  • <T> – The type of the object managed by this initializer class.

  • <E> – The exception type thrown by #initialize().

Since:

3.14.0

Constructors

AbstractConcurrentInitializer()

Constructs a new instance.

public AbstractConcurrentInitializer()[source]

Constructs a new instance.

Methods

close()

Calls the closer with the manager object.

getTypedException(Exception)

Gets an Exception with a type of E as defined by a concrete subclass of this class.

initialize()

Creates and initializes the object managed by this ConcurrentInitializer.

isInitialized()

Tests whether initialization has been completed.

public void close() throws ConcurrentException[source]

Calls the closer with the manager object.

Throws:

org.apache.commons.lang3.concurrent.ConcurrentException – Thrown by the closer.

Since:

3.14.0

protected abstract E getTypedException(Exception e)[source]

Gets an Exception with a type of E as defined by a concrete subclass of this class.

Parameters:

e – The actual exception that was thrown.

Returns:

A new exception with the actual type of E, that wraps e.

@SuppressWarnings({"unchecked"}) protected T initialize() throws E[source]

Creates and initializes the object managed by this ConcurrentInitializer. This method is called by #get() when the object is accessed for the first time. An implementation can focus on the creation of the object. No synchronization is needed, as this is already handled by get().

Subclasses and clients that do not provide an initializer are expected to implement this method.

Returns:

The managed data object.

Throws:

E – Thrown if an error occurs during object creation.

protected abstract boolean isInitialized()[source]

Tests whether initialization has been completed. If initialization threw an exception this will return false, but it will return true if a subsequent call to initialize completes successfully. If the implementation of ConcurrentInitializer can initialize multiple objects, this will only return true if all objects have been initialized.

Returns:

true if all initialization is complete, otherwise false.