public class PollHandler extends java.lang.Thread implements Handler
The result of fetching the url is expected to be a text document in java Properties format.
Properties:
url
above.
[token].name
and [token].value
define a new http header.
sessionTable
(see below)parameter is
identical to the sessionTable
parameter of
the SetTemplate
, then this specifies the
namespace
parameter that may be used with
the SetTemplate
"namespace" parameter to
obtain the extracted data. Defaults to the "prepend" parameter.
date format specifier
to use for matching "match"
patterns. Defaults to "EE-MM-dd-HH-mm".
host:port
, or host
it the desired port is 80
.
sessionTable
used by the SetTemplate
to allow
values obtained by this handler to be accessable from within
templates.
If the sessionTable
is set, the namespace
value is used to name the table (e.g. the namespace
specified by SetTemplate
. If no
namespace parameter is given, then prepend
is used
as the namespace parameter.
If prepend is specified, the following additional properties are created, and added to the properties with the specified prefix.
Modifier and Type | Field and Description |
---|---|
int |
interval |
java.lang.String |
post |
java.lang.String |
url |
Constructor and Description |
---|
PollHandler() |
Modifier and Type | Method and Description |
---|---|
void |
fillProps(java.util.Properties props,
HttpRequest target)
Fill the properties from the input stream
|
boolean |
init(Server server,
java.lang.String prefix)
Set up the initial configuration, and kick off a thread
to periodically fetch the url.
|
boolean |
respond(Request request)
This might allow control over the polling via requests at a later date.
|
void |
run()
Periodically poll the url, and copy the results into the server
properties.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public java.lang.String url
public java.lang.String post
public int interval
public boolean init(Server server, java.lang.String prefix)
init
in interface Handler
server
- The HTTP server that created this Handler
.
Typical Handler
s will use Server.props
to obtain run-time configuration information.prefix
- The handlers name.
The string this Handler
may prepend to all
of the keys that it uses to extract configuration information
from Server.props
. This is set (by the Server
and ChainHandler
) to help avoid configuration parameter
namespace collisions.true
if this Handler
initialized
successfully, false
otherwise. If
false
is returned, this Handler
should not be used.public boolean respond(Request request)
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void fillProps(java.util.Properties props, HttpRequest target) throws java.io.IOException
java.io.IOException