public class DispatchHandler extends GenericHandler
true
, then the exchange
is dispatched to the associated handler with no further processing.
If no condition yields true
then the handler will throw a HandlerException
.
Therefore, it's advisable to have a single "default" handler at the end of the list
with no condition (unconditional) to handle otherwise un-dispatched requests.
Modifier and Type | Class and Description |
---|---|
static class |
DispatchHandler.Heaplet
Creates and initializes a dispatch handler in a heap environment.
|
logger, storage
Constructor and Description |
---|
DispatchHandler() |
Modifier and Type | Method and Description |
---|---|
DispatchHandler |
addBinding(Expression condition,
Handler handler,
URI baseURI)
Binds an expression to the current handler to dispatch to.
|
DispatchHandler |
addUnconditionalBinding(Handler handler,
URI baseURI)
Adds an unconditional bindings to the handler.
|
void |
handle(Exchange exchange)
Called to request the handler respond to the request.
|
public DispatchHandler()
public DispatchHandler addBinding(Expression condition, Handler handler, URI baseURI)
condition
- Condition to evaluate to determine if associated handler should be dispatched to. If omitted, then
dispatch is unconditional.handler
- The name of the handler heap object to dispatch to if the associated condition yields true.baseURI
- Overrides the existing request URI, making requests relative to a new base URI. Only scheme, host and
port are used in the supplied URI. Default: leave URI untouched.public DispatchHandler addUnconditionalBinding(Handler handler, URI baseURI)
handler
- The name of the handler heap object to dispatch to if the associated condition yields true.baseURI
- Overrides the existing request URI, making requests relative to a new base URI. Only scheme, host and
port are used in the supplied URI. Default: leave URI untouched.public void handle(Exchange exchange) throws HandlerException, IOException
Handler
A handler that doesn't hand-off an exchange to another handler downstream is responsible for creating the response in the exchange object.
Important note: If an existing response exists in the exchange object
and the handler intends to replace it with its own, it must first check to see if the
existing response has an entity, and if it does, must call its close
method in
order to signal that the processing of the response from a remote server is complete.
exchange
- the exchange containing the request to handle.HandlerException
- if an exception occurs that prevents handling of the request.IOException
- if an I/O exception occurs.Copyright © 2014 ForgeRock AS. All rights reserved.