Enhydra 5.1 API

org.enhydra.servlet.connectionMethods
Class ChannelTable

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

public class ChannelTable
extends java.lang.Object

A table of Channel elements.

Author:
Andy John
, Shawn McMurdo
See Also:
Channel, ConnectionMethod, StandardConnectionMethod

Field Summary
protected  java.util.Vector channelTable
          This is the actual table.
 
Constructor Summary
ChannelTable()
          Constructor
 
Method Summary
 void add(Channel channel)
          Add a new channel.
 void add(java.lang.String channelID, java.lang.String URLPrefix, java.lang.String servletID)
          Add a new channel.
 void delete(java.lang.String channelID)
          Delete a channel.
 Channel findID(java.lang.String channelID)
          Return the Channel for the given identification name.
 Channel findURLPrefix(java.lang.String URL)
          Search the set of channels for one whose URLPrefix matches the beginning of the given URL.
 Channel getChannelByID(java.lang.String channelID)
          Return the Channel for the given identification name.
 Channel getChannelByURLPrefix(java.lang.String urlPrefix)
          Return the Channel for the given URL prefix.
 java.lang.String[] getChannelIDs()
          Returns the identifier names of all the channels currently in the ChannelTable.
 java.lang.String toString()
          Return a multi-line string listing the channel ids.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

channelTable

protected java.util.Vector channelTable
This is the actual table. If you need to synchronize across multiple calls to this class, you may synchronize on this object. Internally, all synchronization is done on this object.

Maybe this should be replaced with a public Object, and it should be used for all locking?

Constructor Detail

ChannelTable

public ChannelTable()
Constructor

Method Detail

add

public void add(java.lang.String channelID,
                java.lang.String URLPrefix,
                java.lang.String servletID)
Add a new channel. The new channel is not enabled and has no TransactionFilters.

Parameters:
channelID - The symbolic name to use for this channel.
URLPrefix - If a request's URL starts with this string, it will be sent to the servlet identified by servletID.
servletID - The servlet to send requests to. Use the ServletManager's get() method to get the servlet. Call get() for each request, do not save a reference to the servlet.
See Also:
ServletManager

add

public void add(Channel channel)
Add a new channel. The new channel is not enabled and has no TransactionFilters.

Parameters:
channel - the channel to add.

delete

public void delete(java.lang.String channelID)
Delete a channel.

Parameters:
channelID - Which channel to remove.

getChannelIDs

public java.lang.String[] getChannelIDs()
Returns the identifier names of all the channels currently in the ChannelTable.

Returns:
An array of Strings, the names of all the channels

getChannelByID

public Channel getChannelByID(java.lang.String channelID)
Return the Channel for the given identification name. Returns null if not found.

Parameters:
channelID - Which channel to search for.
Returns:
The Channel (see above) for the given channel, or null if not found.

findID

public Channel findID(java.lang.String channelID)
Return the Channel for the given identification name. Returns null if not found. Warning: this method does not synchronize on channelTable. The caller must synchronize on it. Normally you will want to synchronize on it, call this method to look up a Channel, modify the Channel or the table itself, then release the lock on channelTable. That way you know that the table will not change between the time you fetch an entry to the time you modify the entry or the table.

Parameters:
channelID - Which channel to search for.
Returns:
The Channel (see above) for the given channel, or null if not found.

getChannelByURLPrefix

public Channel getChannelByURLPrefix(java.lang.String urlPrefix)
Return the Channel for the given URL prefix. Returns null if not found.

Parameters:
urlPrefix - The URL prefix to search for.
Returns:
The Channel for the given URL prefix, or null if not found.

findURLPrefix

public Channel findURLPrefix(java.lang.String URL)
Search the set of channels for one whose URLPrefix matches the beginning of the given URL. Returns null if not found. If you are extending this class, you should use this method to determine which channel applies to a request URL. The Channel returned is a reference to the object stored in the table, so any changes made to it are also made to the working instance in the table.

Warning: this method does not synchronize on channelTable. The caller must synchronize on it. Normally you will want to synchronize on it, call this method to look up a Channel, modify the Channel or the table its self, then release the lock on channelTable. That way you know that the table will not change between the time you fetch an entry to the time you modify the entry or the table.

Parameters:
URL - The URL to try to find a match for.
Returns:
The Channel (see above) that matches the given URL, or null if not found.

toString

public java.lang.String toString()
Return a multi-line string listing the channel ids.

Overrides:
toString in class java.lang.Object
Returns:
The current channel ids.

Enhydra 5.1 API