Package io.helidon.servicecommon.rest
Class HelidonRestServiceSupport
java.lang.Object
io.helidon.servicecommon.rest.HelidonRestServiceSupport
- All Implemented Interfaces:
RestServiceSupport
,Service
- Direct Known Subclasses:
HealthSupport
,MetricsSupport
,MicrometerSupport
,MinimalMetricsSupport
Common base implementation for service support classes which involve REST endpoints.
This base class takes care of some tasks common to many services, using config and other settings in the builder:
- Setting up the endpoint path (web context) for the service, using settings in the builder and config.
- Providing automatic CORS support (and the ability to control it via config).
Concrete implementations must implement postConfigureEndpoint(Routing.Rules, Routing.Rules)
to do any
service-specific routing.
See also the HelidonRestServiceSupport.Builder
information for possible additional overrides.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
HelidonRestServiceSupport.Builder<B extends HelidonRestServiceSupport.Builder<B,
T>, T extends HelidonRestServiceSupport> Abstract implementation of aBuilder
for the service. -
Constructor Summary
ModifierConstructorDescriptionprotected
HelidonRestServiceSupport
(Logger logger, HelidonRestServiceSupport.Builder<?, ?> builder, String serviceName) Shared initialization for new service support instances.protected
HelidonRestServiceSupport
(Logger logger, RestServiceSettings restServiceSettings, String serviceName) Creates a new service support instance with the specified logger, REST settings, and service name. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
configureEndpoint
(Routing.Rules defaultRules, Routing.Rules serviceEndpointRoutingRules) Configures service endpoint on the provided routing rules.protected String
context()
protected Logger
logger()
protected void
Logic to run when the service is shut down.protected abstract void
postConfigureEndpoint
(Routing.Rules defaultRules, Routing.Rules serviceEndpointRoutingRules) Concrete implementations override this method to perform any service-specific routing set-up.
-
Constructor Details
-
HelidonRestServiceSupport
protected HelidonRestServiceSupport(Logger logger, HelidonRestServiceSupport.Builder<?, ?> builder, String serviceName) Shared initialization for new service support instances.- Parameters:
logger
- theLogger
for the concrete service support instancebuilder
- builder for the service support instance.serviceName
- name of the service
-
HelidonRestServiceSupport
protected HelidonRestServiceSupport(Logger logger, RestServiceSettings restServiceSettings, String serviceName) Creates a new service support instance with the specified logger, REST settings, and service name.- Parameters:
logger
- subclass-specific logger to userestServiceSettings
- REST service settings to useserviceName
- service name for the REST service
-
-
Method Details
-
configureEndpoint
public final void configureEndpoint(Routing.Rules defaultRules, Routing.Rules serviceEndpointRoutingRules) Configures service endpoint on the provided routing rules. This method just adds the endpoint path (as defaulted or configured). This method is exclusive toService.update(io.helidon.webserver.Routing.Rules)
(e.g. you should not use both, as otherwise you would register the endpoint twice)- Specified by:
configureEndpoint
in interfaceRestServiceSupport
- Parameters:
defaultRules
- default routing rules (also acceptsRouting.Builder
serviceEndpointRoutingRules
- actual rules (if different from default) for the service endpoint
-
postConfigureEndpoint
protected abstract void postConfigureEndpoint(Routing.Rules defaultRules, Routing.Rules serviceEndpointRoutingRules) Concrete implementations override this method to perform any service-specific routing set-up.- Parameters:
defaultRules
- defaultRouting.Rules
to be updatedserviceEndpointRoutingRules
- actual rules (if different from the default ones) to be updated for the service endpoint
-
onShutdown
protected void onShutdown()Logic to run when the service is shut down. -
context
- Returns:
- web context
-
logger
- Returns:
- logger in use by the service
-