|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsimple.http.serve.DomainHandler
public class DomainHandler
This class is used to route requests to the proper host. This
allows the virtual host facility to be achieved with a set of
ProtocolHandler
's. This will ensure that if requests
are issued, the host header is checked to see what domain it has
and dispatches it to the correct ProtocolHandler
.
Also if there is a Host header with an unknown domain name then
the default ProtocolHandler
is given the request.
In this case the default protocol handler chosen may be an error
handler. However to avoid this the domain multiplexer may be
wrapped in another ProtocolHandler
implementation
to handle these requests before the DomainHandler
sees them.
Constructor Summary | |
---|---|
DomainHandler(ProtocolHandler primary)
Constructor for the DomainHandler . |
Method Summary | |
---|---|
boolean |
contains(java.lang.String pattern)
This is used to lookup a certain pattern match to see if the DomainHandler has it. |
void |
handle(Request req,
Response resp)
This is used to route the request to the correct handler. |
void |
insert(ProtocolHandler handler,
java.lang.String pattern)
This will insert a new ProtocolHandler for the
specified pattern. |
ProtocolHandler |
lookup(java.lang.String domain)
Used to lookup a specific ProtocolHandler
for a specific domain. |
void |
remove(java.lang.String pattern)
This will remove any ProtocolHandler for the
specified pattern match. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DomainHandler(ProtocolHandler primary)
DomainHandler
. This takes
a default ProtocolHandler
. Which enables this to
accommodate HTTP/1.0 clients to interact with the server without
using the Host header. This default ProtocolHandler
can also be an error generator that will respond with a 400, Bad
Request, status code as suggested by RFC 2616 section 14.23 for
HTTP/1.1 clients without the Host header.
This ensures that there will be very little performance loss when
there are several ProtocolHandler
's being multiplexed
using this ProtocolHandler
implementation.
primary
- the default ProtocolHandler
Method Detail |
---|
public void handle(Request req, Response resp)
For compatibility with HTTP/1.0 clients that do not support the
Host header this delegates the processing of requests without
the Host header to a default ProtocolHandler
.
handle
in interface ProtocolHandler
req
- this is the Request
that was made from
the http clientresp
- this is the Response
that will be given
to the clientpublic void insert(ProtocolHandler handler, java.lang.String pattern)
ProtocolHandler
for the
specified pattern. The new ProtocolHandler
will
manage the requests that have the host header with the domain
name part equal to the domain given.
pattern
- the pattern of the virtual host to be addedhandler
- the ProtocolHandler
that will
process requestspublic void remove(java.lang.String pattern)
ProtocolHandler
for the
specified pattern match. Further Request
's to
this domain will not be processed.
pattern
- this is the name of the handler to removepublic boolean contains(java.lang.String pattern)
DomainHandler
has it. If this returns
true then the pattern exists.
pattern
- the pattern being checked for in this
public ProtocolHandler lookup(java.lang.String domain)
ProtocolHandler
for a specific domain. This allows the user to take the
ProtocolHandler
objects from this for some
modification, or to use it.
domain
- the host domain name for this handler
ProtocolHandler
for the domain
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |