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

public Interface ScopedBindingBuilder<T>

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

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

Method Summary

Modifier and TypeMethod and Description
public ScopedBindingBuilder<T>
analyzeWith(String
The name of the analyzer that should be used. May be null to indicate the default class analzyer
analyzer
)

Set the name of the org.glassfish.hk2.api.ClassAnalyzer on the binding.

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

Returns:

updated binding.
named
(String
new name value.
name
)

Name the binding.

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

Set proxy flag on the binding.

public ScopedBindingBuilder<T>

Returns:

A further refined builder
proxyForSameScope
(boolean
flag to determine if the binding should be proxiable within the same scope
proxyForSameScope
)

Set proxyForSameScope flag on the binding

public ScopedBindingBuilder<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 ScopedBindingBuilder<T>

Returns:

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

Bind a new contract to a service.

public ScopedBindingBuilder<T>

Returns:

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

Bind a new contract to a service.

public ScopedBindingBuilder<T>

Returns:

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

Add binding descriptor metadata.

public ScopedBindingBuilder<T>

Returns:

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

Add binding descriptor metadata.

Method Detail

analyzeWithback to summary
public ScopedBindingBuilder<T> analyzeWith(String analyzer)

Set the name of the org.glassfish.hk2.api.ClassAnalyzer on the binding.

Parameters
analyzer:String

The name of the analyzer that should be used. May be null to indicate the default class analzyer

loadedByback to summary
public ScopedBindingBuilder<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:ScopedBindingBuilder<T>

updated binder.

namedback to summary
public ScopedNamedBindingBuilder<T> named(String name)

Name the binding.

Parameters
name:String

new name value.

Returns:ScopedNamedBindingBuilder<T>

updated binding.

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

Set proxy flag on the binding.

Parameters
proxiable:boolean

flag to determine if the binding should be proxiable.

proxyForSameScopeback to summary
public ScopedBindingBuilder<T> proxyForSameScope(boolean proxyForSameScope)

Set proxyForSameScope flag on the binding

Parameters
proxyForSameScope:boolean

flag to determine if the binding should be proxiable within the same scope

Returns:ScopedBindingBuilder<T>

A further refined builder

qualifiedByback to summary
public ScopedBindingBuilder<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:ScopedBindingBuilder<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 ScopedBindingBuilder<T> to(Class<? super T> contract)

Bind a new contract to a service.

Parameters
contract:Class<? super T>

contract type.

Returns:ScopedBindingBuilder<T>

updated binder.

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

Bind a new contract to a service.

Parameters
contract:TypeLiteral<?>

contract type.

Returns:ScopedBindingBuilder<T>

updated binder.

withMetadataback to summary
public ScopedBindingBuilder<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:ScopedBindingBuilder<T>

updated binder.

withMetadataback to summary
public ScopedBindingBuilder<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:ScopedBindingBuilder<T>

updated binder.