Package org.apache.myfaces.resource
Class FacesJSResourceLoader
java.lang.Object
org.apache.myfaces.resource.ResourceLoader
org.apache.myfaces.resource.ResourceLoaderWrapper
org.apache.myfaces.resource.FacesJSResourceLoader
- All Implemented Interfaces:
FacesWrapper<ResourceLoader>
Resource loader coming in from our jakarta.faces library
The problem why we need a specialized loader is:
we have to append/change the mapping information in Development mode
(and remove it if present for prod mode)
according to the library name and request path
Both values are dynamic and the request path is dependent on the
patterns provided in the web.xml
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.myfaces.resource.ResourceLoader
ResourceLoader.VersionComparator -
Field Summary
FieldsFields inherited from class org.apache.myfaces.resource.ResourceLoader
VERSION_INVALID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateResourceMeta(String prefix, String libraryName, String libraryVersion, String resourceName, String resourceVersion) createResourceMeta(String prefix, String libraryName, String libraryVersion, String resourceName, String resourceVersion, String contractName) getLibraryVersion(String path) Return the max available version found (if exists) or return null if no version available.getResourceInputStream(ResourceMeta resourceMeta) this is the central part, we basically intercept the input stream via an internal pipe and change and add the information on the flygetResourceURL(ResourceMeta resourceMeta) Return the max available version found (if exists) or return null if no version available.getResourceVersion(String path) iterator(FacesContext facesContext, String path, int maxDepth, ResourceVisitOption... options) booleanlibraryExists(String libraryName) booleanresourceExists(ResourceMeta resourceMeta) voidvoidsetVersionComparator(Comparator<String> versionComparator)
-
Field Details
-
SOURCE_MAP_MARKER
- See Also:
-
-
Constructor Details
-
FacesJSResourceLoader
-
-
Method Details
-
getWrapped
-
getResourceInputStream
this is the central part, we basically intercept the input stream via an internal pipe and change and add the information on the fly What happens is that a request is coming in which tries to load a faces.js file. In development mode faces-development.js is loaded transparently. In production mode faces.js is loaded. Also, the request, in case of an extension based match, does not load the resource via the .js extension but via js.<match extension≫ aka faces.js becomes faces.js.jsf now this extension is dependent on the current match of the request triggering the Faces Servlet. In order to load the mapping files correctly we have to take this into consideration by adding in case of an extension match the match extensions. Also given that we only want to have mapping files in development mode we have to retarget the mapping file to faces-development.js.map no matter how the faces.js request looks like. For production mode we do not want to have any mapping request at all (for now)- Overrides:
getResourceInputStreamin classResourceLoaderWrapper- Parameters:
resourceMeta- the incoming resource metadata for the faces.js resource- Returns:
- an input stream on the resource or the mapped input stream which adds the map data
-
getResourceVersion
- Overrides:
getResourceVersionin classResourceLoaderWrapper
-
getLibraryVersion
Description copied from class:ResourceLoaderReturn the max available version found (if exists) or return null if no version available.- Overrides:
getLibraryVersionin classResourceLoaderWrapper
-
getResourceURL
Description copied from class:ResourceLoaderReturn the max available version found (if exists) or return null if no version available.- Overrides:
getResourceURLin classResourceLoaderWrapper
-
createResourceMeta
public ResourceMeta createResourceMeta(String prefix, String libraryName, String libraryVersion, String resourceName, String resourceVersion) - Overrides:
createResourceMetain classResourceLoaderWrapper
-
createResourceMeta
public ResourceMeta createResourceMeta(String prefix, String libraryName, String libraryVersion, String resourceName, String resourceVersion, String contractName) - Overrides:
createResourceMetain classResourceLoader
-
libraryExists
- Overrides:
libraryExistsin classResourceLoaderWrapper
-
resourceExists
- Overrides:
resourceExistsin classResourceLoaderWrapper
-
iterator
public Iterator<String> iterator(FacesContext facesContext, String path, int maxDepth, ResourceVisitOption... options) - Overrides:
iteratorin classResourceLoaderWrapper
-
getVersionComparator
- Overrides:
getVersionComparatorin classResourceLoaderWrapper
-
setVersionComparator
- Overrides:
setVersionComparatorin classResourceLoaderWrapper
-
getPrefix
- Overrides:
getPrefixin classResourceLoaderWrapper
-
setPrefix
- Overrides:
setPrefixin classResourceLoaderWrapper
-