org.glassfish.hk2.utilities
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.

Author:
jwells

Method Summary
 ActiveDescriptorBuilder andLoadWith(HK2Loader loader)
          Call this if this descriptor should be loaded with the given HK2Loader
 AbstractActiveDescriptor<?> build()
          Generates a descriptor that can be used in binding operations
 AbstractActiveDescriptor<?> buildFactory()
          Generates a descriptor that can be used in binding operations that describes a factory
 ActiveDescriptorBuilder has(String key, List<String> values)
          An instance of data to be associated with this descriptor
 ActiveDescriptorBuilder has(String key, String value)
          An instance of data to be associated with this descriptor
 ActiveDescriptorBuilder in(Class<? extends Annotation> scope)
          A scope to be associated with this descriptor object.
 ActiveDescriptorBuilder named(String name)
          The name for this descriptor object.
 ActiveDescriptorBuilder ofRank(int rank)
          The rank to be associated with this descriptor.
 ActiveDescriptorBuilder qualifiedBy(Annotation annotation)
          A qualifier to be associated with this descriptor object
 ActiveDescriptorBuilder to(Type contract)
          A contract to be associated with this descriptor object.
 

Method Detail

named

ActiveDescriptorBuilder named(String name)
                              throws 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:
IllegalArgumentException - if there is more than one name on the predicate

to

ActiveDescriptorBuilder to(Type contract)
                           throws 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:
IllegalArgumentException - on failures

in

ActiveDescriptorBuilder in(Class<? extends Annotation> scope)
                           throws 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:
IllegalArgumentException - If in is called more than once

qualifiedBy

ActiveDescriptorBuilder qualifiedBy(Annotation annotation)
                                    throws 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:
IllegalArgumentException - on failures

has

ActiveDescriptorBuilder has(String key,
                            String value)
                            throws 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:
IllegalArgumentException

has

ActiveDescriptorBuilder has(String key,
                            List<String> values)
                            throws 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:
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

andLoadWith

ActiveDescriptorBuilder andLoadWith(HK2Loader loader)
                                    throws 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:
IllegalArgumentException - if the HK2Loader is set non-null more than once

build

AbstractActiveDescriptor<?> build()
                                  throws IllegalArgumentException
Generates a descriptor that can be used in binding operations

Returns:
The descriptor that has been built up
Throws:
IllegalArgumentException - if the built descriptor is invalid

buildFactory

AbstractActiveDescriptor<?> buildFactory()
                                         throws IllegalArgumentException
Generates a descriptor that can be used in binding operations that describes a factory

Returns:
The descriptor that has been built up, of type FACTORY
Throws:
IllegalArgumentException - if the built descriptor is invalid


Copyright © 2013 Oracle Corporation. All Rights Reserved.