Interface ParameterizedBuilderRegistry
-
- All Superinterfaces:
AutoCloseable
,Disposable
,Iterable<ParameterizedBuilderRegistry.Registration>
- All Known Implementing Classes:
SimpleParameterizedBuilderRegistry
public interface ParameterizedBuilderRegistry extends Disposable, Iterable<ParameterizedBuilderRegistry.Registration>
A registry of strongly typed and possibly namedParameterizedBuilder
s.When a
ParameterizedBuilder
is registered with aParameterizedBuilderRegistry
, theParameterizedBuilderRegistry
assumes ownership of the said builder, up until at which point theParameterizedBuilderRegistry
isdisposed
.Important: Although a
ParameterizedBuilderRegistry
manages builders in a thread-safe manner, it is possible for a thread callinggetBuilder(Class, String)
to receive anull
return value while another thread is registering a builder.- Since:
- Coherence 12.1.3
- Author:
- bo 2014.10.27
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
ParameterizedBuilderRegistry.Registration<T>
Defines a singleParameterizedBuilder
registration with aParameterizedBuilderRegistry
.
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_NAME
The name to use for the registration of a singleton and thus default resource.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> ParameterizedBuilder<T>
getBuilder(Class<T> clzInstance)
Attempts to retrieve the builder that was registered with the specified class.<T> ParameterizedBuilder<T>
getBuilder(Class<T> clzInstance, String sBuilderName)
Attempts to retrieve the builder that was registered with the specified class and name.<T> String
registerBuilder(Class<T> clzInstance, ParameterizedBuilder<? extends T> builder)
Registers aParameterizedBuilder
for later retrieval withgetBuilder(Class)
.<T> String
registerBuilder(Class<T> clzInstance, String sBuilderName, ParameterizedBuilder<? extends T> builder)
Registers aParameterizedBuilder
with the specified name for later retrieval withgetBuilder(Class, String)
.-
Methods inherited from interface com.oracle.coherence.common.base.Disposable
close, dispose
-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
-
-
-
Field Detail
-
DEFAULT_NAME
static final String DEFAULT_NAME
The name to use for the registration of a singleton and thus default resource.- See Also:
- Constant Field Values
-
-
Method Detail
-
getBuilder
<T> ParameterizedBuilder<T> getBuilder(Class<T> clzInstance)
Attempts to retrieve the builder that was registered with the specified class.- Type Parameters:
T
- the type of the instance that will be produced by the builder- Parameters:
clzInstance
- the class of the instance- Returns:
- the registered builder or
null
if the builder is unknown to theParameterizedBuilderRegistry
-
getBuilder
<T> ParameterizedBuilder<T> getBuilder(Class<T> clzInstance, String sBuilderName)
Attempts to retrieve the builder that was registered with the specified class and name.- Type Parameters:
T
- the type of the instance that will be produced by the builder- Parameters:
clzInstance
- the class of the instancesBuilderName
- the name of the builder- Returns:
- the registered builder or
null
if the builder is unknown to theParameterizedBuilderRegistry
-
registerBuilder
<T> String registerBuilder(Class<T> clzInstance, ParameterizedBuilder<? extends T> builder) throws IllegalArgumentException
Registers aParameterizedBuilder
for later retrieval withgetBuilder(Class)
.Notes:
- Multiple builders for the same class can be registered if each
builder is registered with a unique name via
registerBuilder(Class, String, ParameterizedBuilder)
- Registration of builders will occur in a thread-safe manner.
- Builders that are
Disposable
will be disposed when theParameterizedBuilderRegistry
is disposed.
- Parameters:
clzInstance
- the class of instances produced by the builderbuilder
- the builder- Returns:
- the actual name used to register the builder
- Throws:
IllegalArgumentException
- if a builder of the same specified type is already registered
- Multiple builders for the same class can be registered if each
builder is registered with a unique name via
-
registerBuilder
<T> String registerBuilder(Class<T> clzInstance, String sBuilderName, ParameterizedBuilder<? extends T> builder) throws IllegalArgumentException
Registers aParameterizedBuilder
with the specified name for later retrieval withgetBuilder(Class, String)
.Notes:
- Registration of builders will occur in a thread-safe manner.
- Builders that are
Disposable
will be disposed when theParameterizedBuilderRegistry
is disposed.
- Parameters:
clzInstance
- the class of instances produced by the builderbuilder
- the buildersBuilderName
- the proposed name of the builder- Returns:
- the actual name used to register the builder
- Throws:
IllegalArgumentException
- if a builder of the same specified type and name is already registered
-
-