|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.thetransactioncompany.jsonrpc2.server.Dispatcher
public class Dispatcher
Dispatcher for JSON-RPC 2.0 requests and notifications.
Use the register() methods to add a request or notification
handler for an RPC method.
Use the dispatch() methods to have an incoming request or
notification processed by the matching handler.
The reportProcTime() method enables reporting of request
processing time (in microseconds) by appending a non-standard "xProcTime"
attribute to the resulting JSON-RPC 2.0 response message.
Example:
{
"result" : "xyz",
"id" : 1,
"jsonrpc" : "2.0",
"xProcTime" : "189 us"
}
| Constructor Summary | |
|---|---|
Dispatcher()
Creates a new dispatcher with no registered handlers. |
|
| Method Summary | |
|---|---|
void |
dispatch(com.thetransactioncompany.jsonrpc2.JSONRPC2Notification notification,
MessageContext notificationCtx)
Dispatches the specified JSON-RPC 2.0 notification to the appropriate handler for processing. |
com.thetransactioncompany.jsonrpc2.JSONRPC2Response |
dispatch(com.thetransactioncompany.jsonrpc2.JSONRPC2Request request,
MessageContext requestCtx)
Dispatches the specified JSON-RPC 2.0 request to the appropriate handler for processing and returns the response. |
NotificationHandler |
getNotificationHandler(java.lang.String notificationName)
Gets the handler for the specified JSON-RPC 2.0 notification name. |
RequestHandler |
getRequestHandler(java.lang.String requestName)
Gets the handler for the specified JSON-RPC 2.0 request name. |
java.lang.String[] |
handledNotifications()
Returns the registered notification names. |
java.lang.String[] |
handledRequests()
Returns the registered request names. |
void |
register(NotificationHandler handler)
Registers a new JSON-RPC 2.0 notification handler. |
void |
register(RequestHandler handler)
Registers a new JSON-RPC 2.0 request handler. |
void |
reportProcTime(boolean enable)
Controls reporting of request processing time by appending a non-standard "xProcTime" attribute to the JSON-RPC 2.0 response. |
boolean |
reportsProcTime()
Returns true if reporting of request processing time is
enabled. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Dispatcher()
| Method Detail |
|---|
public void register(RequestHandler handler)
handler - The request handler to register.
java.lang.IllegalArgumentException - On attempting to register a handler
that duplicates an existing request
name.public void register(NotificationHandler handler)
handler - The notification handler to register.
java.lang.IllegalArgumentException - On attempting to register a handler
that duplicates an existing
notification name.public java.lang.String[] handledRequests()
public java.lang.String[] handledNotifications()
public RequestHandler getRequestHandler(java.lang.String requestName)
requestName - The request name to lookup.
null if none
was found.public NotificationHandler getNotificationHandler(java.lang.String notificationName)
notificationName - The notification name to lookup.
null if
none was found.
public com.thetransactioncompany.jsonrpc2.JSONRPC2Response dispatch(com.thetransactioncompany.jsonrpc2.JSONRPC2Request request,
MessageContext requestCtx)
request - The JSON-RPC 2.0 request to dispatch for
processing.requestCtx - Context information about the request, may be
null if undefined.
public void dispatch(com.thetransactioncompany.jsonrpc2.JSONRPC2Notification notification,
MessageContext notificationCtx)
Note that JSON-RPC 2.0 notifications don't produce a response!
notification - The JSON-RPC 2.0 notification to dispatch for
processing.notificationCtx - Context information about the notification,
may be null if undefined.public void reportProcTime(boolean enable)
enable - true to enable proccessing time reporting,
false to disable it.public boolean reportsProcTime()
true if reporting of request processing time is
enabled. See the reportProcTime description for more
information.
true if reporting of request processing time is
enabled, else false.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||