Class AssetSourceImpl

    • Method Detail

      • getClasspathAsset

        public Asset getClasspathAsset​(java.lang.String path,
                                       java.util.Locale locale)
        Description copied from interface: AssetSource
        Convenience for finding assets on the classpath.
        Specified by:
        getClasspathAsset in interface AssetSource
        Parameters:
        path - path to the base resource, relative to classpath root
        locale - to localize the resource to
        Returns:
        the asset
      • getContextAsset

        public Asset getContextAsset​(java.lang.String path,
                                     java.util.Locale locale)
        Description copied from interface: AssetSource
        Convenience for finding assets in the context.
        Specified by:
        getContextAsset in interface AssetSource
        Parameters:
        path - path relative to the base resource (the context root)
        locale - to localize the resource to, or null for the locale for the current request
        Returns:
        the asset
      • getAsset

        public Asset getAsset​(Resource baseResource,
                              java.lang.String path,
                              java.util.Locale locale)
        Description copied from interface: AssetSource
        Finds the asset. The path may either be a simple file name or a relative path (relative to the base resource) or it may have a prefix, such as "context:" or "classpath:", in which case it is treated as a complete path within the indicated domain. The resulting Resource is then localized (to the provided Locale) and returned as an Asset. The AssetSource caches its results, so a single Asset instance may be shared among many different components.
        Specified by:
        getAsset in interface AssetSource
        Parameters:
        baseResource - base resource for computing relative paths, or null to search the classpath
        path - relative to the base resource
        locale - locale to localize the final resource to, or null for the thread's current locale
        Returns:
        the asset
      • resourceForPath

        public Resource resourceForPath​(java.lang.String path)
        Description copied from interface: AssetSource
        Finds the asset, either on the classpath or (if prefixed), within the indicated domain. The result is not localized. The underlying Asset may not exist.
        Specified by:
        resourceForPath in interface AssetSource
        Parameters:
        path - to the resource to provide as an Asset
        Returns:
        Resource for the path (the Resource may not exist)
      • getComponentAsset

        public Asset getComponentAsset​(ComponentResources resources,
                                       java.lang.String path,
                                       java.lang.String libraryName)
        Description copied from interface: AssetSource
        Gets an asset that is used with, or injected into, a component, that will be exposed to the client. This encapsulates the new, in 5.4, standard that assets should all be stored in (sub-folders of) META-INF/assets/library-name/. This is the preferred location in 5.4, with compatibility for 5.3 that allows assets to be stored on the classpath alongside Java classes and server-only resources such as templates and message catalogs. When resolving a resource in a component that is subclass, the point of injection is the class which contains the injecting annotation (e.g., Inject with Path, or Import). In other words, the library name for the library containing the class, rather than the library name of the instantiated subclass (which can be different).
        Specified by:
        getComponentAsset in interface AssetSource
        Parameters:
        resources - resources, used to identify starting location of asset (if path does not include a asset prefix).
        path - path to the resource; either fully qualified (with an asset prefix such as "context:"), or relative to the component's library asset folder (the 5.4 and beyond way), or the to the component's Java class file (the 5.3 and earlier way, still supported until at least 5.5). Symbols in the path are expanded.
        libraryName - The name of the library containing the component, as per ComponentModel.getLibraryName(). For a subclass, the libraryName must reflect the name of the library for the parent class that forms the basis of injection.
        Returns:
        the Asset