Enhydra 5.1 API

org.enhydra.servlet.connectionMethods
Class Channel

java.lang.Object
  |
  +--org.enhydra.servlet.connectionMethods.Channel

public class Channel
extends java.lang.Object

Everything there is to store about a channel.

Author:
Shawn McMurdo
See Also:
ChannelTable, ConnectionMethod, StandardConnectionMethod

Field Summary
protected  java.util.Vector filterIDs
           
 
Constructor Summary
Channel()
           
 
Method Summary
 void addFilter(java.lang.String filterID)
          Add a new filter to the stack of filters.
static int compareURLPrefixes(java.lang.String a, java.lang.String b)
          Compare two URL prefixes in terms of specificity.
 void disable()
          Set the channel enabled state to false.
 void enable()
          Set the channel enabled state to true.
 java.lang.String getChannelID()
          Get the channel ID.
 java.util.Date getCreateTime()
          Return the time when this channel was created.
 boolean getEnabled()
          Return the channel enabled state.
 java.util.Date getEnabledDisabledTime()
          Return the time when enable(), disable(), or setEnabled() was last called.
 java.lang.String[] getFilterIDs()
          Returns an array of Strings, the filter names.
 long getRequestCount()
          Return the request count.
 java.lang.String getServletID()
          Get the servlet ID.
 java.lang.String getURLPrefix()
          Get the URL prefix.
 void incrRequestCount()
          Increment the request count.
 void removeFilter(java.lang.String filterID)
          Remove a filter to the stack of filters.
 void resetRequestCount()
          Reset the request count.
 void setChannelID(java.lang.String channelID)
          Set the channel ID.
 void setEnabled(boolean enabled)
          Set the channel enabled state.
 void setRequestCount(long count)
          Set the request count.
 void setServletID(java.lang.String servletID)
          Set the servlet ID.
 void setURLPrefix(java.lang.String urlPrefix)
          Set the URL prefix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filterIDs

protected java.util.Vector filterIDs
Constructor Detail

Channel

public Channel()
Method Detail

setChannelID

public void setChannelID(java.lang.String channelID)
Set the channel ID.

Parameters:
channelID - The channel ID.

getChannelID

public java.lang.String getChannelID()
Get the channel ID.

Returns:
The channel ID.

setURLPrefix

public void setURLPrefix(java.lang.String urlPrefix)
Set the URL prefix.

Parameters:
urlPrefix - The URL prefix.

getURLPrefix

public java.lang.String getURLPrefix()
Get the URL prefix.

Returns:
The URL prefix.

setServletID

public void setServletID(java.lang.String servletID)
Set the servlet ID.

Parameters:
servletID - The servlet ID.

getServletID

public java.lang.String getServletID()
Get the servlet ID.

Returns:
The servlet ID.

setEnabled

public void setEnabled(boolean enabled)
Set the channel enabled state.

Parameters:
enabled - True to enable, false to disable.

enable

public void enable()
Set the channel enabled state to true.


disable

public void disable()
Set the channel enabled state to false.


getEnabled

public boolean getEnabled()
Return the channel enabled state.

Returns:
True if the channel is enabled.

getCreateTime

public java.util.Date getCreateTime()
Return the time when this channel was created.

Returns:
The time when the constructor was called.

getEnabledDisabledTime

public java.util.Date getEnabledDisabledTime()
Return the time when enable(), disable(), or setEnabled() was last called. Channels start off disabled, and this value starts off with the same value as getCreateTime()

Returns:
The time when the the channel was last enabled or disabled.

addFilter

public void addFilter(java.lang.String filterID)
               throws ConnectionMethodException
Add a new filter to the stack of filters. The first filter added should be the first filter wrapped around the Servlet, request and response objects. The filter is refered to in the future by it's filterID. The filters are fetched from the filter manager at request time.

Parameters:
filterID - The symbolic name to use to refer to this filter.
Throws:
ConnectionMethodException - If the name is already in use.

removeFilter

public void removeFilter(java.lang.String filterID)
                  throws ConnectionMethodException
Remove a filter to the stack of filters. Use the filter ID passed in to addFilter().

Parameters:
filterID - The symbolic name of the filter to remove.
Throws:
ConnectionMethodException - If the name is not found.

getFilterIDs

public java.lang.String[] getFilterIDs()
Returns an array of Strings, the filter names.

Returns:
An array of the current TransactionFilter names.

setRequestCount

public void setRequestCount(long count)
Set the request count.

Parameters:
count - The request count.

resetRequestCount

public void resetRequestCount()
Reset the request count.


incrRequestCount

public void incrRequestCount()
Increment the request count.


getRequestCount

public long getRequestCount()
Return the request count.

Returns:
The request count.

compareURLPrefixes

public static int compareURLPrefixes(java.lang.String a,
                                     java.lang.String b)
Compare two URL prefixes in terms of specificity. If a is more specific than b, 1 is returned. If b is more specific than a, -1 is returned. If a and b are equally specific, 0 is returned.

This comparison can be used to sort channels into the order that should be used for matching request URLs. When a request comes in, it's URL is extracted. Then the list of URL prefixes is searched. The first one that matches the beginning of the request URL is found. This channel then recieves the request. The list of URL prefixes should be sorted via this comparison operator. This will ensure, for example, that /admin/ is examined before / is. If they were compared in the other order, the / would always match, and the channel associated with /admin/ would never get any requests.

The URL prefixes are sorted based on the number of directory separator characters they have. More separators means the prefix is more specific. If two prefixes have the same number of directory components, then the one with the longer final path element is considered more specific. If the final path components are the same length, the strings are considered equal.

Here is an example of a resulting search order using this method:

  /app1/a/b/c/d/e/
  /app2/longer-name/but-less-path/elements/
  /demo/free/supersavers/
  /demo/free/supersavers
  /demo/free/super
  /index.html
  /index
  /
  index.html
  index
  "" (the empty string)
Note that the empty string always comes last, and it matches all incoming URLs.


Enhydra 5.1 API