|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.xmlrpc.P2PWebServer
public class P2PWebServer
A minimal web server that exclusively handles XML-RPC requests sent over the Jxta network, using P2P Sockets.
| 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 | |
|---|---|
P2PWebServer(int port)
Creates a web server at the specified port number. |
|
P2PWebServer(int port,
java.net.InetAddress addr)
Creates a web server at the specified port number and IP address. |
|
P2PWebServer(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.P2PWebServer.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 P2PWebServer(int port)
public P2PWebServer(int port,
java.net.InetAddress addr)
public P2PWebServer(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[]).
java.lang.Exceptionpublic 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
java.lang.IllegalArgumentExceptiondenyClient(java.lang.String),
setParanoid(boolean)
public void denyClient(java.lang.String address)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentExceptionacceptClient(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.Runnablejava.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.P2PWebServer.Runner getRunner()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||