Class AbstractBindingBuilder<T>
java.lang.Object
org.glassfish.hk2.utilities.binding.AbstractBindingBuilder<T>
- Type Parameters:
T- bound service type.
- All Implemented Interfaces:
BindingBuilder<T>,NamedBindingBuilder<T>,ScopedBindingBuilder<T>,ScopedNamedBindingBuilder<T>,ServiceBindingBuilder<T>
- Direct Known Subclasses:
AbstractBindingBuilder.ClassBasedBindingBuilder,AbstractBindingBuilder.FactoryInstanceBasedBindingBuilder,AbstractBindingBuilder.FactoryTypeBasedBindingBuilder,AbstractBindingBuilder.InstanceBasedBindingBuilder
abstract class AbstractBindingBuilder<T>
extends Object
implements ServiceBindingBuilder<T>, NamedBindingBuilder<T>, ScopedBindingBuilder<T>, ScopedNamedBindingBuilder<T>
Abstract binding builder implementation.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classprivate static classprivate static classprivate static class -
Field Summary
FieldsModifier and TypeFieldDescription(package private) StringAnalyzer to use with this descriptorContracts the service should be bound to.(package private) Type(package private) HK2LoaderBound service loader.Binding metadata (e.g.(package private) StringBinding name (see @Named).(package private) BooleanInjectee is proxiable.(package private) BooleanInjectee should be proxied even inside the same scope(package private) Set<Annotation> Qualifiers (other than @Named).(package private) IntegerBinding rank.(package private) Class<? extends Annotation> Binding scope.(package private) AnnotationBinding scope as annotation -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionanalyzeWith(String analyzer) Set the name of theClassAnalyzeron the binding.Call this if the parameterized type of the implementation class is known.(package private) abstract voidcomplete(DynamicConfiguration configuration, HK2Loader defaultLoader) Build the binding descriptor and bind it in thedynamic configuration.(package private) static <T> AbstractBindingBuilder<T> Create a new service binding builder.(package private) static <T> AbstractBindingBuilder<T> Create a new service binding builder.(package private) static <T> AbstractBindingBuilder<T> create(TypeLiteral<T> serviceType, boolean bindAsContract) Create a new service binding builder.(package private) static <T> AbstractBindingBuilder<T> create(T service) Create a new service binding builder.(package private) static <T> AbstractBindingBuilder<T> createFactoryBinder(Class<? extends Factory<T>> factoryType, Class<? extends Annotation> factoryScope) Create a new service binding builder.(package private) static <T> AbstractBindingBuilder<T> createFactoryBinder(Factory<T> factory) Create a new service binding builder.in(Annotation scopeAnnotation) Scope a binding.in(Class<? extends Annotation> scopeAnnotation) Scope a binding.Custom HK2 loader to be used when service class is about to be loaded.Namethe binding.proxy(boolean proxiable) Set proxy flag on the binding.proxyForSameScope(boolean proxyForSameScope) Set proxyForSameScope flag on the bindingqualifiedBy(Annotation annotation) Add a binding qualifier annotation.voidranked(int rank) Rank the binding.Bind a new contract to a service.Bind a new contract to a service.to(TypeLiteral<?> contract) Bind a new contract to a service.withMetadata(String key, String value) Add binding descriptor metadata.withMetadata(String key, List<String> values) Add binding descriptor metadata.
-
Field Details
-
contracts
Contracts the service should be bound to. -
loader
HK2Loader loaderBound service loader. -
metadata
Binding metadata (e.g. useful for filtering). -
qualifiers
Set<Annotation> qualifiersQualifiers (other than @Named). -
scopeAnnotation
Annotation scopeAnnotationBinding scope as annotation -
scope
Class<? extends Annotation> scopeBinding scope. -
ranked
Integer rankedBinding rank. -
name
String nameBinding name (see @Named). -
proxiable
Boolean proxiableInjectee is proxiable. -
proxyForSameScope
Boolean proxyForSameScopeInjectee should be proxied even inside the same scope -
implementationType
Type implementationType -
analyzer
String analyzerAnalyzer to use with this descriptor
-
-
Constructor Details
-
AbstractBindingBuilder
AbstractBindingBuilder()
-
-
Method Details
-
proxy
Description copied from interface:ServiceBindingBuilderSet proxy flag on the binding.- Specified by:
proxyin interfaceNamedBindingBuilder<T>- Specified by:
proxyin interfaceScopedBindingBuilder<T>- Specified by:
proxyin interfaceScopedNamedBindingBuilder<T>- Specified by:
proxyin interfaceServiceBindingBuilder<T>- Parameters:
proxiable- flag to determine if the binding should be proxiable.
-
proxyForSameScope
Description copied from interface:ServiceBindingBuilderSet proxyForSameScope flag on the binding- Specified by:
proxyForSameScopein interfaceScopedBindingBuilder<T>- Specified by:
proxyForSameScopein interfaceServiceBindingBuilder<T>- Parameters:
proxyForSameScope- flag to determine if proxies should be generated even within the same scope- Returns:
- A further refined ServiceBindingBuilder
-
analyzeWith
Description copied from interface:ServiceBindingBuilderSet the name of theClassAnalyzeron the binding.- Specified by:
analyzeWithin interfaceScopedBindingBuilder<T>- Specified by:
analyzeWithin interfaceScopedNamedBindingBuilder<T>- Specified by:
analyzeWithin interfaceServiceBindingBuilder<T>- Parameters:
analyzer- The name of the analyzer that should be used. May be null to indicate the default class analzyer
-
to
Description copied from interface:ServiceBindingBuilderBind a new contract to a service.- Specified by:
toin interfaceNamedBindingBuilder<T>- Specified by:
toin interfaceScopedBindingBuilder<T>- Specified by:
toin interfaceScopedNamedBindingBuilder<T>- Specified by:
toin interfaceServiceBindingBuilder<T>- Parameters:
contract- contract type.- Returns:
- updated binder.
-
to
Description copied from interface:ServiceBindingBuilderBind a new contract to a service.- Specified by:
toin interfaceNamedBindingBuilder<T>- Specified by:
toin interfaceScopedBindingBuilder<T>- Specified by:
toin interfaceScopedNamedBindingBuilder<T>- Specified by:
toin interfaceServiceBindingBuilder<T>- Parameters:
contract- contract type.- Returns:
- updated binder.
-
to
Description copied from interface:ServiceBindingBuilderBind a new contract to a service.- Specified by:
toin interfaceServiceBindingBuilder<T>- Parameters:
contract- contract type.- Returns:
- updated binder.
-
loadedBy
Description copied from interface:ServiceBindingBuilderCustom HK2 loader to be used when service class is about to be loaded.- Specified by:
loadedByin interfaceNamedBindingBuilder<T>- Specified by:
loadedByin interfaceScopedBindingBuilder<T>- Specified by:
loadedByin interfaceScopedNamedBindingBuilder<T>- Specified by:
loadedByin interfaceServiceBindingBuilder<T>- Parameters:
loader- custom service loader.- Returns:
- updated binder.
-
withMetadata
Description copied from interface:ServiceBindingBuilderAdd binding descriptor metadata. The metadata can be later used to e.g.filterbinding descriptors. If this is forFactorydescriptors the metadata will be placed on both the Factory as a service and on the FactoriesFactory.provide()method- Specified by:
withMetadatain interfaceNamedBindingBuilder<T>- Specified by:
withMetadatain interfaceScopedBindingBuilder<T>- Specified by:
withMetadatain interfaceScopedNamedBindingBuilder<T>- Specified by:
withMetadatain interfaceServiceBindingBuilder<T>- Parameters:
key- metadata key.value- metadata value.- Returns:
- updated binder.
-
withMetadata
Description copied from interface:ServiceBindingBuilderAdd binding descriptor metadata. The metadata can be later used to e.g.filterbinding descriptors. If this is forFactorydescriptors the metadata will be placed on both the Factory as a service and on the FactoriesFactory.provide()method- Specified by:
withMetadatain interfaceNamedBindingBuilder<T>- Specified by:
withMetadatain interfaceScopedBindingBuilder<T>- Specified by:
withMetadatain interfaceScopedNamedBindingBuilder<T>- Specified by:
withMetadatain interfaceServiceBindingBuilder<T>- Parameters:
key- metadata key.values- metadata values.- Returns:
- updated binder.
-
qualifiedBy
Description copied from interface:ServiceBindingBuilderAdd a binding qualifier annotation. If this is being used with aFactorythen both the Factory Service and theFactory.provide()method will get the qualifier- Specified by:
qualifiedByin interfaceNamedBindingBuilder<T>- Specified by:
qualifiedByin interfaceScopedBindingBuilder<T>- Specified by:
qualifiedByin interfaceScopedNamedBindingBuilder<T>- Specified by:
qualifiedByin interfaceServiceBindingBuilder<T>- Parameters:
annotation- qualifier annotation.- Returns:
- updated binder.
-
in
Description copied from interface:ServiceBindingBuilderScope a binding.- Specified by:
inin interfaceServiceBindingBuilder<T>- Parameters:
scopeAnnotation- scope annotation.- Returns:
- updated binding.
-
in
Description copied from interface:ServiceBindingBuilderScope a binding.- Specified by:
inin interfaceNamedBindingBuilder<T>- Specified by:
inin interfaceServiceBindingBuilder<T>- Parameters:
scopeAnnotation- scope annotation.- Returns:
- updated binding.
-
named
Description copied from interface:ServiceBindingBuilderNamethe binding.- Specified by:
namedin interfaceScopedBindingBuilder<T>- Specified by:
namedin interfaceServiceBindingBuilder<T>- Parameters:
name- new name value.- Returns:
- updated binding.
-
ranked
public void ranked(int rank) Description copied from interface:ServiceBindingBuilderRank the binding. The higher rank, the more prominent position in an injectediterable providerfor a contract.- Specified by:
rankedin interfaceNamedBindingBuilder<T>- Specified by:
rankedin interfaceScopedBindingBuilder<T>- Specified by:
rankedin interfaceScopedNamedBindingBuilder<T>- Specified by:
rankedin interfaceServiceBindingBuilder<T>- Parameters:
rank- binding rank to be used to resolve ordering in case of multiple services are bound to the same contract.
-
asType
Description copied from interface:ServiceBindingBuilderCall this if the parameterized type of the implementation class is known. This must only be called with a ParameterizedType- Specified by:
asTypein interfaceNamedBindingBuilder<T>- Specified by:
asTypein interfaceServiceBindingBuilder<T>- Parameters:
t- The non-null ParameterizedType describing the implementation- Returns:
- A DescriptorBuilder with the given implementationType
-
complete
Build the binding descriptor and bind it in thedynamic configuration.- Parameters:
configuration- dynamic binding configuration.defaultLoader- default HK2 loader that should be used in case a custom loader was not set.
-
create
Create a new service binding builder.- Type Parameters:
T- service type.- Parameters:
serviceType- service class.bindAsContract- iftrue, the service class will be bound as one of the contracts.- Returns:
- initialized binding builder.
-
create
Create a new service binding builder.- Type Parameters:
T- service type.- Parameters:
serviceType- service class.bindAsContract- iftrue, the service class will be bound as one of the contracts.- Returns:
- initialized binding builder.
-
create
Create a new service binding builder.- Type Parameters:
T- service type.- Parameters:
serviceType- generic service type.bindAsContract- iftrue, the service class will be bound as one of the contracts.- Returns:
- initialized binding builder.
-
create
Create a new service binding builder.- Parameters:
service- service instance.- Returns:
- initialized binding builder.
-
createFactoryBinder
Create a new service binding builder.- Parameters:
factory- service factory instance.- Returns:
- initialized binding builder.
-
createFactoryBinder
static <T> AbstractBindingBuilder<T> createFactoryBinder(Class<? extends Factory<T>> factoryType, Class<? extends Annotation> factoryScope) Create a new service binding builder.- Parameters:
factoryType- service factory class.factoryScope- service factory scope.- Returns:
- initialized binding builder.
-