Interface ActiveDescriptorBuilder

  • All Known Implementing Classes:
    ActiveDescriptorBuilderImpl

    public interface ActiveDescriptorBuilder
    The active descriptor build is for building up a non-reified ActiveDescriptor. Non-reified active descriptors are useful because upon bind the system will not do further analysis of the associated class file, assuming instead that all the information from the ActiveDescriptor is what the user intended. This can be used to supply qualifiers that are not marked with Qualifier or contracts that are not marked with Contract. An unreified ActiveDescriptor given to a bind method need not implement the create or destroy method, as they are automatically created and destroyed by the system.
    • Method Detail

      • named

        ActiveDescriptorBuilder named​(java.lang.String name)
                               throws java.lang.IllegalArgumentException
        The name for this descriptor object. Note that at the current time a descriptor can only have one name, hence this method will throw an IllegalArgumentException if named is called more than once.
        Parameters:
        name - The name to be associated with this Descriptor
        Returns:
        A DescriptorBuilder with the given name
        Throws:
        java.lang.IllegalArgumentException - if there is more than one name on the predicate
      • to

        ActiveDescriptorBuilder to​(java.lang.reflect.Type contract)
                            throws java.lang.IllegalArgumentException
        A contract to be associated with this descriptor object.
        Parameters:
        contract - A class that is annotated with Contract to be associated with this Descriptor
        Returns:
        A DescriptorBuilder with the given name
        Throws:
        java.lang.IllegalArgumentException - on failures
      • in

        ActiveDescriptorBuilder in​(java.lang.annotation.Annotation scope)
                            throws java.lang.IllegalArgumentException
        A scope to be associated with this descriptor object. Note that at the current time a descriptor can only have one scope, hence this method will throw an IllegalArgumentException if in is called more than once.
        Parameters:
        scope - The class of the scope this descriptor is to have.
        Returns:
        A DescriptorBuilder with the given scope
        Throws:
        java.lang.IllegalArgumentException - If in is called more than once
      • in

        ActiveDescriptorBuilder in​(java.lang.Class<? extends java.lang.annotation.Annotation> scope)
                            throws java.lang.IllegalArgumentException
        A scope to be associated with this descriptor object. Note that at the current time a descriptor can only have one scope, hence this method will throw an IllegalArgumentException if in is called more than once.
        Parameters:
        scope - The class of the scope this descriptor is to have.
        Returns:
        A DescriptorBuilder with the given scope
        Throws:
        java.lang.IllegalArgumentException - If in is called more than once
      • qualifiedBy

        ActiveDescriptorBuilder qualifiedBy​(java.lang.annotation.Annotation annotation)
                                     throws java.lang.IllegalArgumentException
        A qualifier to be associated with this descriptor object
        Parameters:
        annotation - The annotation to be associated with this descriptor
        Returns:
        A DescriptorBuilder with the given annotation
        Throws:
        java.lang.IllegalArgumentException - on failures
      • has

        ActiveDescriptorBuilder has​(java.lang.String key,
                                    java.lang.String value)
                             throws java.lang.IllegalArgumentException
        An instance of data to be associated with this descriptor
        Parameters:
        key - The key for the data to be associated with this descriptor
        value - The value this key should take (single value metadata)
        Returns:
        A DescriptorBuilder with the given metadata
        Throws:
        java.lang.IllegalArgumentException
      • has

        ActiveDescriptorBuilder has​(java.lang.String key,
                                    java.util.List<java.lang.String> values)
                             throws java.lang.IllegalArgumentException
        An instance of data to be associated with this descriptor
        Parameters:
        key - The key for the data to be associated with this descriptor
        values - The values this key should take (single value metadata)
        Returns:
        A DescriptorBuilder with the given metadata
        Throws:
        java.lang.IllegalArgumentException
      • ofRank

        ActiveDescriptorBuilder ofRank​(int rank)
        The rank to be associated with this descriptor. The last rank bound wins
        Parameters:
        rank - The rank to be associated with this descriptor.
        Returns:
        A DescriptorBuilder with the given rank
      • localOnly

        ActiveDescriptorBuilder localOnly()
        This will cause the descriptorVisibility field of the returned descriptor to return LOCAL
        Returns:
        A DescriptorBuilder with the descriptorVisibility field to be set to LOCAL
      • visibility

        ActiveDescriptorBuilder visibility​(DescriptorVisibility visibility)
        This will set the descriptorVisibility field of the returned descriptor
        Parameters:
        visibility - The non-null visibility that this descriptor should take
        Returns:
        A DescriptorBuilder with the descriptorVisibility field set to the input value
      • proxy

        ActiveDescriptorBuilder proxy()
        This will cause the isProxiable field of the returned descriptor to return true (it will force this descriptor to use proxies).
        Returns:
        A DescriptorBuilder with the proxiable field set to true
      • proxy

        ActiveDescriptorBuilder proxy​(boolean forceProxy)
        This will cause the isProxiable field of the returned descriptor to return the given value.
        Parameters:
        forceProxy - if true then this descriptor will be proxied, if false then this descriptor will NOT be proxied
        Returns:
        A DescriptorBuilder with the proxiable field set to the given value
      • proxyForSameScope

        ActiveDescriptorBuilder proxyForSameScope()
        This will cause the isProxyForSameScope field of the returned descriptor to return true (it will force this descriptor to use proxies even when injecting into the same scope).
        Returns:
        A DescriptorBuilder with the proxyForSameScope field set to true
      • proxyForSameScope

        ActiveDescriptorBuilder proxyForSameScope​(boolean forceProxyForSameScope)
        This will cause the isProxyForSameScope field of the returned descriptor to return the given value.
        Parameters:
        forceProxyForSameScope - if true then this descriptor will be proxied even if the scope of the injectee is the same, if false then this descriptor will NOT be proxied, even if the scope of the injectee is the same
        Returns:
        A DescriptorBuilder with the proxyForSameScope field set to the given value
      • andLoadWith

        ActiveDescriptorBuilder andLoadWith​(HK2Loader loader)
                                     throws java.lang.IllegalArgumentException
        Call this if this descriptor should be loaded with the given HK2Loader
        Parameters:
        loader - The loader to use with this descriptor
        Returns:
        A DescriptorBuilder with the given HK2Loader
        Throws:
        java.lang.IllegalArgumentException - if the HK2Loader is set non-null more than once
      • analyzeWith

        ActiveDescriptorBuilder analyzeWith​(java.lang.String serviceName)
        Call this if the descriptor should be analyzed with the ClassAnalyzer service of the given name
        Parameters:
        serviceName - the name of the ClassAnalyzer service that should be used to analyze this service
        Returns:
        A DescriptorBuilder with the given analysis service
      • asType

        ActiveDescriptorBuilder asType​(java.lang.reflect.Type t)
        Call this if the parameterized type of the implementation class is known. This may be called with any Type, but only a ParameterizedType based on the implementationClass will work
        Parameters:
        t - The non-null ParameterizedType describing the implementation
        Returns:
        A DescriptorBuilder with the given implementationType
      • build

        <T> AbstractActiveDescriptor<T> build()
                                       throws java.lang.IllegalArgumentException
        Generates a descriptor that can be used in binding operations
        Returns:
        The descriptor that has been built up
        Throws:
        java.lang.IllegalArgumentException - if the built descriptor is invalid
      • buildFactory

        @Deprecated
        <T> AbstractActiveDescriptor<T> buildFactory()
                                              throws java.lang.IllegalArgumentException
        Deprecated.
        Use buildProvideMethod instead
        Generates a descriptor that can be used in binding operations that describes a factorys provide method
        Returns:
        The descriptor that has been built up, of type PROVIDE_METHOD
        Throws:
        java.lang.IllegalArgumentException - if the built descriptor is invalid
      • buildProvideMethod

        <T> AbstractActiveDescriptor<T> buildProvideMethod()
                                                    throws java.lang.IllegalArgumentException
        Generates a descriptor that can be used in binding operations that describes a factorys provide method
        Returns:
        The descriptor that has been built up, of type PROVIDE_METHOD
        Throws:
        java.lang.IllegalArgumentException - if the built descriptor is invalid