Class StaticContentConfig.BuilderBase<BUILDER extends StaticContentConfig.BuilderBase<BUILDER, PROTOTYPE>, PROTOTYPE extends StaticContentConfig>

java.lang.Object
io.helidon.webserver.staticcontent.StaticContentConfig.BuilderBase<BUILDER, PROTOTYPE>
Type Parameters:
BUILDER - type of the builder extending this abstract builder
PROTOTYPE - type of the prototype interface that would be built by Prototype.Builder.buildPrototype()
All Implemented Interfaces:
Prototype.Builder<BUILDER, PROTOTYPE>, ConfigBuilderSupport.ConfiguredBuilder<BUILDER, PROTOTYPE>
Direct Known Subclasses:
StaticContentConfig.Builder
Enclosing interface:
StaticContentConfig

public abstract static class StaticContentConfig.BuilderBase<BUILDER extends StaticContentConfig.BuilderBase<BUILDER, PROTOTYPE>, PROTOTYPE extends StaticContentConfig> extends Object implements ConfigBuilderSupport.ConfiguredBuilder<BUILDER, PROTOTYPE>
Fluent API builder base for StaticContentConfig.
  • Constructor Details

    • BuilderBase

      protected BuilderBase()
      Protected to support extensibility.
  • Method Details

    • from

      public BUILDER from(StaticContentConfig prototype)
      Update this builder from an existing prototype instance. This method disables automatic service discovery.
      Parameters:
      prototype - existing prototype to update this builder from
      Returns:
      updated builder instance
    • from

      public BUILDER from(StaticContentConfig.BuilderBase<?,?> builder)
      Update this builder from an existing prototype builder instance.
      Parameters:
      builder - existing builder prototype to update this builder from
      Returns:
      updated builder instance
    • config

      public BUILDER config(Config config)
      Update builder from configuration (node of this type). If a value is present in configuration, it would override currently configured values.
      Specified by:
      config in interface ConfigBuilderSupport.ConfiguredBuilder<BUILDER extends StaticContentConfig.BuilderBase<BUILDER, PROTOTYPE>, PROTOTYPE extends StaticContentConfig>
      Parameters:
      config - configuration instance used to obtain values to update this builder
      Returns:
      updated builder instance
    • enabled

      public BUILDER enabled(boolean enabled)
      Whether this feature is enabled, defaults to true.
      Parameters:
      enabled - whether this feature is enabled
      Returns:
      updated builder instance
      See Also:
    • weight

      public BUILDER weight(double weight)
      Weight of the static content feature. Defaults to 95.0.
      Parameters:
      weight - weight of the feature
      Returns:
      updated builder instance
      See Also:
    • name

      public BUILDER name(String name)
      Name of this instance.
      Parameters:
      name - instance name
      Returns:
      updated builder instance
      See Also:
    • clearMemoryCache

      public BUILDER clearMemoryCache()
      Clear existing value of memoryCache.
      Returns:
      updated builder instance
      See Also:
    • memoryCache

      public BUILDER memoryCache(MemoryCache memoryCache)
      Memory cache shared by the whole feature. If not configured, files are not cached in memory (except for explicitly marked files/resources in each section).
      Parameters:
      memoryCache - memory cache, if configured
      Returns:
      updated builder instance
      See Also:
    • memoryCache

      public BUILDER memoryCache(MemoryCacheConfig memoryCache)
      Memory cache shared by the whole feature. If not configured, files are not cached in memory (except for explicitly marked files/resources in each section).
      Parameters:
      memoryCache - prototype of memory cache, if configured
      Returns:
      updated builder instance
      See Also:
    • memoryCache

      public BUILDER memoryCache(Consumer<MemoryCacheConfig.Builder> consumer)
      Memory cache shared by the whole feature. If not configured, files are not cached in memory (except for explicitly marked files/resources in each section).
      Parameters:
      consumer - consumer of builder of memory cache, if configured
      Returns:
      updated builder instance
      See Also:
    • clearTemporaryStorage

      public BUILDER clearTemporaryStorage()
      Clear existing value of temporaryStorage.
      Returns:
      updated builder instance
      See Also:
    • temporaryStorage

      public BUILDER temporaryStorage(TemporaryStorage temporaryStorage)
      Temporary storage to use across all classpath handlers. If not defined, a default one will be created.
      Parameters:
      temporaryStorage - temporary storage
      Returns:
      updated builder instance
      See Also:
    • temporaryStorage

      public BUILDER temporaryStorage(TemporaryStorageConfig temporaryStorage)
      Temporary storage to use across all classpath handlers. If not defined, a default one will be created.
      Parameters:
      temporaryStorage - prototype of temporary storage
      Returns:
      updated builder instance
      See Also:
    • temporaryStorage

      public BUILDER temporaryStorage(Consumer<TemporaryStorageConfig.Builder> consumer)
      Temporary storage to use across all classpath handlers. If not defined, a default one will be created.
      Parameters:
      consumer - consumer of builder of temporary storage
      Returns:
      updated builder instance
      See Also:
    • clearClasspath

      public BUILDER clearClasspath()
      Clear all classpath.
      Returns:
      updated builder instance
      See Also:
    • classpath

      public BUILDER classpath(List<? extends ClasspathHandlerConfig> classpath)
      List of classpath based static content handlers.
      Parameters:
      classpath - classpath handlers
      Returns:
      updated builder instance
      See Also:
    • addClasspath

      public BUILDER addClasspath(List<? extends ClasspathHandlerConfig> classpath)
      List of classpath based static content handlers.
      Parameters:
      classpath - classpath handlers
      Returns:
      updated builder instance
      See Also:
    • addClasspath

      public BUILDER addClasspath(ClasspathHandlerConfig classpath)
      List of classpath based static content handlers.
      Parameters:
      classpath - add single classpath handlers
      Returns:
      updated builder instance
      See Also:
    • addClasspath

      public BUILDER addClasspath(Consumer<ClasspathHandlerConfig.Builder> consumer)
      List of classpath based static content handlers.
      Parameters:
      consumer - consumer of builder for classpath handlers
      Returns:
      updated builder instance
      See Also:
    • clearPath

      public BUILDER clearPath()
      Clear all path.
      Returns:
      updated builder instance
      See Also:
    • path

      public BUILDER path(List<? extends FileSystemHandlerConfig> path)
      List of file system based static content handlers.
      Parameters:
      path - path handlers
      Returns:
      updated builder instance
      See Also:
    • addPath

      public BUILDER addPath(List<? extends FileSystemHandlerConfig> path)
      List of file system based static content handlers.
      Parameters:
      path - path handlers
      Returns:
      updated builder instance
      See Also:
    • addPath

      public BUILDER addPath(FileSystemHandlerConfig path)
      List of file system based static content handlers.
      Parameters:
      path - add single path handlers
      Returns:
      updated builder instance
      See Also:
    • addPath

      public BUILDER addPath(Consumer<FileSystemHandlerConfig.Builder> consumer)
      List of file system based static content handlers.
      Parameters:
      consumer - consumer of builder for path handlers
      Returns:
      updated builder instance
      See Also:
    • contentTypes

      public BUILDER contentTypes(Map<String, ? extends MediaType> contentTypes)
      Maps a filename extension to the response content type. To have a system-wide configuration, you can use the service loader SPI MediaTypeDetector.

      This method can override MediaTypes detection for a specific static content handler.

      Handler will use a union of configuration defined here, and on the handler here when used from configuration. This method replaces all values with the new ones.

      Parameters:
      contentTypes - map of file extensions to associated media type
      Returns:
      updated builder instance
      See Also:
    • addContentTypes

      public BUILDER addContentTypes(Map<String, ? extends MediaType> contentTypes)
      Maps a filename extension to the response content type. To have a system-wide configuration, you can use the service loader SPI MediaTypeDetector.

      This method can override MediaTypes detection for a specific static content handler.

      Handler will use a union of configuration defined here, and on the handler here when used from configuration. This method keeps existing values, then puts all new values into the map.

      Parameters:
      contentTypes - map of file extensions to associated media type
      Returns:
      updated builder instance
      See Also:
    • putContentType

      public BUILDER putContentType(String key, MediaType contentType)
      Maps a filename extension to the response content type. To have a system-wide configuration, you can use the service loader SPI MediaTypeDetector.

      This method can override MediaTypes detection for a specific static content handler.

      Handler will use a union of configuration defined here, and on the handler here when used from configuration. This method adds a new value to the map, or replaces it if the key already exists.

      Parameters:
      key - key to add or replace
      contentType - new value for the key
      Returns:
      updated builder instance
      See Also:
    • clearWelcome

      public BUILDER clearWelcome()
      Clear existing value of welcome.
      Returns:
      updated builder instance
      See Also:
    • welcome

      public BUILDER welcome(String welcome)
      Welcome-file name. Default for all handlers. By default, we do not serve default files.
      Parameters:
      welcome - welcome-file name, such as index.html
      Returns:
      updated builder instance
      See Also:
    • clearSockets

      public BUILDER clearSockets()
      Clear all sockets.
      Returns:
      updated builder instance
      See Also:
    • sockets

      public BUILDER sockets(Set<String> sockets)
      Sockets names (listeners) that will host static content handlers, defaults to all configured sockets. Default socket name is @default.

      This configures defaults for all handlers.

      Parameters:
      sockets - sockets to register this handler on
      Returns:
      updated builder instance
      See Also:
    • addSockets

      public BUILDER addSockets(Set<String> sockets)
      Sockets names (listeners) that will host static content handlers, defaults to all configured sockets. Default socket name is @default.

      This configures defaults for all handlers.

      Parameters:
      sockets - sockets to register this handler on
      Returns:
      updated builder instance
      See Also:
    • addSocket

      public BUILDER addSocket(String socket)
      Sockets names (listeners) that will host static content handlers, defaults to all configured sockets. Default socket name is @default.

      This configures defaults for all handlers.

      Parameters:
      socket - add single sockets to register this handler on
      Returns:
      updated builder instance
      See Also:
    • preCompressedEnabled

      public BUILDER preCompressedEnabled(boolean preCompressedEnabled)
      Whether pre-compressed sidecar resources should be selected by default for feature-registered directory and classpath handlers; this is disabled by default and does not apply to file system handlers configured with a single file, which require handler-level opt-in.
      Parameters:
      preCompressedEnabled - whether pre-compressed sidecar resources should be used
      Returns:
      updated builder instance
      See Also:
    • preCompressedCrossOriginSourcingEnabled

      public BUILDER preCompressedCrossOriginSourcingEnabled(boolean preCompressedCrossOriginSourcingEnabled)
      Whether classpath sidecar resources may be sourced from a different classpath origin than the logical resource by default for feature-registered handlers.
      Parameters:
      preCompressedCrossOriginSourcingEnabled - whether cross-origin classpath sidecar sourcing is enabled by default
      Returns:
      updated builder instance
      See Also:
    • preCompressedEncodings

      public BUILDER preCompressedEncodings(Map<String,String> preCompressedEncodings)
      Pre-compressed content coding to file suffix mappings; defaults include br to br and gzip to gz, handler-level mappings replace these mappings rather than merging with them, an explicit empty map disables sidecar lookups by default, codings must be unique concrete valid HTTP tokens other than identity and *, and suffixes have leading dots ignored and must not contain path separators. This method replaces all values with the new ones.
      Parameters:
      preCompressedEncodings - content coding to file suffix mappings
      Returns:
      updated builder instance
      See Also:
    • addPreCompressedEncodings

      public BUILDER addPreCompressedEncodings(Map<String,String> preCompressedEncodings)
      Pre-compressed content coding to file suffix mappings; defaults include br to br and gzip to gz, handler-level mappings replace these mappings rather than merging with them, an explicit empty map disables sidecar lookups by default, codings must be unique concrete valid HTTP tokens other than identity and *, and suffixes have leading dots ignored and must not contain path separators. This method keeps existing values, then puts all new values into the map.
      Parameters:
      preCompressedEncodings - content coding to file suffix mappings
      Returns:
      updated builder instance
      See Also:
    • putPreCompressedEncoding

      public BUILDER putPreCompressedEncoding(String key, String preCompressedEncoding)
      Pre-compressed content coding to file suffix mappings; defaults include br to br and gzip to gz, handler-level mappings replace these mappings rather than merging with them, an explicit empty map disables sidecar lookups by default, codings must be unique concrete valid HTTP tokens other than identity and *, and suffixes have leading dots ignored and must not contain path separators. This method adds a new value to the map, or replaces it if the key already exists.
      Parameters:
      key - key to add or replace
      preCompressedEncoding - new value for the key
      Returns:
      updated builder instance
      See Also:
    • enabled

      public boolean enabled()
      Whether this feature is enabled, defaults to true.
      Returns:
      whether this feature is enabled
    • weight

      public double weight()
      Weight of the static content feature. Defaults to 95.0.
      Returns:
      weight of the feature
    • name

      public String name()
      Name of this instance.
      Returns:
      instance name
    • memoryCache

      public Optional<MemoryCache> memoryCache()
      Memory cache shared by the whole feature. If not configured, files are not cached in memory (except for explicitly marked files/resources in each section).
      Returns:
      memory cache, if configured
    • temporaryStorage

      public Optional<TemporaryStorage> temporaryStorage()
      Temporary storage to use across all classpath handlers. If not defined, a default one will be created.
      Returns:
      temporary storage
    • classpath

      public List<ClasspathHandlerConfig> classpath()
      List of classpath based static content handlers.
      Returns:
      classpath handlers
    • path

      public List<FileSystemHandlerConfig> path()
      List of file system based static content handlers.
      Returns:
      path handlers
    • contentTypes

      public Map<String, MediaType> contentTypes()
      Maps a filename extension to the response content type. To have a system-wide configuration, you can use the service loader SPI MediaTypeDetector.

      This method can override MediaTypes detection for a specific static content handler.

      Handler will use a union of configuration defined here, and on the handler here when used from configuration.

      Returns:
      map of file extensions to associated media type
    • welcome

      public Optional<String> welcome()
      Welcome-file name. Default for all handlers. By default, we do not serve default files.
      Returns:
      welcome-file name, such as index.html
    • sockets

      public Set<String> sockets()
      Sockets names (listeners) that will host static content handlers, defaults to all configured sockets. Default socket name is @default.

      This configures defaults for all handlers.

      Returns:
      sockets to register this handler on
    • preCompressedEnabled

      public boolean preCompressedEnabled()
      Whether pre-compressed sidecar resources should be selected by default for feature-registered directory and classpath handlers; this is disabled by default and does not apply to file system handlers configured with a single file, which require handler-level opt-in.
      Returns:
      whether pre-compressed sidecar resources should be used
    • preCompressedCrossOriginSourcingEnabled

      public boolean preCompressedCrossOriginSourcingEnabled()
      Whether classpath sidecar resources may be sourced from a different classpath origin than the logical resource by default for feature-registered handlers.
      Returns:
      whether cross-origin classpath sidecar sourcing is enabled by default
    • preCompressedEncodings

      public Map<String,String> preCompressedEncodings()
      Pre-compressed content coding to file suffix mappings; defaults include br to br and gzip to gz, handler-level mappings replace these mappings rather than merging with them, an explicit empty map disables sidecar lookups by default, codings must be unique concrete valid HTTP tokens other than identity and *, and suffixes have leading dots ignored and must not contain path separators.
      Returns:
      content coding to file suffix mappings
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • preBuildPrototype

      protected void preBuildPrototype()
      Handles providers and decorators.
    • validatePrototype

      protected void validatePrototype()
      Validates required properties.
    • config

      protected Optional<Config> config()
      Configuration used to configure this instance.
      Returns:
      config instance