org.norther.tammi.spray.protocol
Class DefaultHttpRelayFilter

java.lang.Object
  extended by org.norther.tammi.core.base.Adaptee
      extended by org.norther.tammi.spray.filter.DefaultFilter
          extended by org.norther.tammi.spray.protocol.DefaultHttpRelayFilter
All Implemented Interfaces:
Serializable, NotificationBroadcaster, NotificationEmitter, Filter, Manageable, MBeanDelegate, Configurable, HttpRelayFilter

public class DefaultHttpRelayFilter
extends DefaultFilter
implements HttpRelayFilter

A default implementation of HttpRelayFilter.

Version:
$Id: DefaultHttpRelayFilter.java,v 1.11 2009/09/28 15:08:28 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
DefaultHttpRelayFilter()
          Constructs a new filter.
 
Method Summary
 void addProperty(int index, String key, String value)
          Inserts a multivalued property at the specified index.
 void addProperty(String key, String value)
          Adds a multivalued property.
 void addPropertyFilePath(String path)
          Adds a property file path.
 void addPropertyFilePath(String path, String encoding)
          Adds a property file path with an encoding.
 void clearProperties()
          Clears all properties.
 boolean containsProperty(String key)
          Checks whether a property is defined.
 void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
           
 String getConfigKey()
          Gets the path finder key for resolving configuration paths.
 String[] getProperties(String key)
          Gets a multivalued property.
 String getProperty(String key)
          Gets a property.
 String getPropertyFilePath()
          Gets the property file path.
 String[] getPropertyFilePaths()
          Gets the property file paths.
 int indexOfProperty(String key, String value)
          Returns the index of a multivalued property value.
protected  String normalize(String uri)
          Normalizes the specified URI.
 OrderedMap<String,Object> propertyMap()
          Returns a map of properties.
 OrderedMap<String,Object> propertyMap(String prefix)
          Returns a map of prefixed properties.
 Object removeProperty(String key)
          Removes a property.
 boolean removeProperty(String key, String value)
          Removes a multivalued property.
 void removePropertyFilePath(String path)
          Removes a property file path.
 void setConfigKey(String key)
          Sets the path finder key for resolving configuration paths.
 Object setProperties(String key, String[] values)
          Sets a multivalued property.
 Object setProperty(String key, String value)
          Sets a property.
 void setPropertyFilePath(String path)
          Sets the property file path.
 void setPropertyFilePath(String path, String encoding)
          Sets the property file path with an encoding.
 void setPropertyFilePaths(String[] paths)
          Sets the property file paths.
 void setPropertyFilePaths(String[] paths, String... encoding)
          Sets the property file paths with encodings.
 void storeProperties()
          Stores properties to the property file.
 
Methods inherited from class org.norther.tammi.spray.filter.DefaultFilter
destroy, getFilterConfig, getRequestMap, getSessionMap, init
 
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 javax.servlet.Filter
destroy, init
 

Constructor Detail

DefaultHttpRelayFilter

public DefaultHttpRelayFilter()
Constructs a new filter.

Method Detail

getConfigKey

public String getConfigKey()
Description copied from interface: Configurable
Gets the path finder key for resolving configuration paths.

Specified by:
getConfigKey in interface Configurable
Returns:
the path finder key.

setConfigKey

public void setConfigKey(String key)
Description copied from interface: Configurable
Sets the path finder key for resolving configuration paths. The default key is PathFinderMBean.CONFIG.

Specified by:
setConfigKey in interface Configurable
Parameters:
key - the path finder key.

getPropertyFilePath

public String getPropertyFilePath()
Description copied from interface: Configurable
Gets the property file path. The first one is returned if more than one is defined.

Specified by:
getPropertyFilePath in interface Configurable
Returns:
the property file path or null.

setPropertyFilePath

public void setPropertyFilePath(String path)
Description copied from interface: Configurable
Sets the property file path. The path may be an absolute file path, a file path relative to the specified config key folder or a URL. The properties will be loaded before the next get/set property operation.

Note that all previously defined property file paths and properties are cleared.

Specified by:
setPropertyFilePath in interface Configurable
Parameters:
path - a property file path.

setPropertyFilePath

public void setPropertyFilePath(String path,
                                String encoding)
Description copied from interface: Configurable
Sets the property file path with an encoding.

Specified by:
setPropertyFilePath in interface Configurable
Parameters:
path - a property file path.
encoding - an encoding to use.

getPropertyFilePaths

public String[] getPropertyFilePaths()
Description copied from interface: Configurable
Gets the property file paths.

Specified by:
getPropertyFilePaths in interface Configurable
Returns:
the property file paths.

setPropertyFilePaths

public void setPropertyFilePaths(String[] paths)
Description copied from interface: Configurable
Sets the property file paths. The path may be an absolute file path, a file path relative to the specified config key folder or a URL. The properties will be loaded before the next get/set property operation. New paths are added after existing ones.

Specified by:
setPropertyFilePaths in interface Configurable
Parameters:
paths - property file paths.

setPropertyFilePaths

public void setPropertyFilePaths(String[] paths,
                                 String... encoding)
Description copied from interface: Configurable
Sets the property file paths with encodings.

Specified by:
setPropertyFilePaths in interface Configurable
Parameters:
paths - property file paths.
encoding - encodings to use.

addPropertyFilePath

public void addPropertyFilePath(String path)
Description copied from interface: Configurable
Adds a property file path.

Specified by:
addPropertyFilePath in interface Configurable
Parameters:
path - a property file path.

addPropertyFilePath

public void addPropertyFilePath(String path,
                                String encoding)
Description copied from interface: Configurable
Adds a property file path with an encoding.

Specified by:
addPropertyFilePath in interface Configurable
Parameters:
path - a property file path.
encoding - an encoding to use.

removePropertyFilePath

public void removePropertyFilePath(String path)
Description copied from interface: Configurable
Removes a property file path.

Specified by:
removePropertyFilePath in interface Configurable
Parameters:
path - the property file path.

containsProperty

public boolean containsProperty(String key)
Description copied from interface: Configurable
Checks whether a property is defined.

Specified by:
containsProperty in interface Configurable
Parameters:
key - the key.
Returns:
true for a defined property, false otherwise.

getProperty

public String getProperty(String key)
Description copied from interface: Configurable
Gets a property.

Specified by:
getProperty in interface Configurable
Parameters:
key - the key.
Returns:
the value or null.

setProperty

public Object setProperty(String key,
                          String value)
Description copied from interface: Configurable
Sets a property.

Specified by:
setProperty in interface Configurable
Parameters:
key - the key.
value - the value.
Returns:
the previous value.

getProperties

public String[] getProperties(String key)
Description copied from interface: Configurable
Gets a multivalued property.

Specified by:
getProperties in interface Configurable
Parameters:
key - the key.
Returns:
the values or null.

setProperties

public Object setProperties(String key,
                            String[] values)
Description copied from interface: Configurable
Sets a multivalued property.

Specified by:
setProperties in interface Configurable
Parameters:
key - the key.
values - the values.
Returns:
the previous value.

removeProperty

public Object removeProperty(String key)
Description copied from interface: Configurable
Removes a property.

Specified by:
removeProperty in interface Configurable
Parameters:
key - the key.
Returns:
the removed value or null.

indexOfProperty

public int indexOfProperty(String key,
                           String value)
Description copied from interface: Configurable
Returns the index of a multivalued property value.

Specified by:
indexOfProperty in interface Configurable
Parameters:
key - the key.
value - the value.
Returns:
the index of the value or -1.

addProperty

public void addProperty(String key,
                        String value)
Description copied from interface: Configurable
Adds a multivalued property.

Specified by:
addProperty in interface Configurable
Parameters:
key - the key.
value - the property.

addProperty

public void addProperty(int index,
                        String key,
                        String value)
Description copied from interface: Configurable
Inserts a multivalued property at the specified index.

Specified by:
addProperty in interface Configurable
Parameters:
index - the index.
key - the key.
value - the value.

removeProperty

public boolean removeProperty(String key,
                              String value)
Description copied from interface: Configurable
Removes a multivalued property.

Specified by:
removeProperty in interface Configurable
Parameters:
key - the key.
value - the value.
Returns:
true if removed, false otherwise.

clearProperties

public void clearProperties()
Description copied from interface: Configurable
Clears all properties.

Specified by:
clearProperties in interface Configurable

propertyMap

public OrderedMap<String,Object> propertyMap()
Description copied from interface: Configurable
Returns a map of properties. Multivalued properties are presented as string arrays.

Specified by:
propertyMap in interface Configurable
Returns:
a map of properties.

propertyMap

public OrderedMap<String,Object> propertyMap(String prefix)
Description copied from interface: Configurable
Returns a map of prefixed properties. The prefix is removed from the keys of the returned map. Multivalued properties are presented as string arrays.

Specified by:
propertyMap in interface Configurable
Parameters:
prefix - the prefix.
Returns:
a map of properties.

storeProperties

public void storeProperties()
                     throws IOException
Description copied from interface: Configurable
Stores properties to the property file. The first defined property file is applied to all properties.

Specified by:
storeProperties in interface Configurable
Throws:
IOException - on I/O errors.

doFilter

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

normalize

protected String normalize(String uri)
Normalizes the specified URI.

Parameters:
uri - the URI.
Returns:
the normalized URI.


Copyright © 2004 The Norther Organization. All rights reserved.