Interface ForeignDescriptor

All Known Implementing Classes:
ForeignDescriptorImpl

public interface ForeignDescriptor
The descriptor holder for an externally provided DI providers. Using this interface DI provider is able to provider his own descriptor which can be used and returned to the DI provider in further processing.

This is useful in the case of caching where an algorithm is able to store and subsequently provide for an injection the already resolved descriptor of the same value.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    dispose(Object instance)
    Disposes this instance.
    get()
    Returns an object that can be cast on the side of DI provider to his descriptor.
    wrap(Object descriptor)
    Wraps incoming descriptor instance and provides a default implementation of ForeignDescriptor.
    wrap(Object descriptor, Consumer<Object> disposeInstance)
    Wraps incoming descriptor instance and provides a default implementation of ForeignDescriptor along with a Consumer for a disposing an instance created using a given descriptor.
  • Method Details

    • get

      Object get()
      Returns an object that can be cast on the side of DI provider to his descriptor.
      Returns:
      DI provider's descriptor.
    • dispose

      void dispose(Object instance)
      Disposes this instance. All the PerLookup objects that were created for this instance will be destroyed after this object has been destroyed.
      Parameters:
      instance - The instance to destroy.
    • wrap

      static ForeignDescriptor wrap(Object descriptor)
      Wraps incoming descriptor instance and provides a default implementation of ForeignDescriptor.
      Parameters:
      descriptor - incoming foreign descriptor.
      Returns:
      wrapped foreign descriptor.
    • wrap

      static ForeignDescriptor wrap(Object descriptor, Consumer<Object> disposeInstance)
      Wraps incoming descriptor instance and provides a default implementation of ForeignDescriptor along with a Consumer for a disposing an instance created using a given descriptor.
      Parameters:
      descriptor - incoming foreign descriptor.
      disposeInstance - consumer which is able to dispose an instance created with the given descriptor.
      Returns:
      wrapped foreign descriptor.