Package org.omnifaces.resourcehandler
Class CDNResource
- java.lang.Object
-
- jakarta.faces.application.ViewResource
-
- jakarta.faces.application.Resource
-
- jakarta.faces.application.ResourceWrapper
-
- org.omnifaces.resourcehandler.RemappedResource
-
- org.omnifaces.resourcehandler.CDNResource
-
- All Implemented Interfaces:
FacesWrapper<Resource>
,Externalizable
,Serializable
public class CDNResource extends RemappedResource
ThisResource
implementation can be used as a marker class to signal the customResourceHandler
such asCombinedResourceHandler
that the given resource actually returns a CDN URL, and offers a method to return the local URL which can be used as fallback in case the CDN request errors out.- Since:
- 2.7
- Author:
- Bauke Scholtz
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class jakarta.faces.application.Resource
COMPONENT_RESOURCE_KEY
-
-
Constructor Summary
Constructors Constructor Description CDNResource()
Do not use this constructor.CDNResource(Resource resource, String cdnURL)
Constructs a new CDN resource which remaps the given wrapped resource to the given CDN URL.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getLocalRequestPath()
Returns the local URL.String
getRequestPath()
Returns the CDN URL.-
Methods inherited from class org.omnifaces.resourcehandler.RemappedResource
equals, getContentType, getInputStream, getLibraryName, getResourceName, getResponseHeaders, getURL, getWrapped, hashCode, readExternal, setLibraryName, setResourceName, userAgentNeedsUpdate, writeExternal
-
Methods inherited from class jakarta.faces.application.ResourceWrapper
setContentType
-
-
-
-
Constructor Detail
-
CDNResource
public CDNResource()
Do not use this constructor. It's merely there forExternalizable
.
-
CDNResource
public CDNResource(Resource resource, String cdnURL)
Constructs a new CDN resource which remaps the given wrapped resource to the given CDN URL. The CDN URL is available bygetRequestPath()
. The local URL is available bygetLocalRequestPath()
.- Parameters:
resource
- The resource to be remapped.cdnURL
- The CDN URL of the resource.
-
-
Method Detail
-
getRequestPath
public String getRequestPath()
Returns the CDN URL. I.e. the remapped request path pointing a CDN host.- Overrides:
getRequestPath
in classRemappedResource
- Returns:
- The CDN URL.
-
getLocalRequestPath
public String getLocalRequestPath()
Returns the local URL. I.e. the original request path pointing the local host.- Returns:
- The local URL.
-
-