Class AssetSources

java.lang.Object
ru.vyarus.guicey.gsp.app.asset.AssetSources

public class AssetSources extends Object
Application classpath resources configuration object. Assets may be merged from multiple classpath locations. Moreover, classpath locations could be mapped to exact urls.

If assets available only through custom class loader then it must be specified, otherwise application class loader would be used (and, most likely, will not find required resources).

Since:
28.11.2019
  • Field Details

    • DEFAULT_LOADER

      public static final ClassLoader DEFAULT_LOADER
      Default class loader used for assets loading.
  • Constructor Details

    • AssetSources

      public AssetSources()
  • Method Details

    • attach

      public void attach(String location)
      Register one root asset location.
      Parameters:
      location - asset classpath location
    • attach

      public void attach(String url, String location)
      Register location for exact url path (path-mapped locations override root mappings too).

      Internally, path used without first slash to simplify matching. Location could be declared as pure package ('dot' separated path).

      Parameters:
      url - sub url
      location - asset classpath location
    • attach

      public void attach(String location, ClassLoader loader)
      Same as attach(String) but with custom class loader to use for assets loading.

      WARNING: only freemarker could see templates from this loader and only if support activated ServerPagesBundle.ViewsBuilder.enableFreemarkerCustomClassLoadersSupport()

      Parameters:
      location - asset classpath location
      loader - class loader to use for assets loading (may be null to use default)
    • attach

      public void attach(String url, String location, ClassLoader loader)
      Same as attach(String, String) but with custom class loader to use for assets loading.

      WARNING: only freemarker could see templates from this loader and only if support activated ServerPagesBundle.ViewsBuilder.enableFreemarkerCustomClassLoadersSupport()

      Parameters:
      url - sub url
      location - assets classpath location
      loader - class loader to use for assets loading (may be null to use default)
    • getLocations

      public com.google.common.collect.Multimap<String,String> getLocations()
      Returns:
      configured assets classpath locations by url
    • getLoaders

      public com.google.common.collect.Multimap<String,ClassLoader> getLoaders()
      NOTE: default loader (DEFAULT_LOADER) will be registered for each package. No duplicates are possible.
      Returns:
      configured class loaders for packages
    • merge

      public void merge(AssetSources assets)
      Merge assets configurations (in-app config with global extensions).
      Parameters:
      assets - other assets configuration