services()
.
The global singleton instance is accessed via injectionServices()
. Note that optionally one can provide a
primordial bootstrap configuration to the Injection
services provider. One must establish any bootstrap instance
prior to the first call to injectionServices()
as it will use a default configuration if not explicitly set. Once
the bootstrap has been set it cannot be changed for the lifespan of the JVM.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final io.helidon.inject.api.ServiceInfoCriteria
Empty criteria will match anything and everything.static final io.helidon.inject.api.ContextualServiceQuery
Denotes a match to any (default) service, but required to be matched to at least one.static final String
Tag for putting Injection tooling, processing, and runtime into debug mode. -
Method Summary
Modifier and TypeMethodDescriptionOptionally, the service provider activation log.io.helidon.inject.api.Bootstrap
Returns theBootstrap
configuration instance that was used to initialize this instance.io.helidon.inject.api.InjectionServicesConfig
config()
The governing configuration.static io.helidon.inject.api.ActivationRequest
Will create an activation request either toPhase.ACTIVE
or limited to anyBootstrapBlueprint.limitRuntimePhase()
specified.static Optional
<io.helidon.inject.api.Bootstrap> Retrieves any primordial bootstrap configuration that previously set.static void
globalBootstrap
(io.helidon.inject.api.Bootstrap bootstrap) Sets the primordial bootstrap configuration that will supplyinjectionServices()
during global singleton initialization.static Optional
<InjectionServices> GetInjectionServices
instance if available.injector()
Optionally, the injector.static boolean
Whether debug is enabled.lookups()
Optionally, the set ofServices
lookup criteria that were recorded.Optional
<io.helidon.inject.api.Metrics> metrics()
Optionally, the metrics that are exposed by the provider implementation.static io.helidon.inject.api.Bootstrap
First attempts to locate and return theglobalBootstrap()
and if not found will create a new bootstrap instance.static Services
Short-cut for the following code block.default Services
services()
The service registry.services
(boolean initialize) The service registry.shutdown()
Attempts to perform a gracefulInjector.deactivate(Object, InjectorOptions)
on all managed service instances in theServices
registry.static Phase
The terminal phase for activation that we should not cross.Similar toservices()
, but here if Injection is not available or the services registry has not yet been initialized then this method will returnOptional.empty()
.
-
Field Details
-
TAG_DEBUG
Tag for putting Injection tooling, processing, and runtime into debug mode.- See Also:
-
EMPTY_CRITERIA
static final io.helidon.inject.api.ServiceInfoCriteria EMPTY_CRITERIAEmpty criteria will match anything and everything. -
SERVICE_QUERY_REQUIRED
static final io.helidon.inject.api.ContextualServiceQuery SERVICE_QUERY_REQUIREDDenotes a match to any (default) service, but required to be matched to at least one.
-
-
Method Details
-
isDebugEnabled
static boolean isDebugEnabled()Whether debug is enabled.- Returns:
- whether to debug
-
bootstrap
io.helidon.inject.api.Bootstrap bootstrap()Returns theBootstrap
configuration instance that was used to initialize this instance.- Returns:
- the bootstrap configuration instance
-
globalBootstrap
Retrieves any primordial bootstrap configuration that previously set.- Returns:
- the bootstrap primordial configuration already assigned
- See Also:
-
realizedGlobalBootStrap
static io.helidon.inject.api.Bootstrap realizedGlobalBootStrap()First attempts to locate and return theglobalBootstrap()
and if not found will create a new bootstrap instance.- Returns:
- a bootstrap
-
globalBootstrap
static void globalBootstrap(io.helidon.inject.api.Bootstrap bootstrap) Sets the primordial bootstrap configuration that will supplyinjectionServices()
during global singleton initialization.- Parameters:
bootstrap
- the primordial global bootstrap configuration- See Also:
-
injectionServices
GetInjectionServices
instance if available. The highestWeighted
service will be loaded and returned. Remember to optionally configure any primordialBootstrap
configuration prior to the first call to getInjectionServices
.- Returns:
- the services instance
-
realizedServices
Short-cut for the following code block. During the first invocation theServices
registry will be initialized.return injectionServices().orElseThrow().services();
- Returns:
- the services instance
-
unrealizedServices
Similar toservices()
, but here if Injection is not available or the services registry has not yet been initialized then this method will returnOptional.empty()
. This is convenience for users who conditionally want to use Injection's service registry if it is currently available and in active use, but if not do alternative processing or allocations directly, etc.- Returns:
- the services instance if it has already been activated and initialized, empty otherwise
-
services
The service registry. The first call typically loads and initializes the service registry. To avoid automatic loading and initialization on any first request then consider usingunrealizedServices()
orservices(boolean)
.- Returns:
- the services registry
-
services
The service registry. The first call typically loads and initializes the service registry.- Parameters:
initialize
- true to allow initialization applicable for the 1st request, false to prevent 1st call initialization- Returns:
- the services registry if it is available and already has been initialized, empty if not yet initialized
-
config
io.helidon.inject.api.InjectionServicesConfig config()The governing configuration.- Returns:
- the config
-
injector
Optionally, the injector.- Returns:
- the injector, or empty if not available
-
shutdown
Attempts to perform a gracefulInjector.deactivate(Object, InjectorOptions)
on all managed service instances in theServices
registry. Deactivation is handled within the current thread.If the service provider does not support shutdown an empty is returned.
The default reference implementation will return a map of all service types that were deactivated to any throwable that was observed during that services shutdown sequence.
The order in which services are deactivated is dependent upon whether the
activationLog()
is available. If the activation log is available, then services will be shutdown in reverse chronological order as how they were started. If the activation log is not enabled or found to be empty then the deactivation will be in reverse order ofRunLevel
from the highest value down to the lowest value. If two services share the sameRunLevel
value then the ordering will be based upon the implementation's comparator.When shutdown returns, it is guaranteed that all services were shutdown, or failed to achieve shutdown.
The shutdown timeout from
InjectionServicesConfigBlueprint.shutdownTimeout()
will be applied as the default.- Returns:
- a map of all managed service types deactivated to results of deactivation, or empty if shutdown is not supported
-
activationLog
Optional<ActivationLog> activationLog()Optionally, the service provider activation log.- Returns:
- the injector, or empty if not available
-
metrics
Optional<io.helidon.inject.api.Metrics> metrics()Optionally, the metrics that are exposed by the provider implementation.- Returns:
- the metrics, or empty if not available
-
lookups
Optionally, the set ofServices
lookup criteria that were recorded. This is only available ifInjectionServicesConfigBlueprint.serviceLookupCaching()
is enabled.- Returns:
- the lookup criteria recorded, or empty if not available
-
createActivationRequestDefault
static io.helidon.inject.api.ActivationRequest createActivationRequestDefault()Will create an activation request either toPhase.ACTIVE
or limited to anyBootstrapBlueprint.limitRuntimePhase()
specified.- Returns:
- the activation request
-
terminalActivationPhase
The terminal phase for activation that we should not cross.- Returns:
- the terminal phase for activation
-