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

java.lang.Object
io.helidon.webserver.staticcontent.BaseHandlerConfig.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:
BaseHandlerConfig.Builder, ClasspathHandlerConfig.BuilderBase, FileSystemHandlerConfig.BuilderBase
Enclosing interface:
BaseHandlerConfig

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

    • BuilderBase

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

    • from

      public BUILDER from(BaseHandlerConfig 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(BaseHandlerConfig.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 BaseHandlerConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends BaseHandlerConfig>
      Parameters:
      config - configuration instance used to obtain values to update this builder
      Returns:
      updated builder instance
    • enabled

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

      public BUILDER context(String context)
      Context that will serve this handler's static resources, defaults to /.
      Parameters:
      context - context under webserver
      Returns:
      updated builder instance
      See Also:
    • sockets

      public BUILDER sockets(Set<String> sockets)
      Sockets names (listeners) that will host this static content handler, defaults to all configured sockets. Default socket name is @default.
      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 this static content handler, defaults to all configured sockets. Default socket name is @default.
      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 this static content handler, defaults to all configured sockets. Default socket name is @default.
      Parameters:
      socket - sockets to register this handler on
      Returns:
      updated builder instance
      See Also:
    • clearWelcome

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

      public BUILDER welcome(String welcome)
      Welcome-file name. In case a directory is requested, this file would be served if present. There is no welcome file by default.
      Parameters:
      welcome - welcome-file name, such as index.html
      Returns:
      updated builder instance
      See Also:
    • cachedFiles

      public BUILDER cachedFiles(Set<String> 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 will never be re-loaded, even if changed, until server restart!

      Parameters:
      cachedFiles - set of file names (or directory names if not using classpath) to cache in memory on startup
      Returns:
      updated builder instance
      See Also:
    • addCachedFiles

      public BUILDER addCachedFiles(Set<String> 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 will never be re-loaded, even if changed, until server restart!

      Parameters:
      cachedFiles - set of file names (or directory names if not using classpath) to cache in memory on startup
      Returns:
      updated builder instance
      See Also:
    • addCachedFile

      public BUILDER addCachedFile(String cachedFile)
      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 will never be re-loaded, even if changed, until server restart!

      Parameters:
      cachedFile - set of file names (or directory names if not using classpath) to cache in memory on startup
      Returns:
      updated builder instance
      See Also:
    • clearMemoryCache

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

      public BUILDER memoryCache(MemoryCache memoryCache)
      Handles will use memory cache configured on StaticContentConfigBlueprint.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.

      Parameters:
      memoryCache - memory cache to use with this handler
      Returns:
      updated builder instance
      See Also:
    • memoryCache

      public BUILDER memoryCache(MemoryCacheConfig memoryCacheConfig)
      Handles will use memory cache configured on StaticContentConfigBlueprint.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.

      Parameters:
      memoryCacheConfig - memory cache to use with this handler
      Returns:
      updated builder instance
      See Also:
    • memoryCache

      public BUILDER memoryCache(Consumer<MemoryCacheConfig.Builder> consumer)
      Handles will use memory cache configured on StaticContentConfigBlueprint.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.

      Parameters:
      consumer - memory cache to use with this handler
      Returns:
      updated builder instance
      See Also:
    • contentTypes

      public BUILDER contentTypes(Map<String,? extends MediaType> contentTypes)
      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)
      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)
      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:
    • pathMapper

      public BUILDER pathMapper(Function<String,String> pathMapper)
      Map request path to resource path. Default uses the same path as requested. This can be used to resolve all paths to a single file, or to filter out files.
      Parameters:
      pathMapper - function to map request path to resource path
      Returns:
      updated builder instance
      See Also:
    • clearRecordCacheCapacity

      public BUILDER clearRecordCacheCapacity()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • recordCacheCapacity

      public BUILDER recordCacheCapacity(int recordCacheCapacity)
      Configure capacity of cache used for resources. This cache will make sure the media type and location is discovered faster.

      To cache content (bytes) in memory, use BaseHandlerConfigBlueprint.memoryCache()

      Parameters:
      recordCacheCapacity - maximal number of cached records, only caches media type and Path, not the content
      Returns:
      updated builder instance
      See Also:
    • enabled

      public boolean enabled()
      Whether this handle is enabled, defaults to true.
      Returns:
      the enabled
    • context

      public String context()
      Context that will serve this handler's static resources, defaults to /.
      Returns:
      the context
    • sockets

      public Set<String> sockets()
      Sockets names (listeners) that will host this static content handler, defaults to all configured sockets. Default socket name is @default.
      Returns:
      the sockets
    • welcome

      public Optional<String> welcome()
      Welcome-file name. In case a directory is requested, this file would be served if present. There is no welcome file by default.
      Returns:
      the welcome
    • cachedFiles

      public Set<String> 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 will never be re-loaded, even if changed, until server restart!

      Returns:
      the cached files
    • memoryCache

      public Optional<MemoryCache> memoryCache()
      Handles will use memory cache configured on StaticContentConfigBlueprint.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:
      the memory cache
    • 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 on the StaticContentConfig and here when used from configuration.

      Returns:
      the content types
    • pathMapper

      public Function<String,String> pathMapper()
      Map request path to resource path. Default uses the same path as requested. This can be used to resolve all paths to a single file, or to filter out files.
      Returns:
      the path mapper
    • recordCacheCapacity

      public Optional<Integer> recordCacheCapacity()
      Configure capacity of cache used for resources. This cache will make sure the media type and location is discovered faster.

      To cache content (bytes) in memory, use BaseHandlerConfigBlueprint.memoryCache()

      Returns:
      the record cache capacity
    • config

      public Optional<Config> config()
      If this instance was configured, this would be the config instance used.
      Returns:
      config node used to configure this builder, or empty if not configured
    • toString

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

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

      protected void validatePrototype()
      Validates required properties.