Top Description Methods
org.glassfish.hk2.utilities

public Interface ActiveDescriptorBuilder

Known Direct Implementers
org.glassfish.hk2.internal.ActiveDescriptorBuilderImpl
Imports
java.lang.annotation.Annotation, java.lang.reflect.Type, java.util.List, org.glassfish.hk2.api.DescriptorVisibility, .HK2Loader

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 jakarta.inject.Qualifier or contracts that are not marked with org.jvnet.hk2.annotations.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

Modifier and TypeMethod and Description
public ActiveDescriptorBuilder

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 ActiveDescriptorBuilder

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 ActiveDescriptorBuilder

Returns:

A DescriptorBuilder with the given implementationType
asType
(Type
The non-null ParameterizedType describing the implementation
t
)

Call this if the parameterized type of the implementation class is known.

public <T> AbstractActiveDescriptor<T>

Returns:

The descriptor that has been built up
build
()

Generates a descriptor that can be used in binding operations

public <T> AbstractActiveDescriptor<T>

Returns:

The descriptor that has been built up, of type PROVIDE_METHOD
buildFactory
()
Deprecated Use buildProvideMethod instead

Generates a descriptor that can be used in binding operations that describes a factorys provide method

public <T> AbstractActiveDescriptor<T>

Returns:

The descriptor that has been built up, of type PROVIDE_METHOD
buildProvideMethod
()

Generates a descriptor that can be used in binding operations that describes a factorys provide method

public ActiveDescriptorBuilder

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 ActiveDescriptorBuilder

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 ActiveDescriptorBuilder

Returns:

A DescriptorBuilder with the given scope
in
(Annotation
The class of the scope this descriptor is to have.
scope
)

A scope to be associated with this descriptor object.

public ActiveDescriptorBuilder

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 ActiveDescriptorBuilder

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 ActiveDescriptorBuilder

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 ActiveDescriptorBuilder

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 ActiveDescriptorBuilder

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 ActiveDescriptorBuilder

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 ActiveDescriptorBuilder

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 use proxies even when injecting into the same scope).

public ActiveDescriptorBuilder

Returns:

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

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

public ActiveDescriptorBuilder

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 ActiveDescriptorBuilder

Returns:

A DescriptorBuilder with the given name
to
(Type
A class that is annotated with Contract to be associated with this Descriptor
contract
)

A contract to be associated with this descriptor object.

public ActiveDescriptorBuilder

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

A DescriptorBuilder with the given analysis service

andLoadWithback to summary
public ActiveDescriptorBuilder 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:ActiveDescriptorBuilder

A DescriptorBuilder with the given HK2Loader

Exceptions
IllegalArgumentException:
if the HK2Loader is set non-null more than once
asTypeback to summary
public ActiveDescriptorBuilder asType(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:Type

The non-null ParameterizedType describing the implementation

Returns:ActiveDescriptorBuilder

A DescriptorBuilder with the given implementationType

buildback to summary
public <T> AbstractActiveDescriptor<T> build() throws IllegalArgumentException

Generates a descriptor that can be used in binding operations

Returns:AbstractActiveDescriptor<T>

The descriptor that has been built up

Exceptions
IllegalArgumentException:
if the built descriptor is invalid
buildFactoryback to summary
public <T> AbstractActiveDescriptor<T> buildFactory() throws IllegalArgumentException

Deprecated

Use buildProvideMethod instead

Generates a descriptor that can be used in binding operations that describes a factorys provide method

Returns:AbstractActiveDescriptor<T>

The descriptor that has been built up, of type PROVIDE_METHOD

Annotations
@Deprecated
Exceptions
IllegalArgumentException:
if the built descriptor is invalid
buildProvideMethodback to summary
public <T> AbstractActiveDescriptor<T> buildProvideMethod() throws IllegalArgumentException

Generates a descriptor that can be used in binding operations that describes a factorys provide method

Returns:AbstractActiveDescriptor<T>

The descriptor that has been built up, of type PROVIDE_METHOD

Exceptions
IllegalArgumentException:
if the built descriptor is invalid
hasback to summary
public ActiveDescriptorBuilder 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:ActiveDescriptorBuilder

A DescriptorBuilder with the given metadata

hasback to summary
public ActiveDescriptorBuilder 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:ActiveDescriptorBuilder

A DescriptorBuilder with the given metadata

inback to summary
public ActiveDescriptorBuilder in(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:Annotation

The class of the scope this descriptor is to have.

Returns:ActiveDescriptorBuilder

A DescriptorBuilder with the given scope

Exceptions
IllegalArgumentException:
If in is called more than once
inback to summary
public 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:Class<? extends Annotation>

The class of the scope this descriptor is to have.

Returns:ActiveDescriptorBuilder

A DescriptorBuilder with the given scope

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

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

Returns:ActiveDescriptorBuilder

A DescriptorBuilder with the descriptorVisibility field to be set to LOCAL

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

The name to be associated with this Descriptor

Returns:ActiveDescriptorBuilder

A DescriptorBuilder with the given name

Exceptions
IllegalArgumentException:
if there is more than one name on the predicate
ofRankback to summary
public ActiveDescriptorBuilder 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:ActiveDescriptorBuilder

A DescriptorBuilder with the given rank

proxyback to summary
public ActiveDescriptorBuilder proxy()

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

Returns:ActiveDescriptorBuilder

A DescriptorBuilder with the proxiable field set to true

proxyback to summary
public ActiveDescriptorBuilder 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:ActiveDescriptorBuilder

A DescriptorBuilder with the proxiable field set to the given value

proxyForSameScopeback to summary
public 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:ActiveDescriptorBuilder

A DescriptorBuilder with the proxyForSameScope field set to true

proxyForSameScopeback to summary
public ActiveDescriptorBuilder proxyForSameScope(boolean forceProxyForSameScope)

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

Parameters
forceProxyForSameScope:boolean

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

A DescriptorBuilder with the proxyForSameScope field set to the given value

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

A qualifier to be associated with this descriptor object

Parameters
annotation:Annotation

The annotation to be associated with this descriptor

Returns:ActiveDescriptorBuilder

A DescriptorBuilder with the given annotation

Exceptions
IllegalArgumentException:
on failures
toback to summary
public ActiveDescriptorBuilder to(Type contract) throws IllegalArgumentException

A contract to be associated with this descriptor object.

Parameters
contract:Type

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

Returns:ActiveDescriptorBuilder

A DescriptorBuilder with the given name

Exceptions
IllegalArgumentException:
on failures
visibilityback to summary
public ActiveDescriptorBuilder 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:ActiveDescriptorBuilder

A DescriptorBuilder with the descriptorVisibility field set to the input value