Top Description Methods
org.glassfish.hk2.utilities

public Interface DescriptorBuilder

Known Direct Implementers
org.glassfish.hk2.internal.DescriptorBuilderImpl
Imports
java.lang.annotation.Annotation, java.util.List, org.glassfish.hk2.api.DescriptorVisibility, .FactoryDescriptors, .HK2Loader

This is an object that uses the Builder pattern in order to generate a Descriptor (for binding) or a Filter (for searching). It is intended to facilitate query strings of method calls that is simple to understand and read.

Method Summary

Modifier and TypeMethod and Description
public DescriptorBuilder

Returns:

A DescriptorBuilder with the given analysis service
analyzeWith
(String
the name of the org.glassfish.hk2.api.ClassAnalyzer service that should be used to analyze this service
serviceName
)

Call this if the descriptor should be analyzed with the org.glassfish.hk2.api.ClassAnalyzer service of the given name

public DescriptorBuilder

Returns:

A DescriptorBuilder with the given HK2Loader
andLoadWith
(HK2Loader
The loader to use with this descriptor
loader
)

Call this if this descriptor should be loaded with the given HK2Loader

public DescriptorImpl

Returns:

The descriptor that has been built up with this DescriptorBuilder
build
()

Generates a descriptor that can be used in binding operations

public FactoryDescriptors

Returns:

The descriptor that has been built up with this DescriptorBuilder
buildFactory
()

Generates a factory descriptor that can be used in binding operations.

public FactoryDescriptors

Returns:

The descriptor that has been built up with this DescriptorBuilder
buildFactory
(String
The scope the factory service itself is in.
factoryScope
)

Generates a factory descriptor that can be used in binding operations.

public FactoryDescriptors

Returns:

The descriptor that has been built up with this DescriptorBuilder
buildFactory
(Class<? extends Annotation>
The scope the factory service itself is in. If this is null the PerLookup scope will be used
factoryScope
)

Generates a factory descriptor that can be used in binding operations.

public DescriptorBuilder

Returns:

A DescriptorBuilder with the given metadata
has
(String
The key for the data to be associated with this descriptor
key
,
String
The value this key should take (single value metadata)
value
)

An instance of data to be associated with this descriptor

public DescriptorBuilder

Returns:

A DescriptorBuilder with the given metadata
has
(String
The key for the data to be associated with this descriptor
key
,
List<String>
The values this key should take (single value metadata)
values
)

An instance of data to be associated with this descriptor

public DescriptorBuilder

Returns:

A DescriptorBuilder with the given scope
in
(Class<? extends Annotation>
The class of the scope this descriptor is to have.
scope
)

A scope to be associated with this descriptor object.

public DescriptorBuilder

Returns:

A DescriptorBuilder with the given scope
in
(String
The fully qualified class name of the scope this predicate is to have.
scope
)

A scope to be associated with this descriptor object.

public DescriptorBuilder

Returns:

A DescriptorBuilder with the descriptorVisibility field to be set to LOCAL
localOnly
()

This will cause the descriptorVisibility field of the returned descriptor to return LOCAL

public DescriptorBuilder

Returns:

A DescriptorBuilder with the given name
named
(String
The name to be associated with this Descriptor
name
)

The name for this descriptor object.

public DescriptorBuilder

Returns:

A DescriptorBuilder with the given rank
ofRank
(int
The rank to be associated with this descriptor.
rank
)

The rank to be associated with this descriptor.

public DescriptorBuilder

Returns:

A DescriptorBuilder with the proxiable field set to true
proxy
()

This will cause the isProxiable field of the returned descriptor to return true (it will force this descriptor to use proxies).

public DescriptorBuilder

Returns:

A DescriptorBuilder with the proxiable field set to the given value
proxy
(boolean
if true then this descriptor will be proxied, if false then this descriptor will NOT be proxied
forceProxy
)

This will cause the isProxiable field of the returned descriptor to return the given value.

public DescriptorBuilder

Returns:

A DescriptorBuilder with the proxyForSameScope field set to true
proxyForSameScope
()

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).

public DescriptorBuilder

Returns:

A DescriptorBuilder with the proxyForSameScope field set to the given value
proxyForSameScope
(boolean
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
proxyForSameScope
)

This will cause the isProxyForSameScope field of the returned descriptor to return the given value.

public DescriptorBuilder

Returns:

A DescriptorBuilder with the given annotation
qualifiedBy
(Annotation
The annotation to be associated with this descriptor
annotation
)

A qualifier to be associated with this descriptor object.

public DescriptorBuilder

Returns:

A DescriptorBuilder with the given annotation
qualifiedBy
(String
The fully qualified class name of an annotation to be associated with this descriptor
annotation
)

A qualifier to be associated with this descriptor object

public DescriptorBuilder

Returns:

A DescriptorBuilder with the given name
to
(Class<?>
A class that is annotated with Contract to be associated with this Descriptor
contract
)

A contract to be associated with this descriptor object.

public DescriptorBuilder

Returns:

A DescriptorBuilder with the given name
to
(String
The fully qualified name of a class that is annotated with Contract.
contract
)

A contract to be associated with this descriptor object.

public DescriptorBuilder

Returns:

A DescriptorBuilder with the descriptorVisibility field set to the input value
visibility
(DescriptorVisibility
The non-null visibility that this descriptor should take
visibility
)

This will set the descriptorVisibility field of the returned descriptor

Method Detail

analyzeWithback to summary
public DescriptorBuilder analyzeWith(String serviceName)

Call this if the descriptor should be analyzed with the org.glassfish.hk2.api.ClassAnalyzer service of the given name

Parameters
serviceName:String

the name of the org.glassfish.hk2.api.ClassAnalyzer service that should be used to analyze this service

Returns:DescriptorBuilder

A DescriptorBuilder with the given analysis service

andLoadWithback to summary
public DescriptorBuilder andLoadWith(HK2Loader loader) throws IllegalArgumentException

Call this if this descriptor should be loaded with the given HK2Loader

Parameters
loader:HK2Loader

The loader to use with this descriptor

Returns:DescriptorBuilder

A DescriptorBuilder with the given HK2Loader

Exceptions
IllegalArgumentException:
if the HK2Loader is set non-null more than once
buildback to summary
public DescriptorImpl build() throws IllegalArgumentException

Generates a descriptor that can be used in binding operations

Returns:DescriptorImpl

The descriptor that has been built up with this DescriptorBuilder

Exceptions
IllegalArgumentException:
if the built descriptor is invalid
buildFactoryback to summary
public FactoryDescriptors buildFactory() throws IllegalArgumentException

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

Returns:FactoryDescriptors

The descriptor that has been built up with this DescriptorBuilder

Exceptions
IllegalArgumentException:
if the built descriptor is invalid
buildFactoryback to summary
public FactoryDescriptors buildFactory(String factoryScope) throws IllegalArgumentException

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

Parameters
factoryScope:String

The scope the factory service itself is in.

Returns:FactoryDescriptors

The descriptor that has been built up with this DescriptorBuilder

Exceptions
IllegalArgumentException:
if the built descriptor is invalid
buildFactoryback to summary
public FactoryDescriptors buildFactory(Class<? extends Annotation> factoryScope) throws IllegalArgumentException

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

Parameters
factoryScope:Class<? extends Annotation>

The scope the factory service itself is in. If this is null the PerLookup scope will be used

Returns:FactoryDescriptors

The descriptor that has been built up with this DescriptorBuilder

Exceptions
IllegalArgumentException:
if the built descriptor is invalid
hasback to summary
public DescriptorBuilder has(String key, String value) throws IllegalArgumentException

An instance of data to be associated with this descriptor

Parameters
key:String

The key for the data to be associated with this descriptor

value:String

The value this key should take (single value metadata)

Returns:DescriptorBuilder

A DescriptorBuilder with the given metadata

hasback to summary
public DescriptorBuilder has(String key, List<String> values) throws IllegalArgumentException

An instance of data to be associated with this descriptor

Parameters
key:String

The key for the data to be associated with this descriptor

values:List<String>

The values this key should take (single value metadata)

Returns:DescriptorBuilder

A DescriptorBuilder with the given metadata

inback to summary
public DescriptorBuilder 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:Class<? extends Annotation>

The class of the scope this descriptor is to have.

Returns:DescriptorBuilder

A DescriptorBuilder with the given scope

Exceptions
IllegalArgumentException:
If in is called more than once
inback to summary
public DescriptorBuilder in(String 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:String

The fully qualified class name of the scope this predicate is to have.

Returns:DescriptorBuilder

A DescriptorBuilder with the given scope

Exceptions
IllegalArgumentException:
If in is called more than once
localOnlyback to summary
public DescriptorBuilder localOnly()

This will cause the descriptorVisibility field of the returned descriptor to return LOCAL

Returns:DescriptorBuilder

A DescriptorBuilder with the descriptorVisibility field to be set to LOCAL

namedback to summary
public DescriptorBuilder 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:String

The name to be associated with this Descriptor

Returns:DescriptorBuilder

A DescriptorBuilder with the given name

Exceptions
IllegalArgumentException:
if there is more than one name on the predicate
ofRankback to summary
public DescriptorBuilder ofRank(int rank)

The rank to be associated with this descriptor. The last rank bound wins

Parameters
rank:int

The rank to be associated with this descriptor.

Returns:DescriptorBuilder

A DescriptorBuilder with the given rank

proxyback to summary
public DescriptorBuilder proxy()

This will cause the isProxiable field of the returned descriptor to return true (it will force this descriptor to use proxies).

Returns:DescriptorBuilder

A DescriptorBuilder with the proxiable field set to true

proxyback to summary
public DescriptorBuilder proxy(boolean forceProxy)

This will cause the isProxiable field of the returned descriptor to return the given value.

Parameters
forceProxy:boolean

if true then this descriptor will be proxied, if false then this descriptor will NOT be proxied

Returns:DescriptorBuilder

A DescriptorBuilder with the proxiable field set to the given value

proxyForSameScopeback to summary
public DescriptorBuilder proxyForSameScope()

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).

Returns:DescriptorBuilder

A DescriptorBuilder with the proxyForSameScope field set to true

proxyForSameScopeback to summary
public DescriptorBuilder proxyForSameScope(boolean proxyForSameScope)

This will cause the isProxyForSameScope field of the returned descriptor to return the given value.

Parameters
proxyForSameScope:boolean

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:DescriptorBuilder

A DescriptorBuilder with the proxyForSameScope field set to the given value

qualifiedByback to summary
public DescriptorBuilder qualifiedBy(Annotation annotation) throws IllegalArgumentException

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 the org.glassfish.hk2.api.Descriptor. 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 is ActiveDescriptorBuilder#qualifiedBy(Annotation)

Parameters
annotation:Annotation

The annotation to be associated with this descriptor

Returns:DescriptorBuilder

A DescriptorBuilder with the given annotation

Exceptions
IllegalArgumentException:
on failures
qualifiedByback to summary
public DescriptorBuilder qualifiedBy(String annotation) throws IllegalArgumentException

A qualifier to be associated with this descriptor object

Parameters
annotation:String

The fully qualified class name of an annotation to be associated with this descriptor

Returns:DescriptorBuilder

A DescriptorBuilder with the given annotation

Exceptions
IllegalArgumentException:
on failures
toback to summary
public DescriptorBuilder to(Class<?> contract) throws IllegalArgumentException

A contract to be associated with this descriptor object.

Parameters
contract:Class<?>

A class that is annotated with Contract to be associated with this Descriptor

Returns:DescriptorBuilder

A DescriptorBuilder with the given name

Exceptions
IllegalArgumentException:
on failures
toback to summary
public DescriptorBuilder to(String contract) throws IllegalArgumentException

A contract to be associated with this descriptor object.

Parameters
contract:String

The fully qualified name of a class that is annotated with Contract.

Returns:DescriptorBuilder

A DescriptorBuilder with the given name

Exceptions
IllegalArgumentException:
on failures
visibilityback to summary
public DescriptorBuilder visibility(DescriptorVisibility visibility)

This will set the descriptorVisibility field of the returned descriptor

Parameters
visibility:DescriptorVisibility

The non-null visibility that this descriptor should take

Returns:DescriptorBuilder

A DescriptorBuilder with the descriptorVisibility field set to the input value