|
Enhydra 5.1 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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.
ChannelStatus
,
ServletManager
,
org.enhydra.servlet.filter.TransactionFilter
,
StandardConnectionMethod
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. |
int |
getPort()
|
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(Config connectionConfig,
java.lang.String id,
ServletManager servletManager,
FilterManager filterManager)
Initialize the ConnectionMethod. |
void |
initialize(java.lang.String id,
ServletManager servletManager,
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(Config connectionConfig,
java.lang.String base)
Write out self into config fie |
Field Detail |
public static final java.lang.String noChannelHtml
response.sendError(HttpServletResponse.SC_NOT_FOUND,
ConnectionMethod.noChannelHtml);
public static final java.lang.String disabledChannelHtml
response.sendError(HttpServletResponse.SC_MOVED_TEMPORARILY,
ConnectionMethod.disabledChannelHtml);
public static final java.lang.String errorHtml
response.sendError(HttpServletResponse.SC_SERVER_ERROR,
ConnectionMethod.errorHtml);
Method Detail |
public void initialize(Config connectionConfig, java.lang.String id, ServletManager servletManager, FilterManager filterManager) throws ConnectionMethodException
This will be called before any other method in this interface.
connectionConfig
- The portion of the config file relevant to
this connection methodid
- The id associated with this connection methodservletManager
- The ServletManager to use to obtain servlets.
Servlet ID strings given in addChannel()
are valid only
in this ServletManager.filterManager
- The FilterManager to use to get filters.
Filter ID strings given in addTransactionFilter()
are valid only in this FilterManager.
ConnectionMethodException
- If an error occurs.public void initialize(java.lang.String id, ServletManager servletManager, FilterManager filterManager) throws ConnectionMethodException
id
- The id associated with this connection methodservletManager
- The ServletManager to use to obtain servlets.
Servlet ID strings given in addChannel()
are valid only
in this ServletManager.filterManager
- The FilterManager to use to get filters.
Filter ID strings given in addTransactionFilter()
are valid only in this FilterManager.
ConnectionMethodException
- If an error occurs.public void writeToConfig(Config connectionConfig, java.lang.String base) throws ConfigException, KeywordValueException
base
- The base key string
ConfigException
KeywordValueException
public void addChannel(java.lang.String channelID, java.lang.String URLPrefix, java.lang.String servletID) throws ConnectionMethodException
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.
channelID
- The symbolic name to use for this channel.URLPrefix
- If a request's URL starts with this string,
it should be sent to the servlet identified by servletID.
To obtain the servlet, use the ServletManager's get()
method.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.
ConnectionMethodException
- If an error occurs.public void deleteChannel(java.lang.String channelID) throws ConnectionMethodException
channelID
- Which channel to remove.
ConnectionMethodException
- If an error occurs.public ChannelStatus getChannelStatus(java.lang.String channelID)
channelID
- Which channel.
ChannelStatus
public java.lang.String[] getChannelIDs()
public void enableChannel(java.lang.String channelID) throws ConnectionMethodException
channelID
- Which channel to enable.
ConnectionMethodException
- If an error occurs.public void disableChannel(java.lang.String channelID) throws ConnectionMethodException
channelID
- Which channel to disable.
ConnectionMethodException
- If an error occurs.public void resetRequestCount(java.lang.String channelID) throws ConnectionMethodException
channelID
- Which channel.
ConnectionMethodException
- If an error occurs.public void addTransactionFilter(java.lang.String channelID, java.lang.String filterID) throws ConnectionMethodException
removeTransactionFilter()
. The filter will be
fetched from the filter manager when a request comes in.
channelID
- Which channel to add a TransactionFilter to.filterID
- The TransactionFilter to add.
The filter is fetched from the FilterManager passed in to
initialize()
each time a request comes in.
ConnectionMethodException
- If an error occurs.org.enhydra.servlet.filter.TransactionFilter
public void removeTransactionFilter(java.lang.String channelID, java.lang.String filterID) throws ConnectionMethodException
channelID
- Which channel to remove a TransactionFilter from.
ConnectionMethodException
- If an error occurs.org.enhydra.servlet.filter.TransactionFilter
public java.lang.String[] getTransactionFilterIDs(java.lang.String channelID) throws ConnectionMethodException
removeTransactionFilter()
.
ConnectionMethodException
- If an error occurs, for example
if the channel does not exist.public java.lang.String getUniqueChannelName()
addChannel()
.public java.lang.String getChannelURL(java.lang.String channelID) throws ConnectionMethodException
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.
ConnectionMethodException
- If an error occurs,
for example if the channel does not exist.public boolean channelURLIsValid(java.lang.String channelID) throws ConnectionMethodException
getChannelURL()
a valid
url?
getChannelURL()
is a valid url that users could
sucessfully enter into their browsers.
ConnectionMethodException
- If an error occurs,
for example if the channel does not exist.public void destroy() throws ConnectionMethodException
initialize()
or any other mehtod must be terminated.After this call, none of these methods will be called again.
ConnectionMethodException
- If an error occurs.public boolean equivalent(ConnectionMethod compareObject)
compareObject
- The object to compare this to
ConnectionMethodException
- If an error occurs.public java.lang.String getType()
public int getPort()
|
Enhydra 5.1 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |