|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.xmlrpc.WebServer
A minimal web server that exclusively handles XML-RPC requests.
Field Summary | |
protected java.util.Vector |
accept
|
protected static byte[] |
clength
|
protected static byte[] |
conclose
|
protected static byte[] |
conkeep
|
protected static byte[] |
ctype
|
protected java.util.Vector |
deny
|
protected static byte[] |
doubleNewline
|
protected java.lang.Thread |
listener
|
protected static byte[] |
newline
|
protected static byte[] |
ok
|
protected java.lang.ThreadGroup |
runners
|
protected static byte[] |
server
|
protected java.net.ServerSocket |
serverSocket
|
protected java.util.Stack |
threadpool
|
protected static byte[] |
wwwAuthenticate
|
protected XmlRpcServer |
xmlrpc
|
Constructor Summary | |
WebServer(int port)
Creates a web server at the specified port number. |
|
WebServer(int port,
java.net.InetAddress addr)
Creates a web server at the specified port number and IP address. |
|
WebServer(int port,
java.net.InetAddress addr,
XmlRpcServer xmlrpc)
Creates a web server at the specified port number and IP address. |
Method Summary | |
void |
acceptClient(java.lang.String address)
Add an IP address to the list of accepted clients. |
protected void |
addDefaultHandlers()
Adds the bundled handlers to the server. |
void |
addHandler(java.lang.String name,
java.lang.Object target)
Register a handler object with this name. |
protected boolean |
allowConnection(java.net.Socket s)
Checks incoming connections to see if they should be allowed. |
protected boolean |
checkSocket(java.net.Socket s)
Deprecated. Use allowConnection(Socket) instead. |
protected java.net.ServerSocket |
createServerSocket(int port,
int backlog,
java.net.InetAddress addr)
Factory method to manufacture the server socket. |
void |
denyClient(java.lang.String address)
Add an IP address to the list of denied clients. |
protected static int |
determinePort(java.lang.String[] argv,
int defaultPort)
Examines command line arguments from argv . |
protected org.apache.xmlrpc.WebServer.Runner |
getRunner()
|
static void |
main(java.lang.String[] argv)
This can be called from command line, but you'll have to edit and recompile to change the server port or handler objects. |
void |
removeHandler(java.lang.String name)
Remove a handler object that was previously registered with this server. |
void |
run()
Listens for client requests until stopped. |
void |
setParanoid(boolean p)
Switch client filtering on/off. |
void |
shutdown()
Stop listening on the server port. |
void |
start()
Spawns a new thread which binds this server to the port it's configured to accept connections on. |
protected static byte[] |
toHTTPBytes(java.lang.String text)
Returns the US-ASCII encoded byte representation of text for HTTP use (as per section 2.2 of RFC 2068). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected XmlRpcServer xmlrpc
protected java.net.ServerSocket serverSocket
protected java.lang.Thread listener
protected java.util.Vector accept
protected java.util.Vector deny
protected java.util.Stack threadpool
protected java.lang.ThreadGroup runners
protected static final byte[] ctype
protected static final byte[] clength
protected static final byte[] newline
protected static final byte[] doubleNewline
protected static final byte[] conkeep
protected static final byte[] conclose
protected static final byte[] ok
protected static final byte[] server
protected static final byte[] wwwAuthenticate
Constructor Detail |
public WebServer(int port)
public WebServer(int port, java.net.InetAddress addr)
public WebServer(int port, java.net.InetAddress addr, XmlRpcServer xmlrpc)
Method Detail |
public static void main(java.lang.String[] argv)
addDefaultHandlers()
protected static int determinePort(java.lang.String[] argv, int defaultPort)
argv
. If a
port may have been provided, parses that port (exiting with
error status if the port cannot be parsed). If no port is
specified, defaults to defaultPort
.defaultPort
- The port to use if none was specified.protected static final byte[] toHTTPBytes(java.lang.String text)
protected java.net.ServerSocket createServerSocket(int port, int backlog, java.net.InetAddress addr) throws java.lang.Exception
SSLServerSocket
).port
- backlog
- addr
- If null
, binds to
INADDR_ANY
, meaning that all network interfaces on
a multi-homed host will be listening.java.lang.Exception
- Error creating listener socket.public void start()
run()
public void addHandler(java.lang.String name, java.lang.Object target)
protected void addDefaultHandlers() throws java.lang.Exception
main(String[])
.public void removeHandler(java.lang.String name)
public void setParanoid(boolean p)
acceptClient(java.lang.String)
,
denyClient(java.lang.String)
public void acceptClient(java.lang.String address) throws java.lang.IllegalArgumentException
denyClient(java.lang.String)
,
setParanoid(boolean)
public void denyClient(java.lang.String address) throws java.lang.IllegalArgumentException
acceptClient(java.lang.String)
,
setParanoid(boolean)
protected boolean allowConnection(java.net.Socket s)
s
- The socket to inspect.protected boolean checkSocket(java.net.Socket s)
allowConnection(Socket)
instead.allowConnection(Socket)
public void run()
start()
to invoke this method, and shutdown()
to
break out of it.run
in interface java.lang.Runnable
java.lang.RuntimeException
- Generally caused by either an
UnknownHostException
or BindException
with the vanilla web server.start()
,
shutdown()
public void shutdown()
listener
effectively breaks it out of its run()
loop.run()
protected org.apache.xmlrpc.WebServer.Runner getRunner()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |