public abstract class DefaultResourceHandler extends ResourceHandlerWrapper
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)
.
Modifier and Type | Field and Description |
---|---|
static String |
RES_NOT_FOUND |
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
Modifier | Constructor and Description |
---|---|
protected |
DefaultResourceHandler(ResourceHandler wrapped)
Creates a new instance of this default resource handler which wraps the given resource handler.
|
Modifier and Type | Method and Description |
---|---|
Resource |
createResource(String resourceName)
Delegate to
decorateResource(Resource, String, String) with result of createResource(String)
from the wrapped resource handler. |
Resource |
createResource(String resourceName,
String libraryName)
If library name is not null and it equals
getLibraryName() , then delegate to
createResourceFromLibrary(String, String) with null as content type, else delegate to
decorateResource(Resource, String, String) with result of createResource(String, String)
from the wrapped resource handler. |
Resource |
createResource(String resourceName,
String libraryName,
String contentType)
If library name is not null and it equals
getLibraryName() , then delegate to
createResourceFromLibrary(String, String) , else delegate to
decorateResource(Resource, String, String) with result of
createResource(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 by
getLibraryName() 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.
|
createResourceFromId, createViewResource, getRendererTypeForResourceName, getViewResources, getViewResources, getWrapped, handleResourceRequest, isResourceRendered, isResourceRequest, isResourceURL, libraryExists, markResourceRendered
public static final String RES_NOT_FOUND
protected DefaultResourceHandler(ResourceHandler wrapped)
wrapped
- The resource handler to be wrapped.public Resource createResource(String resourceName)
decorateResource(Resource, String, String)
with result of createResource(String)
from the wrapped resource handler.
Implementors should not override this.
createResource
in class ResourceHandlerWrapper
public Resource createResource(String resourceName, String libraryName)
getLibraryName()
, then delegate to
createResourceFromLibrary(String, String)
with null
as content type, else delegate to
decorateResource(Resource, String, String)
with result of createResource(String, String)
from the wrapped resource handler.
Implementors should not override this.
createResource
in class ResourceHandlerWrapper
public Resource createResource(String resourceName, String libraryName, String contentType)
getLibraryName()
, then delegate to
createResourceFromLibrary(String, String)
, else delegate to
decorateResource(Resource, String, String)
with result of
createResource(String, String, String)
from the wrapped resource handler.
Implementors should not override this.
createResource
in class ResourceHandlerWrapper
public String getLibraryName()
createResourceFromLibrary(String, String)
will be
called to create the resource, else decorateResource(Resource)
will be called with result of the call
from the wrapped resource handler.
The default implementation returns null
.
public Resource createResourceFromLibrary(String resourceName, String contentType)
getLibraryName()
is requested.
The default implementation returns null
.
resourceName
- The resource name.contentType
- The content type.public Resource decorateResource(Resource resource, String resourceName, String libraryName)
The default implementation delegates to decorateResource(Resource)
.
resource
- The resource to be decorated.resourceName
- The resource name.libraryName
- The library name.public Resource decorateResource(Resource resource)
The default implementation just returns the given resource unmodified.
resource
- The resource to be decorated.Copyright © 2012–2021 OmniFaces. All rights reserved.