Interface ServiceBindingBuilder<T>
-
- Type Parameters:
T
- service type.
- All Superinterfaces:
BindingBuilder<T>
- All Known Implementing Classes:
AbstractBindingBuilder
,AbstractBindingBuilder.ClassBasedBindingBuilder
,AbstractBindingBuilder.FactoryInstanceBasedBindingBuilder
,AbstractBindingBuilder.FactoryTypeBasedBindingBuilder
,AbstractBindingBuilder.InstanceBasedBindingBuilder
public interface ServiceBindingBuilder<T> extends BindingBuilder<T>
Service binding builder.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ServiceBindingBuilder<T>
analyzeWith(java.lang.String analyzer)
Set the name of theClassAnalyzer
on the binding.ServiceBindingBuilder<T>
asType(java.lang.reflect.Type t)
Call this if the parameterized type of the implementation class is known.ScopedBindingBuilder<T>
in(java.lang.annotation.Annotation scopeAnnotation)
Scope a binding.ScopedBindingBuilder<T>
in(java.lang.Class<? extends java.lang.annotation.Annotation> scopeAnnotation)
Scope a binding.ServiceBindingBuilder<T>
loadedBy(HK2Loader loader)
Custom HK2 loader to be used when service class is about to be loaded.NamedBindingBuilder<T>
named(java.lang.String name)
Name
the binding.ServiceBindingBuilder<T>
proxy(boolean proxiable)
Set proxy flag on the binding.ServiceBindingBuilder<T>
proxyForSameScope(boolean proxyForSameScope)
Set proxyForSameScope flag on the bindingServiceBindingBuilder<T>
qualifiedBy(java.lang.annotation.Annotation annotation)
Add a binding qualifier annotation.void
ranked(int rank)
Rank the binding.ServiceBindingBuilder<T>
to(java.lang.Class<? super T> contract)
Bind a new contract to a service.ServiceBindingBuilder<T>
to(java.lang.reflect.Type contract)
Bind a new contract to a service.ServiceBindingBuilder<T>
to(TypeLiteral<?> contract)
Bind a new contract to a service.ServiceBindingBuilder<T>
withMetadata(java.lang.String key, java.lang.String value)
Add binding descriptor metadata.ServiceBindingBuilder<T>
withMetadata(java.lang.String key, java.util.List<java.lang.String> values)
Add binding descriptor metadata.
-
-
-
Method Detail
-
to
ServiceBindingBuilder<T> to(java.lang.Class<? super T> contract)
Bind a new contract to a service.- Parameters:
contract
- contract type.- Returns:
- updated binder.
-
to
ServiceBindingBuilder<T> to(TypeLiteral<?> contract)
Bind a new contract to a service.- Parameters:
contract
- contract type.- Returns:
- updated binder.
-
to
ServiceBindingBuilder<T> to(java.lang.reflect.Type contract)
Bind a new contract to a service.- Parameters:
contract
- contract type.- Returns:
- updated binder.
-
loadedBy
ServiceBindingBuilder<T> loadedBy(HK2Loader loader)
Custom HK2 loader to be used when service class is about to be loaded.- Parameters:
loader
- custom service loader.- Returns:
- updated binder.
-
withMetadata
ServiceBindingBuilder<T> withMetadata(java.lang.String key, java.lang.String value)
Add binding descriptor metadata. The metadata can be later used to e.g.filter
binding descriptors. If this is forFactory
descriptors the metadata will be placed on both the Factory as a service and on the FactoriesFactory.provide()
method- Parameters:
key
- metadata key.value
- metadata value.- Returns:
- updated binder.
-
withMetadata
ServiceBindingBuilder<T> withMetadata(java.lang.String key, java.util.List<java.lang.String> values)
Add binding descriptor metadata. The metadata can be later used to e.g.filter
binding descriptors. If this is forFactory
descriptors the metadata will be placed on both the Factory as a service and on the FactoriesFactory.provide()
method- Parameters:
key
- metadata key.values
- metadata values.- Returns:
- updated binder.
-
qualifiedBy
ServiceBindingBuilder<T> qualifiedBy(java.lang.annotation.Annotation annotation)
Add a binding qualifier annotation. If this is being used with aFactory
then both the Factory Service and theFactory.provide()
method will get the qualifier- Parameters:
annotation
- qualifier annotation.- Returns:
- updated binder.
-
in
ScopedBindingBuilder<T> in(java.lang.annotation.Annotation scopeAnnotation)
Scope a binding.- Parameters:
scopeAnnotation
- scope annotation.- Returns:
- updated binding.
-
in
ScopedBindingBuilder<T> in(java.lang.Class<? extends java.lang.annotation.Annotation> scopeAnnotation)
Scope a binding.- Parameters:
scopeAnnotation
- scope annotation.- Returns:
- updated binding.
-
named
NamedBindingBuilder<T> named(java.lang.String name)
Name
the binding.- Parameters:
name
- new name value.- Returns:
- updated binding.
-
ranked
void ranked(int rank)
Rank the binding. The higher rank, the more prominent position in an injectediterable provider
for a contract.- Parameters:
rank
- binding rank to be used to resolve ordering in case of multiple services are bound to the same contract.
-
proxy
ServiceBindingBuilder<T> proxy(boolean proxiable)
Set proxy flag on the binding.- Parameters:
proxiable
- flag to determine if the binding should be proxiable.
-
proxyForSameScope
ServiceBindingBuilder<T> proxyForSameScope(boolean proxyForSameScope)
Set proxyForSameScope flag on the binding- Parameters:
proxyForSameScope
- flag to determine if proxies should be generated even within the same scope- Returns:
- A further refined ServiceBindingBuilder
-
analyzeWith
ServiceBindingBuilder<T> analyzeWith(java.lang.String analyzer)
Set the name of theClassAnalyzer
on the binding.- Parameters:
analyzer
- The name of the analyzer that should be used. May be null to indicate the default class analzyer
-
asType
ServiceBindingBuilder<T> asType(java.lang.reflect.Type t)
Call this if the parameterized type of the implementation class is known. This must only be called with a ParameterizedType- Parameters:
t
- The non-null ParameterizedType describing the implementation- Returns:
- A DescriptorBuilder with the given implementationType
-
-