Package org.omnifaces.resourcehandler
Class DefaultResourceHandler
- java.lang.Object
-
- jakarta.faces.application.ResourceHandler
-
- jakarta.faces.application.ResourceHandlerWrapper
-
- org.omnifaces.resourcehandler.DefaultResourceHandler
-
- All Implemented Interfaces:
FacesWrapper<ResourceHandler>
- Direct Known Subclasses:
CDNResourceHandler
,CombinedResourceHandler
,GraphicResourceHandler
,OmniVersionResourceHandler
,PWAResourceHandler
,SourceMapResourceHandler
,UnmappedResourceHandler
,VersionedResourceHandler
,ViewResourceHandler
public abstract class DefaultResourceHandler extends ResourceHandlerWrapper
A default
ResourceHandler
implementation which hooks on all threecreateResource(String)
,createResource(String, String)
andcreateResource(String, String, String)
methods. Implementors should only need to override eithergetLibraryName()
andcreateResourceFromLibrary(String, String)
, ordecorateResource(Resource)
.- Since:
- 2.0
- Author:
- Bauke Scholtz
-
-
Field Summary
Fields Modifier and Type Field Description static String
FACES_SCRIPT_RESOURCE_NAME
The Faces 4+ script resource name.static String
RES_NOT_FOUND
The default URI when a resource is not found.-
Fields inherited from class jakarta.faces.application.ResourceHandler
JSF_SCRIPT_LIBRARY_NAME, JSF_SCRIPT_RESOURCE_NAME, LOCALE_PREFIX, RESOURCE_CONTRACT_XML, RESOURCE_EXCLUDES_DEFAULT_VALUE, RESOURCE_EXCLUDES_PARAM_NAME, RESOURCE_IDENTIFIER, WEBAPP_CONTRACTS_DIRECTORY_PARAM_NAME, WEBAPP_RESOURCES_DIRECTORY_PARAM_NAME
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DefaultResourceHandler(ResourceHandler wrapped)
Creates a new instance of this default resource handler which wraps the given resource handler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Resource
createResource(String resourceName)
Delegate todecorateResource(Resource, String, String)
with result ofcreateResource(String)
from the wrapped resource handler.Resource
createResource(String resourceName, String libraryName)
If library name is not null and it equalsgetLibraryName()
, then delegate tocreateResourceFromLibrary(String, String)
withnull
as content type, else delegate todecorateResource(Resource, String, String)
with result ofcreateResource(String, String)
from the wrapped resource handler.Resource
createResource(String resourceName, String libraryName, String contentType)
If library name is not null and it equalsgetLibraryName()
, then delegate tocreateResourceFromLibrary(String, String)
, else delegate todecorateResource(Resource, String, String)
with result ofcreateResource(String, String, String)
from the wrapped resource handler.Resource
createResourceFromLibrary(String resourceName, String contentType)
Returns the library-specific resource in case a resource from specifically the library name as identified bygetLibraryName()
is requested.Resource
decorateResource(Resource resource)
Decorate the given resource.Resource
decorateResource(Resource resource, String resourceName, String libraryName)
Decorate the given resource.String
getLibraryName()
Returns the library name on which this resource handler implementation should listen.-
Methods inherited from class jakarta.faces.application.ResourceHandlerWrapper
createResourceFromId, createViewResource, getRendererTypeForResourceName, getViewResources, getViewResources, getWrapped, handleResourceRequest, isResourceRendered, isResourceRequest, isResourceURL, libraryExists, markResourceRendered
-
-
-
-
Field Detail
-
RES_NOT_FOUND
public static final String RES_NOT_FOUND
The default URI when a resource is not found.- See Also:
- Constant Field Values
-
FACES_SCRIPT_RESOURCE_NAME
public static final String FACES_SCRIPT_RESOURCE_NAME
The Faces 4+ script resource name.- Since:
- 4.0
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DefaultResourceHandler
protected DefaultResourceHandler(ResourceHandler wrapped)
Creates a new instance of this default resource handler which wraps the given resource handler.- Parameters:
wrapped
- The resource handler to be wrapped.
-
-
Method Detail
-
createResource
public Resource createResource(String resourceName)
Delegate todecorateResource(Resource, String, String)
with result ofcreateResource(String)
from the wrapped resource handler.Implementors should not override this.
- Overrides:
createResource
in classResourceHandlerWrapper
-
createResource
public Resource createResource(String resourceName, String libraryName)
If library name is not null and it equalsgetLibraryName()
, then delegate tocreateResourceFromLibrary(String, String)
withnull
as content type, else delegate todecorateResource(Resource, String, String)
with result ofcreateResource(String, String)
from the wrapped resource handler.Implementors should not override this.
- Overrides:
createResource
in classResourceHandlerWrapper
-
createResource
public Resource createResource(String resourceName, String libraryName, String contentType)
If library name is not null and it equalsgetLibraryName()
, then delegate tocreateResourceFromLibrary(String, String)
, else delegate todecorateResource(Resource, String, String)
with result ofcreateResource(String, String, String)
from the wrapped resource handler.Implementors should not override this.
- Overrides:
createResource
in classResourceHandlerWrapper
-
getLibraryName
public String getLibraryName()
Returns the library name on which this resource handler implementation should listen. If a resource from specifically this library name is requested, thencreateResourceFromLibrary(String, String)
will be called to create the resource, elsedecorateResource(Resource)
will be called with result of the call from the wrapped resource handler.The default implementation returns
null
.- Returns:
- The library name on which this resource handler implementation should listen.
-
createResourceFromLibrary
public Resource createResourceFromLibrary(String resourceName, String contentType)
Returns the library-specific resource in case a resource from specifically the library name as identified bygetLibraryName()
is requested.The default implementation returns
null
.- Parameters:
resourceName
- The resource name.contentType
- The content type.- Returns:
- The library-specific resource.
-
decorateResource
public Resource decorateResource(Resource resource, String resourceName, String libraryName)
Decorate the given resource. This will only be called if no library-specific resource has been requested.The default implementation delegates to
decorateResource(Resource)
.- Parameters:
resource
- The resource to be decorated.resourceName
- The resource name.libraryName
- The library name.- Returns:
- The decorated resource.
- Since:
- 2.6
-
decorateResource
public Resource decorateResource(Resource resource)
Decorate the given resource. This will only be called if no library-specific resource has been requested.The default implementation just returns the given resource unmodified.
- Parameters:
resource
- The resource to be decorated.- Returns:
- The decorated resource.
-
-