Class ConstantActiveDescriptor<T>

Type Parameters:
T - The type of the constant
All Implemented Interfaces:
Externalizable, Serializable, ActiveDescriptor<T>, Descriptor, SingleCache<T>

public class ConstantActiveDescriptor<T> extends AbstractActiveDescriptor<T>
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      For serialization
      See Also:
    • theOne

      private T theOne
    • locatorId

      private Long locatorId
  • Constructor Details

    • ConstantActiveDescriptor

      public ConstantActiveDescriptor()
      For serialization
    • ConstantActiveDescriptor

      public ConstantActiveDescriptor(T theOne, ServiceLocatorImpl locator)
      Creates a constant active descriptor with the given locator
      Parameters:
      theOne - the object to create it from
      locator - the locator this is being created for
    • ConstantActiveDescriptor

      public ConstantActiveDescriptor(T theOne, Set<Type> advertisedContracts, Class<? extends Annotation> scope, String name, Set<Annotation> qualifiers, DescriptorVisibility visibility, int ranking, Boolean proxy, Boolean proxyForSameScope, String analyzerName, long locatorId, Map<String,List<String>> metadata)
      Constructor with more control over the fields of the descriptor
      Parameters:
      theOne - The non-null constant
      advertisedContracts - its advertised contracts
      scope - its scope
      name - its possibly null name
      qualifiers - its set of qualifiers
      visibility - its visibility
      ranking - its starting rank
      proxy - can it be proxied (null for default)
      proxyForSameScope - will it be proxied for the same scope (null for default)
      analyzerName - The name of the analyzer (null for default)
      locatorId - its locator parent
      metadata - The metadata associated with it
  • Method Details

    • getImplementation

      public String getImplementation()
      Description copied from interface: Descriptor
      Returns the fully qualified class name of the implementation class. If this is a factory descriptor then this will return the fully qualified name of the class implementing the factory interface.
      Specified by:
      getImplementation in interface Descriptor
      Overrides:
      getImplementation in class DescriptorImpl
      Returns:
      Might return null in some cases, but will usually return the fully qualified class name of the implementation class or of the factory class for this descriptor
    • getLocatorId

      public Long getLocatorId()
      Description copied from interface: Descriptor
      This returns the id of the ServiceLocator which this descriptor is registered with. Returns null if this descriptor is not yet registered with a ServiceLocator
      Specified by:
      getLocatorId in interface Descriptor
      Overrides:
      getLocatorId in class DescriptorImpl
      Returns:
      The id of the ServiceLocator this Descriptor is registered with, or null if this Descriptor is not registered with a ServiceLocator
    • getCache

      public T getCache()
      Description copied from interface: SingleCache
      This can be used for scopes that will only every be created once. The returned value must have been set previously with setCache. If this is called when isCacheSet is false will result in a RuntimeException
      Specified by:
      getCache in interface SingleCache<T>
      Overrides:
      getCache in class AbstractActiveDescriptor<T>
      Returns:
      A value cached with this ActiveDescriptor
    • isCacheSet

      public boolean isCacheSet()
      Description copied from interface: SingleCache
      Returns true if this cache has been set
      Specified by:
      isCacheSet in interface SingleCache<T>
      Overrides:
      isCacheSet in class AbstractActiveDescriptor<T>
      Returns:
      true if there is a currently cached value, false otherwise
    • getImplementationClass

      public Class<?> getImplementationClass()
      Description copied from interface: ActiveDescriptor
      The implementation class that should be used to generate new instances of this descriptor.

      If the class returned is a Factory, then the factory is used to create instances. In this case the system will get an instance of the factory and use it to create the instances

      Returns:
      The class that directly implements the contract types, or the class that is the factory for an object that implements the contract types
    • getImplementationType

      public Type getImplementationType()
      Description copied from interface: ActiveDescriptor
      If known the Type of the implementation. If unknown will return the same as ActiveDescriptor.getImplementationClass()
      Returns:
      The type of the implementation or the implementation class
    • setImplementationType

      public void setImplementationType(Type t)
      Overrides:
      setImplementationType in class AbstractActiveDescriptor<T>
    • create

      public T create(ServiceHandle<?> root)
      Description copied from interface: ActiveDescriptor
      Creates an instance of the ActiveDescriptor. All of the Injectee's must be created prior to instantiation, and associated with the ExtendedProvider so that they can be destroyed properly
      Parameters:
      root - The root service handle, which can be used to associated all the PerLookup objects with this creation
      Returns:
      An instance of this ActiveDescriptor
    • dispose

      public void dispose(T instance)
      Description copied from interface: ActiveDescriptor
      Disposes this instance. All the PerLookup objects that were created for this instance will be destroyed after this object has been destroyed
      Specified by:
      dispose in interface ActiveDescriptor<T>
      Overrides:
      dispose in class AbstractActiveDescriptor<T>
      Parameters:
      instance - The instance to destroy