- 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 ResourceHandlerimplementation 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 SummaryFields Modifier and Type Field Description static StringFACES_SCRIPT_RESOURCE_NAMEThe Faces 4+ script resource name.static StringRES_NOT_FOUNDThe default URI when a resource is not found.- 
Fields inherited from class jakarta.faces.application.ResourceHandlerJSF_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 SummaryConstructors Modifier Constructor Description protectedDefaultResourceHandler(ResourceHandler wrapped)Creates a new instance of this default resource handler which wraps the given resource handler.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description ResourcecreateResource(String resourceName)Delegate todecorateResource(Resource, String, String)with result ofcreateResource(String)from the wrapped resource handler.ResourcecreateResource(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.ResourcecreateResource(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.ResourcecreateResourceFromLibrary(String resourceName, String contentType)Returns the library-specific resource in case a resource from specifically the library name as identified bygetLibraryName()is requested.ResourcedecorateResource(Resource resource)Decorate the given resource.ResourcedecorateResource(Resource resource, String resourceName, String libraryName)Decorate the given resource.StringgetLibraryName()Returns the library name on which this resource handler implementation should listen.- 
Methods inherited from class jakarta.faces.application.ResourceHandlerWrappercreateResourceFromId, createViewResource, getRendererTypeForResourceName, getViewResources, getViewResources, getWrapped, handleResourceRequest, isResourceRendered, isResourceRequest, isResourceURL, libraryExists, markResourceRendered
 
- 
 
- 
- 
- 
Field Detail- 
RES_NOT_FOUNDpublic static final String RES_NOT_FOUND The default URI when a resource is not found.- See Also:
- Constant Field Values
 
 - 
FACES_SCRIPT_RESOURCE_NAMEpublic static final String FACES_SCRIPT_RESOURCE_NAME The Faces 4+ script resource name.- Since:
- 4.0
- See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
DefaultResourceHandlerprotected 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- 
createResourcepublic Resource createResource(String resourceName) Delegate todecorateResource(Resource, String, String)with result ofcreateResource(String)from the wrapped resource handler.Implementors should not override this. - Overrides:
- createResourcein class- ResourceHandlerWrapper
 
 - 
createResourcepublic Resource 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.Implementors should not override this. - Overrides:
- createResourcein class- ResourceHandlerWrapper
 
 - 
createResourcepublic 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:
- createResourcein class- ResourceHandlerWrapper
 
 - 
getLibraryNamepublic 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.
 
 - 
createResourceFromLibrarypublic 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.
 
 - 
decorateResourcepublic 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
 
 - 
decorateResourcepublic 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.
 
 
- 
 
-