org.glassfish.hk2.internal
Class DescriptorBuilderImpl

java.lang.Object
  extended by org.glassfish.hk2.internal.DescriptorBuilderImpl
All Implemented Interfaces:
DescriptorBuilder

public class DescriptorBuilderImpl
extends Object
implements DescriptorBuilder

This is a simple implementation of the DescriptorBuilder

Author:
jwells

Constructor Summary
DescriptorBuilderImpl()
          The basid constructor
DescriptorBuilderImpl(String implementation, boolean addToContracts)
          A descriptor builder with the given implementation
 
Method Summary
 DescriptorBuilder andLoadWith(HK2Loader loader)
          Call this if this descriptor should be loaded with the given HK2Loader
 DescriptorImpl build()
          Generates a descriptor that can be used in binding operations
 FactoryDescriptors buildFactory()
          Generates a factory descriptor that can be used in binding operations.
 FactoryDescriptors buildFactory(Class<? extends Annotation> factoryScope)
          Generates a factory descriptor that can be used in binding operations.
 FactoryDescriptors buildFactory(String factoryScope)
          Generates a factory descriptor that can be used in binding operations.
 DescriptorBuilder has(String key, List<String> values)
          An instance of data to be associated with this descriptor
 DescriptorBuilder has(String key, String value)
          An instance of data to be associated with this descriptor
 DescriptorBuilder in(Class<? extends Annotation> scope)
          A scope to be associated with this descriptor object.
 DescriptorBuilder in(String scope)
          A scope to be associated with this descriptor object.
 DescriptorBuilder named(String name)
          The name for this descriptor object.
 DescriptorBuilder ofRank(int rank)
          The rank to be associated with this descriptor.
 DescriptorBuilder qualifiedBy(Annotation annotation)
          A qualifier to be associated with this descriptor object
 DescriptorBuilder qualifiedBy(String annotation)
          A qualifier to be associated with this descriptor object
 DescriptorBuilder to(Class<?> contract)
          A contract to be associated with this descriptor object.
 DescriptorBuilder to(String contract)
          A contract to be associated with this descriptor object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DescriptorBuilderImpl

public DescriptorBuilderImpl()
The basid constructor


DescriptorBuilderImpl

public DescriptorBuilderImpl(String implementation,
                             boolean addToContracts)
A descriptor builder with the given implementation

Parameters:
implementation - The implementation this should take
addToContracts - Whether or not to add the implementation to the set of contracts
Method Detail

named

public DescriptorBuilder named(String name)
                        throws IllegalArgumentException
Description copied from interface: DescriptorBuilder
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.

Specified by:
named in interface DescriptorBuilder
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

public DescriptorBuilder to(Class<?> contract)
                     throws IllegalArgumentException
Description copied from interface: DescriptorBuilder
A contract to be associated with this descriptor object.

Specified by:
to in interface DescriptorBuilder
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

to

public DescriptorBuilder to(String contract)
                     throws IllegalArgumentException
Description copied from interface: DescriptorBuilder
A contract to be associated with this descriptor object.

Specified by:
to in interface DescriptorBuilder
Parameters:
contract - The fully qualified name of a class that is annotated with Contract.
Returns:
A DescriptorBuilder with the given name
Throws:
IllegalArgumentException - on failures

in

public DescriptorBuilder in(Class<? extends Annotation> scope)
                     throws IllegalArgumentException
Description copied from interface: DescriptorBuilder
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.

Specified by:
in in interface DescriptorBuilder
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

in

public DescriptorBuilder in(String scope)
                     throws IllegalArgumentException
Description copied from interface: DescriptorBuilder
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.

Specified by:
in in interface DescriptorBuilder
Parameters:
scope - The fully qualified class name of the scope this predicate is to have.
Returns:
A DescriptorBuilder with the given scope
Throws:
IllegalArgumentException - If in is called more than once

qualifiedBy

public DescriptorBuilder qualifiedBy(Annotation annotation)
                              throws IllegalArgumentException
Description copied from interface: DescriptorBuilder
A qualifier to be associated with this descriptor object

Specified by:
qualifiedBy in interface DescriptorBuilder
Parameters:
annotation - The annotation to be associated with this descriptor
Returns:
A DescriptorBuilder with the given annotation
Throws:
IllegalArgumentException - on failures

qualifiedBy

public DescriptorBuilder qualifiedBy(String annotation)
                              throws IllegalArgumentException
Description copied from interface: DescriptorBuilder
A qualifier to be associated with this descriptor object

Specified by:
qualifiedBy in interface DescriptorBuilder
Parameters:
annotation - The fully qualified class name of an annotation to be associated with this descriptor
Returns:
A DescriptorBuilder with the given annotation
Throws:
IllegalArgumentException - on failures

has

public DescriptorBuilder has(String key,
                             String value)
                      throws IllegalArgumentException
Description copied from interface: DescriptorBuilder
An instance of data to be associated with this descriptor

Specified by:
has in interface DescriptorBuilder
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

public DescriptorBuilder has(String key,
                             List<String> values)
                      throws IllegalArgumentException
Description copied from interface: DescriptorBuilder
An instance of data to be associated with this descriptor

Specified by:
has in interface DescriptorBuilder
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

public DescriptorBuilder ofRank(int rank)
Description copied from interface: DescriptorBuilder
The rank to be associated with this descriptor. The last rank bound wins

Specified by:
ofRank in interface DescriptorBuilder
Parameters:
rank - The rank to be associated with this descriptor.
Returns:
A DescriptorBuilder with the given rank

andLoadWith

public DescriptorBuilder andLoadWith(HK2Loader loader)
                              throws IllegalArgumentException
Description copied from interface: DescriptorBuilder
Call this if this descriptor should be loaded with the given HK2Loader

Specified by:
andLoadWith in interface DescriptorBuilder
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

public DescriptorImpl build()
                     throws IllegalArgumentException
Description copied from interface: DescriptorBuilder
Generates a descriptor that can be used in binding operations

Specified by:
build in interface DescriptorBuilder
Returns:
The descriptor that has been built up with this DescriptorBuilder
Throws:
IllegalArgumentException - if the built descriptor is invalid

buildFactory

public FactoryDescriptors buildFactory(String factoryScope)
                                throws IllegalArgumentException
Description copied from interface: DescriptorBuilder
Generates a factory descriptor that can be used in binding operations. The generated factory service will have no name, no qualifiers and the same metadata as given to this builder. The generated service will have had the implementation class removed from its set of advertised contracts

Specified by:
buildFactory in interface DescriptorBuilder
Parameters:
factoryScope - The scope the factory service itself is in.
Returns:
The descriptor that has been built up with this DescriptorBuilder
Throws:
IllegalArgumentException - if the built descriptor is invalid

buildFactory

public FactoryDescriptors buildFactory()
                                throws IllegalArgumentException
Description copied from interface: DescriptorBuilder
Generates a factory descriptor that can be used in binding operations. The generated factory service will have no name, no qualifiers and the same metadata as given to this builder. The factory will be put into PerLookup scope

Specified by:
buildFactory in interface DescriptorBuilder
Returns:
The descriptor that has been built up with this DescriptorBuilder
Throws:
IllegalArgumentException - if the built descriptor is invalid

buildFactory

public FactoryDescriptors buildFactory(Class<? extends Annotation> factoryScope)
                                throws IllegalArgumentException
Description copied from interface: DescriptorBuilder
Generates a factory descriptor that can be used in binding operations. The generated factory service will have no name, no qualifiers and the same metadata as given to this builder. The generated service will have had the implementation class removed from its set of advertised contracts

Specified by:
buildFactory in interface DescriptorBuilder
Parameters:
factoryScope - The scope the factory service itself is in. If this is null the PerLookup scope will be used
Returns:
The descriptor that has been built up with this DescriptorBuilder
Throws:
IllegalArgumentException - if the built descriptor is invalid


Copyright © 2013 Oracle Corporation. All Rights Reserved.