org.norther.tammi.spray.media
Class DefaultMediaContentFilter<M extends MediaProvider>

java.lang.Object
  extended by org.norther.tammi.core.base.Adaptee
      extended by org.norther.tammi.core.base.DefaultContainer<V>
          extended by org.norther.tammi.spray.filter.DefaultContainerFilter<M>
              extended by org.norther.tammi.spray.media.DefaultMediaContentFilter<M>
Type Parameters:
M - the registered provider type.
All Implemented Interfaces:
Serializable, NotificationBroadcaster, NotificationEmitter, Filter, Container<M>, Manageable, MBeanDelegate, ContainerFilter<M>, TerminationFilter, ContentFilter, MediaContentFilter<M>
Direct Known Subclasses:
AbstractMediaContentKeyFilter

public class DefaultMediaContentFilter<M extends MediaProvider>
extends DefaultContainerFilter<M>
implements MediaContentFilter<M>

A default implementation of MediaContentFilter.

Version:
$Id: DefaultMediaContentFilter.java,v 1.11 2009/09/28 15:08:26 cvsimp Exp $
Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.norther.tammi.core.base.Adaptee
ADAPTEE_NOTIF_DESCRIPTION, ADAPTEE_NOTIFICATIONS
 
Constructor Summary
  DefaultMediaContentFilter()
          Contructs a new filter.
protected DefaultMediaContentFilter(ContentFilter filter)
          Contructs a new filter.
 
Method Summary
 void clearFixedPaths()
          Clears all fixed content paths.
 void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
           
 Set<String> fixedKeySet()
          Returns a read-only set of fixed path keys.
 String getContentPath(boolean unparsed, ServletRequest request, ServletResponse response, FilterChain chain)
          Gets the optionally unparsed path info as the content path without any parsed keys and values, if any.
protected  ContentFilter getFilter()
          Gets the content filter adaptee.
 String getFixedPath(String key)
          Gets a fixed content path.
 int getMaxAge()
          Gets the max caching age of content i clients.
protected  MediaProvider getMediaProvider(MimeType mime)
          Gets the type specific provider.
protected  Resource<?> getResource(MimeType mime, String path, ServletRequest request, ServletResponse response, FilterChain chain)
          Gets the resource.
 boolean isLocalizedContent()
          Gets the localized content flag.
 void removeFixedPath(String key)
          Removes a fixed content path.
 void setFixedPath(String key, String path)
          Sets a fixed content path.
 void setLocalizedContent(boolean flag)
          Sets the localized content flag.
 void setMaxAge(int secs)
          Sets the max caching age of content in clients.
 
Methods inherited from class org.norther.tammi.spray.filter.DefaultContainerFilter
destroy, 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
 

Constructor Detail

DefaultMediaContentFilter

public DefaultMediaContentFilter()
Contructs a new filter.


DefaultMediaContentFilter

protected DefaultMediaContentFilter(ContentFilter filter)
Contructs a new filter.

Parameters:
filter - the filter adaptee.
Method Detail

getContentPath

public String getContentPath(boolean unparsed,
                             ServletRequest request,
                             ServletResponse response,
                             FilterChain chain)
Description copied from interface: ContentFilter
Gets the optionally unparsed path info as the content path without any parsed keys and values, if any. Returns null, if the path is missing or unparsed is true and the path is partially parsed.

Specified by:
getContentPath in interface ContentFilter
Parameters:
unparsed - true for an unparsed path.
request - the request.
response - the response.
chain - the filter chain.
Returns:
the content path or an empty path.

isLocalizedContent

public boolean isLocalizedContent()
Description copied from interface: MediaContentFilter
Gets the localized content flag.

Specified by:
isLocalizedContent in interface MediaContentFilter<M extends MediaProvider>
Returns:
the localized content flag.

setLocalizedContent

public void setLocalizedContent(boolean flag)
Description copied from interface: MediaContentFilter
Sets the localized content flag. Localized media content names are formed by inserting the locale string between the plain name and the extension.

Specified by:
setLocalizedContent in interface MediaContentFilter<M extends MediaProvider>
Parameters:
flag - the localized content flag.

getMaxAge

public int getMaxAge()
Description copied from interface: MediaContentFilter
Gets the max caching age of content i clients.

Specified by:
getMaxAge in interface MediaContentFilter<M extends MediaProvider>
Returns:
the max age in seconds.

setMaxAge

public void setMaxAge(int secs)
Description copied from interface: MediaContentFilter
Sets the max caching age of content in clients.

Specified by:
setMaxAge in interface MediaContentFilter<M extends MediaProvider>
Parameters:
secs - the max age in seconds (-1 = forever).

getFixedPath

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

Specified by:
getFixedPath in interface MediaContentFilter<M extends MediaProvider>
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<M extends MediaProvider>
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<M extends MediaProvider>
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<M extends MediaProvider>

fixedKeySet

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

Specified by:
fixedKeySet in interface MediaContentFilter<M extends MediaProvider>
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 DefaultContainerFilter<M extends MediaProvider>
Throws:
ServletException
IOException

getMediaProvider

protected MediaProvider getMediaProvider(MimeType mime)
Gets the type specific provider.

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

getResource

protected Resource<?> getResource(MimeType mime,
                                  String path,
                                  ServletRequest request,
                                  ServletResponse response,
                                  FilterChain chain)
                           throws IOException,
                                  ConstructionException,
                                  AccessDeniedException
Gets the resource.

Parameters:
mime - the MIME type.
path - the resource path.
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.

getFilter

protected ContentFilter getFilter()
Gets the content filter adaptee.

Overrides:
getFilter in class DefaultContainerFilter<M extends MediaProvider>
Returns:
the content filter adaptee.


Copyright © 2004 The Norther Organization. All rights reserved.