Package io.helidon.servicecommon.rest
Class HelidonRestServiceSupport
- java.lang.Object
-
- io.helidon.servicecommon.rest.HelidonRestServiceSupport
-
- All Implemented Interfaces:
RestServiceSupport
,Service
- Direct Known Subclasses:
MetricsSupport
,MicrometerSupport
,MinimalMetricsSupport
public abstract class HelidonRestServiceSupport extends Object implements RestServiceSupport
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 theHelidonRestServiceSupport.Builder
information for possible additional overrides.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
HelidonRestServiceSupport.Builder<T extends HelidonRestServiceSupport,B extends HelidonRestServiceSupport.Builder<T,B>>
Abstract implementation of aBuilder
for the service.
-
Constructor Summary
Constructors Modifier Constructor Description protected
HelidonRestServiceSupport(Logger logger, HelidonRestServiceSupport.Builder<?,?> builder, String serviceName)
Shared initialization for new service support instances.protected
HelidonRestServiceSupport(Logger logger, RestServiceSettings restServiceSettings, String serviceName)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
configureEndpoint(Routing.Rules rules)
Deprecated, for removal: This API element is subject to removal in a future version.UseconfigureEndpoint(Routing.Rules, Routing.Rules)
instead and only if invoking this method is absolutely necessary.void
configureEndpoint(Routing.Rules defaultRules, Routing.Rules serviceEndpointRoutingRules)
Configures service endpoint on the provided routing rules.protected String
context()
protected Logger
logger()
protected void
onShutdown()
protected abstract void
postConfigureEndpoint(Routing.Rules defaultRules, Routing.Rules serviceEndpointRoutingRules)
Concrete implementations override this method to perform any service-specific routing set-up.
-
-
-
Constructor Detail
-
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)
-
-
Method Detail
-
configureEndpoint
@Deprecated(since="2.4.0", forRemoval=true) public final void configureEndpoint(Routing.Rules rules)
Deprecated, for removal: This API element is subject to removal in a future version.UseconfigureEndpoint(Routing.Rules, Routing.Rules)
instead and only if invoking this method is absolutely necessary. (Typically, user code should directly invoke neither this method nor the replacement one.)Avoid using this obsolete method.- Parameters:
rules
- routing rules (also acceptsRouting.Builder
-
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()
-
context
protected String context()
-
logger
protected Logger logger()
-
-