public 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 |
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 and Description |
---|
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) 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) 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) 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.
|
String |
getLibraryName()
Returns the library name on which this resource handler implementation should listen.
|
ResourceHandler |
getWrapped() |
createResourceFromId, createViewResource, getRendererTypeForResourceName, handleResourceRequest, isResourceRequest, isResourceURL, libraryExists
public static final String RES_NOT_FOUND
public DefaultResourceHandler(ResourceHandler wrapped)
wrapped
- The resource handler to be wrapped.public Resource createResource(String resourceName)
decorateResource(Resource)
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)
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)
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)
The default implementation just returns the given resource unmodified.
resource
- The resource to be decorated.public ResourceHandler getWrapped()
getWrapped
in interface FacesWrapper<ResourceHandler>
getWrapped
in class ResourceHandlerWrapper
Copyright © 2012–2016 OmniFaces. All rights reserved.