Class AbstractFullyQualifiedNameInstantiator
java.lang.Object
com.gruelbox.transactionoutbox.spi.AbstractFullyQualifiedNameInstantiator
- All Implemented Interfaces:
Instantiator
Abstract
Instantiator
implementation which simplifies the creation of implementations
which instantiate based on the clazz FQN.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
AbstractFullyQualifiedNameInstantiator.AbstractFullyQualifiedNameInstantiatorBuilder<C extends AbstractFullyQualifiedNameInstantiator,
B extends AbstractFullyQualifiedNameInstantiator.AbstractFullyQualifiedNameInstantiatorBuilder<C, B>> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
protected
AbstractFullyQualifiedNameInstantiator
(AbstractFullyQualifiedNameInstantiator.AbstractFullyQualifiedNameInstantiatorBuilder<?, ?> b) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Object
createInstance
(Class<?> clazz) final Object
getInstance
(String name) Requests an instance of the named class, where the "name" is whatever is returned byInstantiator.getName(Class)
.final String
Provides the name of the specified class.
-
Constructor Details
-
AbstractFullyQualifiedNameInstantiator
protected AbstractFullyQualifiedNameInstantiator(AbstractFullyQualifiedNameInstantiator.AbstractFullyQualifiedNameInstantiatorBuilder<?, ?> b) -
AbstractFullyQualifiedNameInstantiator
protected AbstractFullyQualifiedNameInstantiator()
-
-
Method Details
-
getName
Description copied from interface:Instantiator
Provides the name of the specified class. This may be the classes fully-qualified name, or may be an alias of some kind. This is up to the implementer.Not using the actual class name can be useful in avoiding a case where queued tasks end up referencing renamed classes following a refactor. It is also useful for DI frameworks such as Spring DI, which use named bindings by default.
- Specified by:
getName
in interfaceInstantiator
- Parameters:
clazz
- The class to get the name of.- Returns:
- The class name.
-
getInstance
Description copied from interface:Instantiator
Requests an instance of the named class, where the "name" is whatever is returned byInstantiator.getName(Class)
.A common use-case for this method is to return a class from a DI framework such as Guice (using an injected {code Injector}), but it is perfectly valid to simply instantiate the class by name and populate its dependencies directly.
- Specified by:
getInstance
in interfaceInstantiator
- Parameters:
name
- The class "name" as returned byInstantiator.getName(Class)
.- Returns:
- An instance of the class.
-
createInstance
-