Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Static Package Attributes | Private Member Functions | Private Attributes
org.apache.xmlrpc.webserver.WebServer Class Reference

List of all members.

Classes

class  AddressMatcher

Public Member Functions

void acceptClient (String pAddress)
void denyClient (String pAddress)
int getPort ()
XmlRpcStreamServer getXmlRpcServer ()
void log (Throwable pError)
void log (String pMessage)
void run ()
void setParanoid (boolean pParanoid)
synchronized void shutdown ()
void start () throws IOException
 WebServer (int pPort)
 WebServer (int pPort, InetAddress pAddr)

Protected Member Functions

boolean allowConnection (Socket s)
ServerSocket createServerSocket (int pPort, int backlog, InetAddress addr) throws IOException
boolean isParanoid ()
ThreadPool.Task newTask (WebServer pServer, XmlRpcStreamServer pXmlRpcServer, Socket pSocket) throws IOException
ThreadPool newThreadPool ()
XmlRpcStreamServer newXmlRpcStreamServer ()

Protected Attributes

final List accept = new ArrayList()
final List deny = new ArrayList()
final XmlRpcStreamServer server = newXmlRpcStreamServer()
ServerSocket serverSocket

Static Package Attributes

static final String HTTP_11 = "HTTP/1.1"

Private Member Functions

synchronized void setupServerSocket (int backlog) throws IOException

Private Attributes

InetAddress address
Thread listener
boolean paranoid
ThreadPool pool
int port

Detailed Description

The WebServer is a minimal HTTP server, that might be used as an embedded web server.

Use of the WebServer has grown very popular amongst users of Apache XML-RPC. Why this is the case, can hardly be explained, because the WebServer is at best a workaround, compared to full blown servlet engines like Tomcat or Jetty. For example, under heavy load it will almost definitely be slower than a real servlet engine, because it does neither support proper keepalive (multiple requests per physical connection) nor chunked mode (in other words, it cannot stream requests).

If you still insist in using the WebServer, it is recommended to use its subclass, the ServletWebServer instead, which offers a minimal subset of the servlet API. In other words, you keep yourself the option to migrate to a real servlet engine later.

Use of the WebServer goes roughly like this: First of all, create a property file (for example "MyHandlers.properties") and add it to your jar file. The property keys are handler names and the property values are the handler classes. Once that is done, create an instance of WebServer:

   final int port = 8088;
   final String propertyFile = "MyHandler.properties";
   PropertyHandlerMapping mapping = new PropertyHandlerMapping();
   ClassLoader cl = Thread.currentThread().getContextClassLoader();
   mapping.load(cl, propertyFile);
   WebServer webServer = new WebServer(port);
   XmlRpcServerConfigImpl config = new XmlRpcServerConfigImpl();
   XmlRpcServer server = webServer.getXmlRpcServer();
   server.setConfig(config);
   server.setHandlerMapping(mapping);
   webServer.start();
 

Definition at line 72 of file WebServer.java.


Constructor & Destructor Documentation

Creates a web server at the specified port number.

Parameters:
pPortPort number; 0 for a random port, choosen by the operating system.

Definition at line 135 of file WebServer.java.

org.apache.xmlrpc.webserver.WebServer.WebServer ( int  pPort,
InetAddress  pAddr 
) [inline]

Creates a web server at the specified port number and IP address.

Parameters:
pPortPort number; 0 for a random port, choosen by the operating system.
pAddrLocal IP address; null for all available IP addresses.

Definition at line 144 of file WebServer.java.


Member Function Documentation

void org.apache.xmlrpc.webserver.WebServer.acceptClient ( String  pAddress) [inline]

Add an IP address to the list of accepted clients. The parameter can contain '*' as wildcard character, e.g. "192.168.*.*". You must call setParanoid(true) in order for this to have any effect.

Parameters:
pAddressThe IP address being enabled.
See also:
denyClient(java.lang.String)
setParanoid(boolean)
Exceptions:
IllegalArgumentExceptionParsing the address failed.

Definition at line 256 of file WebServer.java.

boolean org.apache.xmlrpc.webserver.WebServer.allowConnection ( Socket  s) [inline, protected]

Checks incoming connections to see if they should be allowed. If not in paranoid mode, always returns true.

Parameters:
sThe socket to inspect.
Returns:
Whether the connection should be allowed.

Definition at line 280 of file WebServer.java.

ServerSocket org.apache.xmlrpc.webserver.WebServer.createServerSocket ( int  pPort,
int  backlog,
InetAddress  addr 
) throws IOException [inline, protected]

Factory method to manufacture the server socket. Useful as a hook method for subclasses to override when they desire different flavor of socket (i.e. a SSLServerSocket).

Parameters:
pPortPort number; 0 for a random port, choosen by the operating system.
backlog
addrIf null, binds to INADDR_ANY, meaning that all network interfaces on a multi-homed host will be listening.
Exceptions:
IOExceptionError creating listener socket.

Definition at line 162 of file WebServer.java.

void org.apache.xmlrpc.webserver.WebServer.denyClient ( String  pAddress) [inline]

Add an IP address to the list of denied clients. The parameter can contain '*' as wildcard character, e.g. "192.168.*.*". You must call setParanoid(true) in order for this to have any effect.

Parameters:
pAddressThe IP address being disabled.
See also:
acceptClient(java.lang.String)
setParanoid(boolean)
Exceptions:
IllegalArgumentExceptionParsing the address failed.

Definition at line 269 of file WebServer.java.

Returns the port, on which the web server is running. This method may be invoked after start() only.

Returns:
Servers port number

Definition at line 396 of file WebServer.java.

Returns the org.apache.xmlrpc.server.XmlRpcServer.

Returns:
The server object.

Definition at line 416 of file WebServer.java.

boolean org.apache.xmlrpc.webserver.WebServer.isParanoid ( ) [inline, protected]

Returns the client filtering state.

Returns:
True, if client filtering is enabled, false otherwise.
See also:
acceptClient(java.lang.String)
denyClient(java.lang.String)

Definition at line 244 of file WebServer.java.

void org.apache.xmlrpc.webserver.WebServer.log ( Throwable  pError) [inline]

Logs an error.

Parameters:
pErrorThe error being logged.

Definition at line 401 of file WebServer.java.

void org.apache.xmlrpc.webserver.WebServer.log ( String  pMessage) [inline]

Logs a message.

Parameters:
pMessageThe being logged.

Definition at line 409 of file WebServer.java.

ThreadPool.Task org.apache.xmlrpc.webserver.WebServer.newTask ( WebServer  pServer,
XmlRpcStreamServer  pXmlRpcServer,
Socket  pSocket 
) throws IOException [inline, protected]

Definition at line 304 of file WebServer.java.

Definition at line 369 of file WebServer.java.

Definition at line 120 of file WebServer.java.

Listens for client requests until stopped. Call start() to invoke this method, and shutdown() to break out of it.

Exceptions:
RuntimeExceptionGenerally caused by either an UnknownHostException or BindException with the vanilla web server.
See also:
start()
shutdown()

Definition at line 321 of file WebServer.java.

void org.apache.xmlrpc.webserver.WebServer.setParanoid ( boolean  pParanoid) [inline]

Switch client filtering on/off.

Parameters:
pParanoidTrue to enable filtering, false otherwise.
See also:
acceptClient(java.lang.String)
denyClient(java.lang.String)

Definition at line 234 of file WebServer.java.

synchronized void org.apache.xmlrpc.webserver.WebServer.setupServerSocket ( int  backlog) throws IOException [inline, private]

Initializes this server's listener socket with the specified attributes, assuring that a socket timeout has been set. The createServerSocket(int, int, InetAddress) method can be overridden to change the flavor of socket used.

See also:
createServerSocket(int, int, InetAddress)

Definition at line 175 of file WebServer.java.

synchronized void org.apache.xmlrpc.webserver.WebServer.shutdown ( ) [inline]

Stop listening on the server port. Shutting down our listener effectively breaks it out of its run() loop.

See also:
run()

Definition at line 380 of file WebServer.java.

void org.apache.xmlrpc.webserver.WebServer.start ( ) throws IOException [inline]

Spawns a new thread which binds this server to the port it's configured to accept connections on.

See also:
run()
Exceptions:
IOExceptionBinding the server socket failed.

Definition at line 217 of file WebServer.java.


Member Data Documentation

final List org.apache.xmlrpc.webserver.WebServer.accept = new ArrayList() [protected]

Definition at line 116 of file WebServer.java.

Definition at line 125 of file WebServer.java.

final List org.apache.xmlrpc.webserver.WebServer.deny = new ArrayList() [protected]

Definition at line 117 of file WebServer.java.

final String org.apache.xmlrpc.webserver.WebServer.HTTP_11 = "HTTP/1.1" [static, package]

Definition at line 130 of file WebServer.java.

Definition at line 114 of file WebServer.java.

Definition at line 128 of file WebServer.java.

Definition at line 115 of file WebServer.java.

Definition at line 126 of file WebServer.java.

Definition at line 118 of file WebServer.java.

Definition at line 113 of file WebServer.java.


The documentation for this class was generated from the following file:


rosjava_core
Author(s):
autogenerated on Wed Aug 26 2015 16:06:50