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 Weighted
DEFAULT_WEIGHTModifier and TypeFieldDescriptionstatic final doubleDefault weight for any weighted component (whether it implements this interface or usesWeightannotation). -
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).booleaninthashCode()instantiate(DependencyContext ctx, InterceptionMetadata metadata) Create a new service instance.Type of the service this descriptor describes.toString()doubleweight()Weight of this class (maybe because it is defined dynamically, so it cannot be defined by an annotation).Methods inherited from interface ServiceDescriptor
inject, postConstruct, preDestroy, scope, typeSetModifier and TypeMethodDescriptiondefault voidinject(DependencyContext ctx, InterceptionMetadata interceptionMetadata, Set<String> injected, T instance) Inject fields and methods.default voidpostConstruct(T instance) InvokeService.PostConstructannotated method(s).default voidpreDestroy(T instance) InvokeService.PreDestroyannotated method(s).default TypeNamescope()Scope of this service.default Set<ResolvedType> typeSet(ResolvedType contract) Provide a mapping of a contracts of this service to its contract type set.Methods inherited from interface ServiceInfo
dependencies, factoryContracts, factoryType, isAbstract, providedType, qualifiers, runLevelModifier and TypeMethodDescriptiondefault List<Dependency> List of dependencies required by this service.default Set<ResolvedType> Set of contracts that identify the factory provider itself.default FactoryTypeWhat factory type is the described service.default booleanReturnstruefor abstract classes and interfaces, returnsfalseby default.default TypeNameThe type that implementsServiceInfo.contracts().Service qualifiers.runLevel()Run level of this service.
-
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:ServiceInfoType of the service this descriptor describes.- Specified by:
serviceTypein interfaceServiceInfo- Returns:
- service type
-
descriptorType
Description copied from interface:ServiceInfoType of the service descriptor (usually generated).- Specified by:
descriptorTypein interfaceServiceInfo- Returns:
- descriptor type
-
contracts
Description copied from interface:ServiceInfoSet of contracts the described service implements or provides through a factory method.- Specified by:
contractsin interfaceServiceInfo- Returns:
- set of contracts
-
instantiate
Description copied from interface:ServiceDescriptorCreate a new service instance.- Specified by:
instantiatein 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:WeightedWeight of this class (maybe because it is defined dynamically, so it cannot be defined by an annotation). If not dynamic, you can use theWeightannotation rather than implementing this interface as long as it is supported by the library using thisWeighted. -
toString
-
equals
-
hashCode
-