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

      All Methods Static Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void dispose​(java.lang.Object instance)
      Disposes this instance.
      java.lang.Object get()
      Returns an object that can be cast on the side of DI provider to his descriptor.
      static ForeignDescriptor wrap​(java.lang.Object descriptor)
      Wraps incoming descriptor instance and provides a default implementation of ForeignDescriptor.
      static ForeignDescriptor wrap​(java.lang.Object descriptor, java.util.function.Consumer<java.lang.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 Detail

      • get

        java.lang.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​(java.lang.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​(java.lang.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​(java.lang.Object descriptor,
                                      java.util.function.Consumer<java.lang.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.