Simple JSON-RPC updated to 1.0.0
Simple JSON-RPC has been updated to 1.0.0. This new version includes a brand new event messaging system making it possible for classes to react to events generated by the Simple JSON-RPC framework.
Through simple event messaging, your RPC classes are now able to react to and even interact with servlet configuration, context, request, and response objects. To use this facility your class needs to extend the new JSONRPCEventListener interface and implement the messageReceived method, accepting one argument of the JSONRPCMessageEvent type.
Here is an example of how a class could implement a Simple JSON-RPC event listener:
public void messageReceived(JSONRPCMessageEvent me) {
switch(me.message().getCode()) {
case JSONRPCMessage.INIT:
config = me.message().getServletConfig();
break;
case JSONRPCMessage.BEFOREREQUEST:
request = me.message().getRequest();
session = request.getSession(true);
break;
case JSONRPCMessage.BEFORERESPONSE:
response = me.message().getHttpResponse();
response.setContentType("text/html");
break;
case JSONRPCMessage.AFTERRESPONSE:
lastresponse = me.message().getRPCResponse();
break;
}
}
This new feature should also make it easier to implement solutions that use sessions. This should also make it possible for classes to react to the output of other classes, including errors.