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) boolean
libraryExists
(String libraryName) boolean
resourceExists
(ResourceMeta resourceMeta) void
void
setVersionComparator
(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:
getResourceInputStream
in 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:
getResourceVersion
in classResourceLoaderWrapper
-
getLibraryVersion
Description copied from class:ResourceLoader
Return the max available version found (if exists) or return null if no version available.- Overrides:
getLibraryVersion
in classResourceLoaderWrapper
-
getResourceURL
Description copied from class:ResourceLoader
Return the max available version found (if exists) or return null if no version available.- Overrides:
getResourceURL
in classResourceLoaderWrapper
-
createResourceMeta
public ResourceMeta createResourceMeta(String prefix, String libraryName, String libraryVersion, String resourceName, String resourceVersion) - Overrides:
createResourceMeta
in classResourceLoaderWrapper
-
createResourceMeta
public ResourceMeta createResourceMeta(String prefix, String libraryName, String libraryVersion, String resourceName, String resourceVersion, String contractName) - Overrides:
createResourceMeta
in classResourceLoader
-
libraryExists
- Overrides:
libraryExists
in classResourceLoaderWrapper
-
resourceExists
- Overrides:
resourceExists
in classResourceLoaderWrapper
-
iterator
public Iterator<String> iterator(FacesContext facesContext, String path, int maxDepth, ResourceVisitOption... options) - Overrides:
iterator
in classResourceLoaderWrapper
-
getVersionComparator
- Overrides:
getVersionComparator
in classResourceLoaderWrapper
-
setVersionComparator
- Overrides:
setVersionComparator
in classResourceLoaderWrapper
-
getPrefix
- Overrides:
getPrefix
in classResourceLoaderWrapper
-
setPrefix
- Overrides:
setPrefix
in classResourceLoaderWrapper
-