Top Description Methods
org.glassfish.hk2.utilities.binding

public Interface NamedBindingBuilder<T>

extends BindingBuilder<T>
Known Direct Implementers
org.glassfish.hk2.utilities.binding.AbstractBindingBuilder
Type Parameters
<T>
service type.
Imports
java.lang.annotation.Annotation, java.lang.reflect.Type, java.util.List, org.glassfish.hk2.api.HK2Loader, .TypeLiteral

Named service binding builder.
Author
Marek Potociar (marek.potociar at oracle.com)

Method Summary

Modifier and TypeMethod and Description
public NamedBindingBuilder<T>

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 ScopedNamedBindingBuilder<T>

Returns:

updated binding.
in
(Class<? extends Annotation>
scope annotation.
scopeAnnotation
)

Scope a binding.

public NamedBindingBuilder<T>

Returns:

updated binder.
loadedBy
(HK2Loader
custom service loader.
loader
)

Custom HK2 loader to be used when service class is about to be loaded.

public NamedBindingBuilder<T>
proxy(boolean
flag to determine if the binding should be proxiable.
proxiable
)

Set proxy flag on the binding.

public NamedBindingBuilder<T>

Returns:

updated binder.
qualifiedBy
(Annotation
qualifier annotation.
annotation
)

Add a binging qualifier annotation.

public void
ranked(int
binding rank to be used to resolve ordering in case of multiple services are bound to the same contract.
rank
)

Rank the binding.

public NamedBindingBuilder<T>

Returns:

updated binder.
to
(Class<? super T>
contract type.
contract
)

Bind a new contract to a service.

public NamedBindingBuilder<T>

Returns:

updated binder.
to
(TypeLiteral<?>
contract type.
contract
)

Bind a new contract to a service.

public NamedBindingBuilder<T>

Returns:

updated binder.
withMetadata
(String
metadata key.
key
,
String
metadata value.
value
)

Add binding descriptor metadata.

public NamedBindingBuilder<T>

Returns:

updated binder.
withMetadata
(String
metadata key.
key
,
List<String>
metadata values.
values
)

Add binding descriptor metadata.

Method Detail

asTypeback to summary
public NamedBindingBuilder<T> asType(Type t)

Call this if the parameterized type of the implementation class is known. This must only be called with a ParameterizedType

Parameters
t:Type

The non-null ParameterizedType describing the implementation

Returns:NamedBindingBuilder<T>

A DescriptorBuilder with the given implementationType

inback to summary
public ScopedNamedBindingBuilder<T> in(Class<? extends Annotation> scopeAnnotation)

Scope a binding.

Parameters
scopeAnnotation:Class<? extends Annotation>

scope annotation.

Returns:ScopedNamedBindingBuilder<T>

updated binding.

loadedByback to summary
public NamedBindingBuilder<T> loadedBy(HK2Loader loader)

Custom HK2 loader to be used when service class is about to be loaded.

Parameters
loader:HK2Loader

custom service loader.

Returns:NamedBindingBuilder<T>

updated binder.

proxyback to summary
public NamedBindingBuilder<T> proxy(boolean proxiable)

Set proxy flag on the binding.

Parameters
proxiable:boolean

flag to determine if the binding should be proxiable.

qualifiedByback to summary
public NamedBindingBuilder<T> qualifiedBy(Annotation annotation)

Add a binging qualifier annotation. If this is being used with a org.glassfish.hk2.api.Factory then both the Factory Service and the org.glassfish.hk2.api.Factory#provide() method will get the qualifier

Parameters
annotation:Annotation

qualifier annotation.

Returns:NamedBindingBuilder<T>

updated binder.

rankedback to summary
public void ranked(int rank)

Rank the binding. The higher rank, the more prominent position in an injected iterable provider for a contract.

Parameters
rank:int

binding rank to be used to resolve ordering in case of multiple services are bound to the same contract.

toback to summary
public NamedBindingBuilder<T> to(Class<? super T> contract)

Bind a new contract to a service.

Parameters
contract:Class<? super T>

contract type.

Returns:NamedBindingBuilder<T>

updated binder.

toback to summary
public NamedBindingBuilder<T> to(TypeLiteral<?> contract)

Bind a new contract to a service.

Parameters
contract:TypeLiteral<?>

contract type.

Returns:NamedBindingBuilder<T>

updated binder.

withMetadataback to summary
public NamedBindingBuilder<T> withMetadata(String key, String value)

Add binding descriptor metadata. The metadata can be later used to e.g. filter binding descriptors. If this is for org.glassfish.hk2.api.Factory descriptors the metadata will be placed on both the Factory as a service and on the Factories org.glassfish.hk2.api.Factory#provide() method

Parameters
key:String

metadata key.

value:String

metadata value.

Returns:NamedBindingBuilder<T>

updated binder.

withMetadataback to summary
public NamedBindingBuilder<T> withMetadata(String key, List<String> values)

Add binding descriptor metadata. The metadata can be later used to e.g. filter binding descriptors. If this is for org.glassfish.hk2.api.Factory descriptors the metadata will be placed on both the Factory as a service and on the Factories org.glassfish.hk2.api.Factory#provide() method

Parameters
key:String

metadata key.

values:List<String>

metadata values.

Returns:NamedBindingBuilder<T>

updated binder.