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
A default ResourceHandler implementation which hooks on all three createResource(String),
createResource(String, String) and createResource(String, String, String) methods. Implementors
should only need to override either getLibraryName() and
createResourceFromLibrary(String, String), or decorateResource(Resource).
- Since:
- 2.0
- Author:
- Bauke Scholtz
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default URI when a resource is not found.Fields inherited from class jakarta.faces.application.ResourceHandler
FACES_SCRIPT_LIBRARY_NAME, FACES_SCRIPT_RESOURCE_NAME, 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
ConstructorsModifierConstructorDescriptionprotectedDefaultResourceHandler(ResourceHandler wrapped) Creates a new instance of this default resource handler which wraps the given resource handler. -
Method Summary
Modifier and TypeMethodDescriptioncreateResource(String resourceName) Delegate todecorateResource(Resource, String, String)with result ofcreateResource(String)from the wrapped resource handler.createResource(String resourceName, String libraryName) If library name is not null and it equalsgetLibraryName(), then delegate tocreateResourceFromLibrary(String, String)withnullas content type, else delegate todecorateResource(Resource, String, String)with result ofcreateResource(String, String)from the wrapped resource handler.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.createResourceFromLibrary(String resourceName, String contentType) Returns the library-specific resource in case a resource from specifically the library name as identified bygetLibraryName()is requested.decorateResource(Resource resource) Decorate the given resource.decorateResource(Resource resource, String resourceName, String libraryName) Decorate the given resource.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 Details
-
RES_NOT_FOUND
The default URI when a resource is not found.- See Also:
-
-
Constructor Details
-
DefaultResourceHandler
Creates a new instance of this default resource handler which wraps the given resource handler.- Parameters:
wrapped- The resource handler to be wrapped.
-
-
Method Details
-
createResource
Delegate todecorateResource(Resource, String, String)with result ofcreateResource(String)from the wrapped resource handler.Implementors should not override this.
- Overrides:
createResourcein classResourceHandlerWrapper
-
createResource
If library name is not null and it equalsgetLibraryName(), then delegate tocreateResourceFromLibrary(String, String)withnullas content type, else delegate todecorateResource(Resource, String, String)with result ofcreateResource(String, String)from the wrapped resource handler.Implementors should not override this.
- Overrides:
createResourcein classResourceHandlerWrapper
-
createResource
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:
createResourcein classResourceHandlerWrapper
-
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
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
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
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.
-