org.norther.tammi.spray.media
Class AbstractMediaContentFilter

java.lang.Object
  extended by org.norther.tammi.core.base.Adaptee
      extended by org.norther.tammi.core.base.DefaultContainer
          extended by org.norther.tammi.spray.filter.AbstractContainerFilter
              extended by org.norther.tammi.spray.media.AbstractMediaContentFilter
All Implemented Interfaces:
Serializable, NotificationBroadcaster, NotificationEmitter, Filter, Container, Manageable, MBeanDelegate, ContainerFilter, TerminationFilter, MediaContentFilter
Direct Known Subclasses:
AbstractMediaContentKeyFilter, DefaultMediaContentFilter

public abstract class AbstractMediaContentFilter
extends AbstractContainerFilter
implements MediaContentFilter

An abstract implementation of MediaContentFilter.

Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.norther.tammi.core.base.Adaptee
ADAPTEE_NOTIF_DESCRIPTION, ADAPTEE_NOTIFICATIONS
 
Fields inherited from interface org.norther.tammi.core.base.MBeanDelegate
ARRAY_TYPE, OBJECT_TYPE, PRIMITIVE_TYPE, STRING_TYPE
 
Constructor Summary
AbstractMediaContentFilter()
          Contructs a new filter.
 
Method Summary
 void clearFixedPaths()
          Clears all fixed content paths.
 void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
           
 Set fixedKeySet()
          Returns a read-only set of fixed path keys.
protected  String getContentPath(ServletRequest request, ServletResponse response, FilterChain chain)
          Gets the path info as the content path without the service key and value, if any.
protected  String getFixedPath(ServletRequest request, ServletResponse response, FilterChain chain)
          Gets the fixed path mapped to the path info as the content path.
 String getFixedPath(String key)
          Gets a fixed content path.
protected  Resource getResource(String type, String path, boolean cached, ServletRequest request, ServletResponse response, FilterChain chain)
          Gets the resource.
protected  MediaProvider getResourceProvider(String type)
          Gets the type specific provider.
 void removeFixedPath(String key)
          Removes a fixed content path.
 void setFixedPath(String key, String path)
          Sets a fixed content path.
 
Methods inherited from class org.norther.tammi.spray.filter.AbstractContainerFilter
destroy, getFilter, getFilterConfig, getRequestMap, getSessionMap, init
 
Methods inherited from class org.norther.tammi.core.base.DefaultContainer
clear, containsKey, get, getContainerKey, getContainerKey, getContainerKey, getMBean, getMBeanHandle, getMBeanHandles, getMBeanInterface, getMBeanInterface, getObjectName, getObjectNames, getQueryPattern, registryKeySet, registryKeySet, registryKeySet, registryKeySet, registryMap, registrySize, remove, setMBeanInterface, setQueryPattern, setQueryPattern
 
Methods inherited from class org.norther.tammi.core.base.Adaptee
addAdaptee, addNotificationListener, getAttributeSupport, getBroker, getCanonicalName, getDomain, getFactory, getLoader, getLog, getLog, getMBean, getMBeanServer, getNotificationInfo, getObjectName, getRegistrationTime, getSequenceNumber, hasListeners, isRegistered, postmanaged, premanaged, removeNotificationListener, removeNotificationListener, sendNotification, sendNotification, sendNotification, sendNotification, unmanaged, unregister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.norther.tammi.core.base.Container
clear, containsKey, get, getContainerKey, getContainerKey, getContainerKey, getMBean, getMBeanInterface, getMBeanInterface, getObjectName, getObjectNames, getQueryPattern, registryKeySet, registryKeySet, registryKeySet, registryKeySet, registryMap, registrySize, remove, setMBeanInterface, setQueryPattern, setQueryPattern
 
Methods inherited from interface javax.servlet.Filter
destroy, init
 
Methods inherited from interface javax.servlet.Filter
destroy, init
 

Constructor Detail

AbstractMediaContentFilter

public AbstractMediaContentFilter()
Contructs a new filter.

Method Detail

getFixedPath

public String getFixedPath(String key)
Description copied from interface: MediaContentFilter
Gets a fixed content path.

Specified by:
getFixedPath in interface MediaContentFilter
Parameters:
key - the path key.
Returns:
a fixed content path.

setFixedPath

public void setFixedPath(String key,
                         String path)
Description copied from interface: MediaContentFilter
Sets a fixed content path.

Specified by:
setFixedPath in interface MediaContentFilter
Parameters:
key - the path key.
path - a fixed content path.

removeFixedPath

public void removeFixedPath(String key)
Description copied from interface: MediaContentFilter
Removes a fixed content path.

Specified by:
removeFixedPath in interface MediaContentFilter
Parameters:
key - the path key.

clearFixedPaths

public void clearFixedPaths()
Description copied from interface: MediaContentFilter
Clears all fixed content paths.

Specified by:
clearFixedPaths in interface MediaContentFilter

fixedKeySet

public Set fixedKeySet()
Description copied from interface: MediaContentFilter
Returns a read-only set of fixed path keys.

Specified by:
fixedKeySet in interface MediaContentFilter
Returns:
a set of fixed keys.

doFilter

public void doFilter(ServletRequest request,
                     ServletResponse response,
                     FilterChain chain)
              throws ServletException,
                     IOException
Specified by:
doFilter in interface Filter
Overrides:
doFilter in class AbstractContainerFilter
Throws:
ServletException
IOException

getResourceProvider

protected MediaProvider getResourceProvider(String type)
Gets the type specific provider.

Parameters:
type - the Mime type.
Returns:
the provider or null.
Throws:
NullPointerException - if type is null.

getResource

protected Resource getResource(String type,
                               String path,
                               boolean cached,
                               ServletRequest request,
                               ServletResponse response,
                               FilterChain chain)
                        throws IOException,
                               ConstructionException,
                               AccessDeniedException
Gets the resource.

Parameters:
type - the content type.
path - the resource path.
cached - true if caching is enabled, false otherwise.
request - the request.
response - the response.
chain - the filter chain.
Returns:
the resource source.
Throws:
IOException - on I/O errors.
ConstructionException - on resource errors.
AccessDeniedException - for access restrictions.

getContentPath

protected String getContentPath(ServletRequest request,
                                ServletResponse response,
                                FilterChain chain)
Gets the path info as the content path without the service key and value, if any. Checks also any defined fixed paths. Returns an empty path if the path info is missing.

Parameters:
request - the request.
response - the response.
chain - the filter chain.
Returns:
the content path or an empty path.

getFixedPath

protected String getFixedPath(ServletRequest request,
                              ServletResponse response,
                              FilterChain chain)
Gets the fixed path mapped to the path info as the content path.

Parameters:
request - the request.
response - the response.
chain - the filter chain.
Returns:
the fixed path or null.


Copyright © 2004 The Norther Organization. All rights reserved.