Class MultiProtocolRequestHandler
java.lang.Object
net.sf.basedb.clients.jobagent.handlers.MultiProtocolRequestHandler
- All Implemented Interfaces:
RequestHandler
Request handler implementation that forwards all requests to a registered
protocol-specific handler. All unknown protocols are forwarded to a
default request handler. Protocols and their handlers are
registered with
registerProtocols(RequestHandler, String[])
.
An incoming request should be of the form: protocol://additional-info.
Requests for protocols that doesn't have a registered handler and requests
that doesn't follow the above form are forwarded to the default handler.- Since:
- 2.16
- Author:
- Nicklas
- Last modified
- $Date: 2014-04-09 14:21:20 +0200 (on, 09 apr 2014) $
-
Field Summary
Modifier and TypeFieldDescriptionprivate final Agent
private final RequestHandler
private final Map<String,
RequestHandler> private boolean
private static final Logger
Logger. -
Constructor Summary
ConstructorDescriptionMultiProtocolRequestHandler
(Agent agent, RequestHandler defaultHandler) Create a new multi-protocol request handler. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close this handler.Handle a command that was sent by an incoming request.boolean
isClosed()
If the request handler is closed, it will igore all method calls.void
registerProtocols
(RequestHandler handler, String... protocols) Register a handler for one or more protocols.void
unregisterProtocols
(String... protocols) Unregister a handler for one or more protocols.
-
Field Details
-
log
Logger. -
agent
-
defaultHandler
-
handlers
-
isClosed
private boolean isClosed
-
-
Constructor Details
-
MultiProtocolRequestHandler
Create a new multi-protocol request handler.- Parameters:
defaultHandler
- The default handler that should receive all requests that hasn't a registered specific handler
-
-
Method Details
-
handleCmd
Description copied from interface:RequestHandler
Handle a command that was sent by an incoming request.- Specified by:
handleCmd
in interfaceRequestHandler
- Parameters:
socket
- The socket that is handling the communication with the remote clientcmd
- The command- Returns:
- The answer
-
registerProtocols
Register a handler for one or more protocols. Ignored if this request handler has been closed.- Parameters:
handler
- The handlerprotocols
- An array with protocol names
-
unregisterProtocols
Unregister a handler for one or more protocols. Ignored if this request handler has been closed.- Parameters:
protocols
- An array with protocol names- Since:
- 2.16
-
close
public void close()Close this handler. It can't be used again. -
isClosed
public boolean isClosed()If the request handler is closed, it will igore all method calls.
-