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>
public class FacesJSResourceLoader extends ResourceLoaderWrapper
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
Fields Modifier and Type Field Description static String
SOURCE_MAP_MARKER
-
Fields inherited from class org.apache.myfaces.resource.ResourceLoader
VERSION_INVALID
-
-
Constructor Summary
Constructors Constructor Description FacesJSResourceLoader(ResourceLoader delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResourceMeta
createResourceMeta(String prefix, String libraryName, String libraryVersion, String resourceName, String resourceVersion)
ResourceMeta
createResourceMeta(String prefix, String libraryName, String libraryVersion, String resourceName, String resourceVersion, String contractName)
String
getLibraryVersion(String path)
Return the max available version found (if exists) or return null if no version available.String
getPrefix()
InputStream
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 flyURL
getResourceURL(ResourceMeta resourceMeta)
Return the max available version found (if exists) or return null if no version available.String
getResourceVersion(String path)
Comparator<String>
getVersionComparator()
ResourceLoader
getWrapped()
Iterator<String>
iterator(FacesContext facesContext, String path, int maxDepth, ResourceVisitOption... options)
boolean
libraryExists(String libraryName)
boolean
resourceExists(ResourceMeta resourceMeta)
void
setPrefix(String prefix)
void
setVersionComparator(Comparator<String> versionComparator)
-
-
-
Field Detail
-
SOURCE_MAP_MARKER
public static final String SOURCE_MAP_MARKER
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FacesJSResourceLoader
public FacesJSResourceLoader(ResourceLoader delegate)
-
-
Method Detail
-
getWrapped
public ResourceLoader getWrapped()
-
getResourceInputStream
public InputStream 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 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
public String getResourceVersion(String path)
- Overrides:
getResourceVersion
in classResourceLoaderWrapper
-
getLibraryVersion
public String getLibraryVersion(String path)
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
public URL getResourceURL(ResourceMeta resourceMeta)
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
public boolean libraryExists(String libraryName)
- Overrides:
libraryExists
in classResourceLoaderWrapper
-
resourceExists
public boolean resourceExists(ResourceMeta resourceMeta)
- Overrides:
resourceExists
in classResourceLoaderWrapper
-
iterator
public Iterator<String> iterator(FacesContext facesContext, String path, int maxDepth, ResourceVisitOption... options)
- Overrides:
iterator
in classResourceLoaderWrapper
-
getVersionComparator
public Comparator<String> getVersionComparator()
- Overrides:
getVersionComparator
in classResourceLoaderWrapper
-
setVersionComparator
public void setVersionComparator(Comparator<String> versionComparator)
- Overrides:
setVersionComparator
in classResourceLoaderWrapper
-
getPrefix
public String getPrefix()
- Overrides:
getPrefix
in classResourceLoaderWrapper
-
setPrefix
public void setPrefix(String prefix)
- Overrides:
setPrefix
in classResourceLoaderWrapper
-
-