Module io.helidon.service.registry
Package io.helidon.service.registry
Class ExistingInstanceDescriptor<T>
java.lang.Object
io.helidon.service.registry.ExistingInstanceDescriptor<T>
- Type Parameters:
T
- type of the instance
- All Implemented Interfaces:
Weighted
,ServiceDescriptor<T>
,ServiceInfo
,Comparable<Weighted>
A special case service descriptor allowing registration of service instances that do not have
a code generated service descriptor, such as for testing.
Note that these instances cannot be used for creating code generated binding, as they do not exist as classes.
-
Field Summary
Fields inherited from interface io.helidon.common.Weighted
DEFAULT_WEIGHT
-
Method Summary
Modifier and TypeMethodDescriptionSet of contracts the described service implements or provides through a factory method.static <T> ExistingInstanceDescriptor
<T> create
(T instance, Collection<Class<? super T>> contracts, double weight) Create a new instance.Type of the service descriptor (usually generated).boolean
int
hashCode()
instantiate
(DependencyContext ctx, InterceptionMetadata metadata) Create a new service instance.Type of the service this descriptor describes.toString()
double
weight()
Weight of this class (maybe because it is defined dynamically, so it cannot be defined by an annotation).Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.helidon.service.registry.ServiceDescriptor
inject, postConstruct, preDestroy, scope
Methods inherited from interface io.helidon.service.registry.ServiceInfo
dependencies, factoryContracts, factoryType, isAbstract, providedType, qualifiers, runLevel
-
Method Details
-
create
public static <T> ExistingInstanceDescriptor<T> create(T instance, Collection<Class<? super T>> contracts, double weight) Create a new instance. The only place this can be used at is withServiceRegistryConfig.BuilderBase.addServiceDescriptor(io.helidon.service.registry.ServiceDescriptor)
.- Type Parameters:
T
- type of the service- Parameters:
instance
- service instance to usecontracts
- contracts of the service (the ones we want service registry to use)weight
- weight of the service- Returns:
- a new service descriptor for the provided information
-
serviceType
Description copied from interface:ServiceInfo
Type of the service this descriptor describes.- Specified by:
serviceType
in interfaceServiceInfo
- Returns:
- service type
-
descriptorType
Description copied from interface:ServiceInfo
Type of the service descriptor (usually generated).- Specified by:
descriptorType
in interfaceServiceInfo
- Returns:
- descriptor type
-
contracts
Description copied from interface:ServiceInfo
Set of contracts the described service implements or provides through a factory method.- Specified by:
contracts
in interfaceServiceInfo
- Returns:
- set of contracts
-
instantiate
Description copied from interface:ServiceDescriptor
Create a new service instance.- Specified by:
instantiate
in interfaceServiceDescriptor<T>
- Parameters:
ctx
- dependency context with all dependencies of this servicemetadata
- metadata handler for interception- Returns:
- a new instance, must be of the type T or a subclass
-
weight
public double weight()Description copied from interface:Weighted
Weight of this class (maybe because it is defined dynamically, so it cannot be defined by an annotation). If not dynamic, you can use theWeight
annotation rather than implementing this interface as long as it is supported by the library using thisWeighted
. -
toString
-
equals
-
hashCode
public int hashCode()
-