|
Femto Web Server V1.4-F | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Connection Adapters - network protocol listeners - are used to wire the Femto Web Server to a specific network protocol.
As result of this concept, the further processing of HTTP requests and response is network protocol independent. For example: listening for new HTTPS/SSL client connection instead of listening for a normal TCP/IP connection.
By following this concept consequently it has the impact, that in example the method
HttpRequest.getRemoteAddress() returns a String instead of a java.net.InetAddress.
So if you will find inside this Java Doc Pages an allude of the TCP/IP protocol please consider,
that this is in fact only the most common case - but that theoretically any other network protocol could be used.
If a own connection adapter should be used
it must be configured by calling the method Httpd.setConnectionAdapterClass(java.lang.String) before the Httpd tread starts with run().
If no special connection adapter has been configured, the Femto Web Server uses as default the already implemented connection adapter
HttpdSocketConnectionAdapter.
Httpd deals with connection adapters:
// init adapter
((HttpdConnectionAdapterInterface) connectionAdapterObject).init(httpdProperties);
// server up and ready
Stdout.log("# ... femto web server ready.");
while (!shutdown)
{
try
{
// wait for new client
HttpdConnection connection = ((HttpdConnectionAdapterInterface) connectionAdapterObject).getNextConnection(httpdProperties);
// process http request and response
...
...
}
catch (java.io.InterruptedIOException iex)
{
// normal: so timeout expired - no action
}
catch (IOException ie)
{
Stdout.log("# *** warning: unable process client, connection aborted ***");
Stdout.log("# ", ie);
}
}
Stdout.log("# femto web server shutdown ...");
try { ((HttpdConnectionAdapterInterface) connectionAdapterObject).shutdown(httpdProperties); } catch (Exception e) {}
Httpd.setConnectionAdapterClass(java.lang.String),
HttpdConnection,
HttpdSocketConnectionAdapter| Method Summary | |
HttpdConnection |
getNextConnection(HttpdProperties httpdProperties)
Listens for a new client connection and blocks until a new client connection is made. |
void |
init(HttpdProperties httpdProperties)
Initializes the connection adapter. |
void |
shutdown(HttpdProperties httpdProperties)
Closes the connection adapter. |
| Method Detail |
public void init(HttpdProperties httpdProperties)
throws java.lang.Exception
httpdProperties - read/only access to the Femto Web Server configuration
public HttpdConnection getNextConnection(HttpdProperties httpdProperties)
throws java.lang.Exception
HttpdConnection is given back to the Femto Web Server which
is used to process the HTTP request.
From time to time (1..60 seconds) it would be fine that a java.io.InterruptedIOException is thrown by this method.
Optionally throwing the InterruptedIOException will not abort the Httpd main thread, but enables
the Femto Web Sever to do a graceful shutdown if Httpd.shutdown() is called.
httpdProperties - read/only access to the Femto Web Server configurationHttpdConnection,
Httpd.shutdown(),
Httpd.setConnectionAdapterClass(java.lang.String)
public void shutdown(HttpdProperties httpdProperties)
throws java.lang.Exception
httpdProperties - read/only access to the Femto Web Server configurationHttpd.shutdown()
|
Femto Web Server V1.4-F | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||