Class AbstractFullyQualifiedNameInstantiator

java.lang.Object
com.gruelbox.transactionoutbox.spi.AbstractFullyQualifiedNameInstantiator
All Implemented Interfaces:
Instantiator

public abstract class AbstractFullyQualifiedNameInstantiator extends Object implements Instantiator
Abstract Instantiator implementation which simplifies the creation of implementations which instantiate based on the clazz FQN.
  • Constructor Details

  • Method Details

    • getName

      public final String getName(Class<?> clazz)
      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 interface Instantiator
      Parameters:
      clazz - The class to get the name of.
      Returns:
      The class name.
    • getInstance

      public final Object getInstance(String name)
      Description copied from interface: Instantiator
      Requests an instance of the named class, where the "name" is whatever is returned by Instantiator.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 interface Instantiator
      Parameters:
      name - The class "name" as returned by Instantiator.getName(Class).
      Returns:
      An instance of the class.
    • createInstance

      protected abstract Object createInstance(Class<?> clazz)