Interface BaseHandlerConfig
- All Superinterfaces:
Prototype.Api
- All Known Subinterfaces:
ClasspathHandlerConfig, FileSystemHandlerConfig
- All Known Implementing Classes:
BaseHandlerConfig.BuilderBase.BaseHandlerConfigImpl, ClasspathHandlerConfig.BuilderBase.ClasspathHandlerConfigImpl, FileSystemHandlerConfig.BuilderBase.FileSystemHandlerConfigImpl
Configuration of static content handlers that is common for classpath and file system based handlers.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classFluent API builder forBaseHandlerConfig.static classBaseHandlerConfig.BuilderBase<BUILDER extends BaseHandlerConfig.BuilderBase<BUILDER, PROTOTYPE>, PROTOTYPE extends BaseHandlerConfig>Fluent API builder base forBaseHandlerConfig. -
Method Summary
Modifier and TypeMethodDescriptionstatic BaseHandlerConfig.Builderbuilder()Create a new fluent API builder to customize configuration.static BaseHandlerConfig.Builderbuilder(BaseHandlerConfig instance) Create a new fluent API builder from an existing instance.A set of files that are cached in memory at startup.Maps a filename extension to the response content type.context()Context that will serve this handler's static resources, defaults to/.static BaseHandlerConfigCreate a new instance from configuration.booleanenabled()Whether this handle is enabled, defaults totrue.Handles will use memory cache configured onStaticContentConfig.memoryCache()by default.Map request path to resource path.Whether pre-compressed sidecar resources should be selected for this handler; feature-registered handlers inherit the feature value when absent, directly created handlers default to disabled, and file system handlers configured with a single file always require handler-level opt-in.Pre-compressed content coding to file suffix mappings; handler mappings replace inherited feature-level mappings rather than merging with them, an explicit empty map disables sidecar lookups for this handler, codings must be unique concrete valid HTTP tokens other thanidentityand*, and suffixes have leading dots ignored and must not contain path separators.Configures the capacity of the cache used for resource metadata.sockets()Sockets names (listeners) that will host this static content handler, defaults to all configured sockets.welcome()Welcome-file name.
-
Method Details
-
builder
Create a new fluent API builder to customize configuration.- Returns:
- a new builder
-
builder
Create a new fluent API builder from an existing instance.- Parameters:
instance- an existing instance used as a base for the builder- Returns:
- a builder based on an instance
-
create
Create a new instance from configuration.- Parameters:
config- used to configure the new instance- Returns:
- a new instance configured from configuration
-
enabled
boolean enabled()Whether this handle is enabled, defaults totrue.- Returns:
- whether enabled
-
context
String context()Context that will serve this handler's static resources, defaults to/.- Returns:
- context under webserver
-
sockets
-
welcome
-
cachedFiles
A set of files that are cached in memory at startup. These files are never removed from the in-memory cache, though their overall size is added to the memory cache used bytes. When using classpath, the set must contain explicit list of all files that should be cached, when using file system, it can contain a directory, and all files under that directory (recursive) would be cached as well.Note that files cached through this method may use more than the max-bytes configured for the in-memory cache (i.e. this option wins over the maximal size in bytes), so kindly be careful with what is pushed to the cache.
Files cached in memory are snapshots. They remain available and are never re-loaded, even if their source is changed or removed, until server restart!
- Returns:
- set of file names (or directory names if not using classpath) to cache in memory on startup
-
memoryCache
Optional<MemoryCache> memoryCache()Handles will use memory cache configured onStaticContentConfig.memoryCache()by default. In case a memory cache is configured here, it will replace the memory cache used by the static content feature, and this handle will use a dedicated memory cache instead.To disable memory caching for a single handler, create the configuration, and set
enabled: false.- Returns:
- memory cache to use with this handler
-
contentTypes
Maps a filename extension to the response content type. To have a system-wide configuration, you can use the service loader SPIMediaTypeDetector.This method can override
MediaTypesdetection for a specific static content handler.Handler will use a union of configuration on the
StaticContentConfigand here when used from configuration.- Returns:
- map of file extensions to associated media type
-
pathMapper
-
recordCacheCapacity
Configures the capacity of the cache used for resource metadata. Pre-compressed sidecar lookup state is attached to the corresponding normal resource record.To cache content (bytes) in memory, use
memoryCache()- Returns:
- maximal number of cached records; records do not contain the content bytes
-
preCompressedEnabled
Whether pre-compressed sidecar resources should be selected for this handler; feature-registered handlers inherit the feature value when absent, directly created handlers default to disabled, and file system handlers configured with a single file always require handler-level opt-in.- Returns:
- whether pre-compressed sidecar resources should be used
-
preCompressedEncodings
Pre-compressed content coding to file suffix mappings; handler mappings replace inherited feature-level mappings rather than merging with them, an explicit empty map disables sidecar lookups for this handler, codings must be unique concrete valid HTTP tokens other thanidentityand*, and suffixes have leading dots ignored and must not contain path separators.- Returns:
- content coding to file suffix mappings
-