java.lang.Object
org.glassfish.hk2.internal.DescriptorBuilderImpl
- All Implemented Interfaces:
DescriptorBuilder
This is a simple implementation of the
DescriptorBuilder
- Author:
- jwells
-
Constructor Summary
ConstructorsConstructorDescriptionThe basid constructorDescriptorBuilderImpl
(String implementation, boolean addToContracts) A descriptor builder with the given implementation -
Method Summary
Modifier and TypeMethodDescriptionanalyzeWith
(String serviceName) Call this if the descriptor should be analyzed with theClassAnalyzer
service of the given nameandLoadWith
(HK2Loader loader) Call this if this descriptor should be loaded with the given HK2Loaderbuild()
Generates a descriptor that can be used in binding operationsGenerates a factory descriptor that can be used in binding operations.buildFactory
(Class<? extends Annotation> factoryScope) Generates a factory descriptor that can be used in binding operations.buildFactory
(String factoryScope) Generates a factory descriptor that can be used in binding operations.An instance of data to be associated with this descriptorAn instance of data to be associated with this descriptorin
(Class<? extends Annotation> scope) A scope to be associated with this descriptor object.A scope to be associated with this descriptor object.This will cause the descriptorVisibility field of the returned descriptor to return LOCALThe name for this descriptor object.ofRank
(int rank) The rank to be associated with this descriptor.proxy()
This will cause the isProxiable field of the returned descriptor to return true (it will force this descriptor to use proxies).proxy
(boolean forceProxy) This will cause the isProxiable field of the returned descriptor to return the given value.This will cause the isProxyForSameScope field of the returned descriptor to return true (it will force this descriptor to proxy even when injecting into the same scope).proxyForSameScope
(boolean proxyForSameScope) This will cause the isProxyForSameScope field of the returned descriptor to return the given value.qualifiedBy
(Annotation annotation) A qualifier to be associated with this descriptor object.qualifiedBy
(String annotation) A qualifier to be associated with this descriptor objectA contract to be associated with this descriptor object.A contract to be associated with this descriptor object.visibility
(DescriptorVisibility visibility) This will set the descriptorVisibility field of the returned descriptor
-
Constructor Details
-
DescriptorBuilderImpl
public DescriptorBuilderImpl()The basid constructor -
DescriptorBuilderImpl
A descriptor builder with the given implementation- Parameters:
implementation
- The implementation this should takeaddToContracts
- Whether or not to add the implementation to the set of contracts
-
-
Method Details
-
named
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 interfaceDescriptorBuilder
- 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
Description copied from interface:DescriptorBuilder
A contract to be associated with this descriptor object.- Specified by:
to
in interfaceDescriptorBuilder
- 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
Description copied from interface:DescriptorBuilder
A contract to be associated with this descriptor object.- Specified by:
to
in interfaceDescriptorBuilder
- 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
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 interfaceDescriptorBuilder
- 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
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 interfaceDescriptorBuilder
- 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
Description copied from interface:DescriptorBuilder
A qualifier to be associated with this descriptor object. It is dangerous to use this method with a ghost annotation (one that is not on the object) if that annotation has fields, as these fields will NOT survive being put into theDescriptor
. Use this method with care and ONLY with annotations that do not have fields. A safe version of this method for use with ghost annotations isActiveDescriptorBuilder.qualifiedBy(Annotation)
- Specified by:
qualifiedBy
in interfaceDescriptorBuilder
- Parameters:
annotation
- The annotation to be associated with this descriptor- Returns:
- A DescriptorBuilder with the given annotation
- Throws:
IllegalArgumentException
- on failures
-
qualifiedBy
Description copied from interface:DescriptorBuilder
A qualifier to be associated with this descriptor object- Specified by:
qualifiedBy
in interfaceDescriptorBuilder
- 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
Description copied from interface:DescriptorBuilder
An instance of data to be associated with this descriptor- Specified by:
has
in interfaceDescriptorBuilder
- Parameters:
key
- The key for the data to be associated with this descriptorvalue
- The value this key should take (single value metadata)- Returns:
- A DescriptorBuilder with the given metadata
- Throws:
IllegalArgumentException
-
has
Description copied from interface:DescriptorBuilder
An instance of data to be associated with this descriptor- Specified by:
has
in interfaceDescriptorBuilder
- Parameters:
key
- The key for the data to be associated with this descriptorvalues
- The values this key should take (single value metadata)- Returns:
- A DescriptorBuilder with the given metadata
- Throws:
IllegalArgumentException
-
ofRank
Description copied from interface:DescriptorBuilder
The rank to be associated with this descriptor. The last rank bound wins- Specified by:
ofRank
in interfaceDescriptorBuilder
- Parameters:
rank
- The rank to be associated with this descriptor.- Returns:
- A DescriptorBuilder with the given rank
-
proxy
Description copied from interface:DescriptorBuilder
This will cause the isProxiable field of the returned descriptor to return true (it will force this descriptor to use proxies).- Specified by:
proxy
in interfaceDescriptorBuilder
- Returns:
- A DescriptorBuilder with the proxiable field set to true
-
proxy
Description copied from interface:DescriptorBuilder
This will cause the isProxiable field of the returned descriptor to return the given value.- Specified by:
proxy
in interfaceDescriptorBuilder
- 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
Description copied from interface:DescriptorBuilder
This will cause the isProxyForSameScope field of the returned descriptor to return true (it will force this descriptor to proxy even when injecting into the same scope).- Specified by:
proxyForSameScope
in interfaceDescriptorBuilder
- Returns:
- A DescriptorBuilder with the proxyForSameScope field set to true
-
proxyForSameScope
Description copied from interface:DescriptorBuilder
This will cause the isProxyForSameScope field of the returned descriptor to return the given value.- Specified by:
proxyForSameScope
in interfaceDescriptorBuilder
- Parameters:
proxyForSameScope
- if true then this descriptor will be proxied even when being injected into the same scope, if false then this descriptor will NOT be proxied when injected into a service of the same scope- Returns:
- A DescriptorBuilder with the proxyForSameScope field set to the given value
-
localOnly
Description copied from interface:DescriptorBuilder
This will cause the descriptorVisibility field of the returned descriptor to return LOCAL- Specified by:
localOnly
in interfaceDescriptorBuilder
- Returns:
- A DescriptorBuilder with the descriptorVisibility field to be set to LOCAL
-
visibility
Description copied from interface:DescriptorBuilder
This will set the descriptorVisibility field of the returned descriptor- Specified by:
visibility
in interfaceDescriptorBuilder
- Parameters:
visibility
- The non-null visibility that this descriptor should take- Returns:
- A DescriptorBuilder with the descriptorVisibility field set to the input value
-
andLoadWith
Description copied from interface:DescriptorBuilder
Call this if this descriptor should be loaded with the given HK2Loader- Specified by:
andLoadWith
in interfaceDescriptorBuilder
- 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
-
analyzeWith
Description copied from interface:DescriptorBuilder
Call this if the descriptor should be analyzed with theClassAnalyzer
service of the given name- Specified by:
analyzeWith
in interfaceDescriptorBuilder
- Parameters:
serviceName
- the name of theClassAnalyzer
service that should be used to analyze this service- Returns:
- A DescriptorBuilder with the given analysis service
-
build
Description copied from interface:DescriptorBuilder
Generates a descriptor that can be used in binding operations- Specified by:
build
in interfaceDescriptorBuilder
- Returns:
- The descriptor that has been built up with this DescriptorBuilder
- Throws:
IllegalArgumentException
- if the built descriptor is invalid
-
buildFactory
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 interfaceDescriptorBuilder
- 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
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 interfaceDescriptorBuilder
- 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 interfaceDescriptorBuilder
- 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
-