Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.enhydra.servlet.connectionMethods
Interface ConnectionMethod  view ConnectionMethod download ConnectionMethod.java

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
StandardConnectionMethod

public interface ConnectionMethod
extends java.io.Serializable

A ConnectionMethod is how requests get into the server from the outside world. This interface defines the API an object must implement in order to be administered by the server.

Each ConnectionMethod must maintain an ordered list of "channels". Each channel has an ID (a String), used to identify and refer to the channel. See addChannel(), below.

Each channel can be enabled or disabled. When disabled, connections must be refused, and not passed on to any servlets. When enabled, connections are allowed through to the destination servlet.

Each channel also contains an ordered list of TransactionFilters, which can be used for debugging and logging.

When a ConnectionMethod is being used as part of a server, the initialize() method will be called before any other methods. The servlet IDs in the channels are only valid in the ServletManager object provided to initialize(). Filter IDs are only valid in the FilterManager passed in to initialize().

The destroy() method will be called when the ConnectionMethod should shut down. Any external network exposure should be eliminated, for example any ServerSockets should be closed, or any WAI registrations should be unregistered. After destroy() is called, no further calls will be made to the object.

HTTP, WAI and RMI are implementations of this interface. See StandardConnectionMethod for a sample implementation which mananges the channels, but does not actually recieve or generate requests. If you are implementing a ConnectionMethod, it is recommended that you extend StandardConnectionMethod. Connection methods must contain a running non-daemon thread. The thread must be started either in the constructor or (perfered) the initialize() method, and stopped in the destroy() method.


Field Summary
static java.lang.String disabledChannelHtml
          Return this HTML when an incomming request matches a channel, but that channel is disabled.
static java.lang.String errorHtml
          Return this HTML if an unexpected exception is thrown.
static java.lang.String noChannelHtml
          Return this HTML when an incomming request does not match any of the channels.
 
Method Summary
 void addChannel(java.lang.String channelID, java.lang.String URLPrefix, java.lang.String servletID)
          Add a new channel.
 void addTransactionFilter(java.lang.String channelID, java.lang.String filterID)
          Add a new TransactionFilter to the specified channel.
 boolean channelURLIsValid(java.lang.String channelID)
          Is the string returned from getChannelURL() a valid url?
 void deleteChannel(java.lang.String channelID)
          Delete a channel.
 void destroy()
          Shut down the connection method.
 void disableChannel(java.lang.String channelID)
          Turn off the channel.
 void enableChannel(java.lang.String channelID)
          Turn on the channel.
 boolean equivalent(ConnectionMethod compareObject)
          Compares the connection specific attributes for equivalency
 java.lang.String[] getChannelIDs()
          Returns the identifier names of all the channels currently in the ConnectionMethod.
 ChannelStatus getChannelStatus(java.lang.String channelID)
          Get the current status of a channel.
 java.lang.String getChannelURL(java.lang.String channelID)
          Returns the URL that a user would use to connect to this channel.
 java.lang.String[] getTransactionFilterIDs(java.lang.String channelID)
          Get an array of all the current filter names for a given channel.
 java.lang.String getType()
           
 java.lang.String getUniqueChannelName()
          This returns a channel name that is not currently in use.
 void initialize(com.lutris.util.Config connectionConfig, java.lang.String id, org.enhydra.servlet.servletManager.ServletManager servletManager, org.enhydra.servlet.filter.FilterManager filterManager)
          Initialize the ConnectionMethod.
 void initialize(java.lang.String id, org.enhydra.servlet.servletManager.ServletManager servletManager, org.enhydra.servlet.filter.FilterManager filterManager)
          Initialize the ConnectionMethod.
 void removeTransactionFilter(java.lang.String channelID, java.lang.String filterID)
          Remove the given TransactionFilter from the specified channel.
 void resetRequestCount(java.lang.String channelID)
          Reset the specified channel's request count to zero.
 void writeToConfig(com.lutris.util.Config connectionConfig, java.lang.String base)
          Write out self into config fie
 

Field Detail

noChannelHtml

public static final java.lang.String noChannelHtml
Return this HTML when an incomming request does not match any of the channels. Suggested use: response.sendError(HttpServletResponse.SC_NOT_FOUND, ConnectionMethod.noChannelHtml);

See Also:
Constant Field Values

disabledChannelHtml

public static final java.lang.String disabledChannelHtml
Return this HTML when an incomming request matches a channel, but that channel is disabled. Suggested use: response.sendError(HttpServletResponse.SC_MOVED_TEMPORARILY, ConnectionMethod.disabledChannelHtml);

See Also:
Constant Field Values

errorHtml

public static final java.lang.String errorHtml
Return this HTML if an unexpected exception is thrown. Suggested use: response.sendError(HttpServletResponse.SC_SERVER_ERROR, ConnectionMethod.errorHtml);

See Also:
Constant Field Values
Method Detail

initialize

public void initialize(com.lutris.util.Config connectionConfig,
                       java.lang.String id,
                       org.enhydra.servlet.servletManager.ServletManager servletManager,
                       org.enhydra.servlet.filter.FilterManager filterManager)
                throws ConnectionMethodException
Initialize the ConnectionMethod. The ServletManager to use is passed in. This ServletManager is used to look up Servlets based on their String servlet IDs.

This will be called before any other method in this interface.


initialize

public void initialize(java.lang.String id,
                       org.enhydra.servlet.servletManager.ServletManager servletManager,
                       org.enhydra.servlet.filter.FilterManager filterManager)
                throws ConnectionMethodException
Initialize the ConnectionMethod. The ServletManager to use is passed in. This ServletManager is used to look up Servlets based on their String servlet IDs.


writeToConfig

public void writeToConfig(com.lutris.util.Config connectionConfig,
                          java.lang.String base)
                   throws com.lutris.util.ConfigException,
                          com.lutris.util.KeywordValueException
Write out self into config fie


addChannel

public void addChannel(java.lang.String channelID,
                       java.lang.String URLPrefix,
                       java.lang.String servletID)
                throws ConnectionMethodException
Add a new channel. The new channel is not enabled, and has no TransactionFilters. The Servlet ID is only valid in the ServletManager passed in to initialize(). When the Servlet ID is used to fetch the actual Servlet, the reference should only be kept in the ConnectionMethod for the duration of the request. After the request is finished, the ConnectionMehtod should eliminate all pointers to the Servlet. This will allow the ServletManager to destroy the Servlet and cause it to get garbage collected. The ServletManager's get() method should be called for every request.


deleteChannel

public void deleteChannel(java.lang.String channelID)
                   throws ConnectionMethodException
Delete a channel.


getChannelStatus

public ChannelStatus getChannelStatus(java.lang.String channelID)
Get the current status of a channel.


getChannelIDs

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


enableChannel

public void enableChannel(java.lang.String channelID)
                   throws ConnectionMethodException
Turn on the channel. Allows requests to be sent to the servlet.


disableChannel

public void disableChannel(java.lang.String channelID)
                    throws ConnectionMethodException
Turn off the channel. Incomming requests should be refused. No requests should be allowd through to the servlet.


resetRequestCount

public void resetRequestCount(java.lang.String channelID)
                       throws ConnectionMethodException
Reset the specified channel's request count to zero. The counter measures the number of requests processed by this channel.


addTransactionFilter

public void addTransactionFilter(java.lang.String channelID,
                                 java.lang.String filterID)
                          throws ConnectionMethodException
Add a new TransactionFilter to the specified channel. Use this ID to refer to the filter in removeTransactionFilter(). The filter will be fetched from the filter manager when a request comes in.


removeTransactionFilter

public void removeTransactionFilter(java.lang.String channelID,
                                    java.lang.String filterID)
                             throws ConnectionMethodException
Remove the given TransactionFilter from the specified channel.


getTransactionFilterIDs

public java.lang.String[] getTransactionFilterIDs(java.lang.String channelID)
                                           throws ConnectionMethodException
Get an array of all the current filter names for a given channel. If there are no filters, this will return a zero-length array.


getUniqueChannelName

public java.lang.String getUniqueChannelName()
This returns a channel name that is not currently in use. Use this when you want to programatically create a channel, and you don't care what it's name is. The name returned will not be in the list of current channels, and will not be returned on any other calls to this function.


getChannelURL

public java.lang.String getChannelURL(java.lang.String channelID)
                               throws ConnectionMethodException
Returns the URL that a user would use to connect to this channel. For example, with an HTTP method on port 2000 on a machine called enhydra.lutris.com, and a url prefix of /abalone/, the returned string would be "http://enhydra.lutris.com:2000/abalone/".

Note: it is not always possible for a connection method to know the exact URL a user should use, so the returned string may be an approximation. For example, the RMI connection method may be accessed from any host that has access to it.


channelURLIsValid

public boolean channelURLIsValid(java.lang.String channelID)
                          throws ConnectionMethodException
Is the string returned from getChannelURL() a valid url?


destroy

public void destroy()
             throws ConnectionMethodException
Shut down the connection method. Any threads created in initialize() or any other mehtod must be terminated.

After this call, none of these methods will be called again.


equivalent

public boolean equivalent(ConnectionMethod compareObject)
Compares the connection specific attributes for equivalency


getType

public java.lang.String getType()