json-rpc-java/svn/trunk * A user derived bridge implementation should be able to control access to which classes can be serialized. The JSONRPCBridge.resolveClass method has been made protected so that a client application can derive it to control access. -- Michael Clark * Switch from java.util logging to SLF4J. (the simple logging facade for java--see http://slf4j.org) so that json-rpc-java can be easily integrated with projects that use other java logging systems. The test webapp still uses java.util logging (although it's now via SLF4J.) The json-rpc-java library now has a dependency on slf4j. * Added conveniance target 'uninstall' that removes .war and the expanded .war folder from tomcat. -- Arthur Blake * Add asynchrounous support to the constructor JSONRpcClient constructor. Previously the constructor would make a synchronous call to system.listmethods. Now if the constructor is called with a function as the first argument, it will construct the proxy asynchrously, calling the function when this is done. -- Michael Clark * Add ExceptionTransformer interface and interface to JSONRPCBridge to transform exception objects returned to the client. -- Rhys Yarranton, rhys dot yarranton at albertasolutions dot com * Make Hello test page use async callback. * Modify unit test page to allow running a single test by clicking on a link. * Add HttpServletResponseLocalArgResolver and pass HttpServletResponse object into calls so that exported methods can get access to it. * Add RawJSONObjectSerializer and RawJSONArraySerializer to allow methods to return hand constructed JSON object representations * Formatting cleanups in example Dictionary client -- Michael Clark json-rpc-java-cvs * Add a new overloaded registerObject call that allows the caller to specify the class/interface to be used for exporting methods on the object (exported methods are restricted to just the interface class). -- Ian Sollars, ian at sollars dot gmail dot com * Add back ObjectInstance wrapper class to allow us to store the interface to be used to export for the associated object. -- Michael Clark * License changed from LGPL to Apache License, Version 2.0 after approval from all authors/contributors * Update JSP pages to use common header and footer and new style * Remove eval function from test.jsp * Simplify async callback in unit test -- Michael Clark * Allow derived versions of JSONRPCServlet to override a findBridge method to provide a custom method of locating the JSONRPCBridge object. -- Todd Lindner, tlindner at dynax dot com * Add java.math.BigDecimal marshalling/unmarshalling support to NumberSerializer. -- Michael Clark * Fix JavaScript client failure the HTTP authentication in Firefox -- Mark F Murphy, markm at tyrell dot com * Remove auto-creation of session specific bridge and associated options from JSONRPCServlet (ie. default is to invoke against objects in the global bridge). Updated manual, tutorial, JSONRPCServlet and JSONRPCBridge docs to reflect this. * Made JSONSerializer instance global to reduce memory used by session specific bridges. The global JSONSerializer instance can be changed or added to, to allow for custom Serializers. * Remove keepalive disable option from JSONRPCServlet as the Connection: keepalive header was causing problems and is not required for keepalives in all modern browsers. * Remove enableReferences from API, references are enabled when this first call to registerReference or registerCallableReference. This keeps the bridge state smaller if references are not enabled. * Move most bridge state data into a new class JSONRPCBridgeState * Remove ObjectInstance inner class from JSONRPCBridge and change code to use Object directly in the objectMap * Remove reference registrations from unit.jsp as they are not used * Add more Java docs to various classes and methods. * Move reflection related code out of JSONRPCBridge and into com.metaparadigm.jsonrpc.reflect.ClassAnalyzer. * Move inner classes ClassData and MethodKey from JSONRPCBridge into com.metaparadigm.jsonrpc.reflect package. * Move inner class CallbackData from JSONRPCBridge into com.metaparadigm.jsonrpc.callback.CallbackData. * Move callback implementation details from JSONRPCBridge into: com.metaparadigm.jsonrpc.callback.CallbackController. * Move inner class CallbackData from JSONRPCBridge into com.metaparadigm.jsonrpc.callback.CallbackData. * Move local argument processing out of JSONRPCBridge into com.metaparadigm.jsonrpc.localarg.LocalArgController. * Move localarg implementations (HttpSession, etc) into: com.metaparadigm.jsonrpc.localarg.impl. * Add a simple perl script utility for making a smaller JS file. * Add unregisterClass, unregisterObject, lookupClass and lookupObject methods to JSONRPCBridge to enable external lifecycle management of exported classes and objects * Package reorginisation. New packages: com.metaparadigm.jsonrpc.serializer com.metaparadigm.jsonrpc.serializer.impl com.metaparadigm.jsonrpc.localarg * Source code formatting changes for Eclipse. No longer have the tab issue with emacs when used in an editor with tabstop=4. The source code was previously formatted with tabstop=8 with 4 char indents and space stuffing that caused problems with Eclipse users. -- Michael Clark json-rpc-java-1.0rc2 Summary of changes * Improved documentation. More Javadoc comments and addition on documentation on References and LocalArgResolvers to the manual. * JSON-RPC JavaScript Client bugfixes, changes to comments and addition of trailing ; to function assignments to allow usage or certain script compressors. * Fix to keepalive handling. * Implement Serializable on all JSONRPCBridge related objects to enable sessions to be persistent against tomcat restarts and clustering should now work. * Add ErrorInvocationCallback interface to allow callbacks to get notification of server side errors. Changes since 1.0rc1 * Created branch in CVS. To check out 1.0 branch use: cvs update -r R1_0_BRANCH * Add documentation on References, Callable References and LocalArgResolver to the manual * More Javadoc updates * Change // comments to /* */ comments in jsonrpc client * Add ; to end of function variable assignments in jsonrpc client * Return http object to pool if we get a connection error * Fix put in poolReturnHTTPRequest where we pushed a deleted http object onto the spare array * Implement Serializable on more classes to make Session persistence and clustering possible * Don't add 'Connection: keep-alive' header in JSONRPCServlet as this is not actually required for keepalive connections with HTTP/1.1 clients (ie. any browser that implements XMLHttpRequestObject). This header was perhaps a cause for the subtle and infrequent breakage seen with certain connector, webserver and browser combinations causing empty bodies to be sent to the server. Content-length is all that is required for keepalive connections to work with HTTP/1.1 clients - this header can still be disabled with the keepalive=0 servlet param although many containers will still maintain keepalive connections by reverting to chunked encoding. -- Michael Clark * Add more Javadoc comments to InvocationCallback interface * Add ErrorInvocationCallback interface to allow callback functions to be notified of exceptions generated while invoking methods on exported objects -- Brett Connor, connorb at axxia dot com -- Michael Clark * Make JSON-RPC JavaScript client throw Exception consistent with other client exceptions if there is a connection error -- Krzysztof Ogrodnik, OgrodnikK at axxia dot com -- Michael Clark * Add additional Javadoc comments to LocalArgResolver interfaces and associated classes * Fix bug in JSONRPC JavaScript client where we forget to set async timeout handler variable causing the async handler function to get called back multiple times with no work to be done * Implement Serializable on JSONRPCBridge and mark a few fields as transient that aren't required during serialization -- Michael Clark json-rpc-java-1.0rc1 Summary of changes * Ability to handle generic Object and Interface method signatures. * Closer conformance with the JSON-RPC specification. * Ability to cancel async requests. * Now sends Dates in milliseconds. Upgrade notes * Code that unmarshalls Dates will need to be changed from: new Date(object.time*1000) to: new Date(object.time) * Backwards compatibility code with 0.7 release has been removed. * CallableReference has been changed on the wire so if these are used then then both the client and server must be 1.0rc1. Changes since 0.9 * Avoid memory leak on IE in jsonrpc JS client by removing callback function once we have recieved the callback -- Evan Leonard, evan at mindreef dot com * Allowed BooleanSerializer to accept JSONObjects of type string, if they can be converted to a Boolean. -- Ryan Gates ryan.gates at gmail dot com * Fetching servlet config at init time instead of on each request * Add servlet config option 'keepalive' when set to 0 disables keepalives -- Michael Clark * Fix JSONRPCResult to use Throwable instead of Exception so all kinds of Throwable types can be handled -- Igor Bernstein, happycrappy at gmail dot com * Handle case where a method generic signature such as Object is overloaded with a more specific signature. Previously the method matching code would pick an arbitrary method. Now the method with the specific matching class signature will be chosen. * Fix date value truncation introduced when converting Date marshalling format into milliseconds. -- Nicola Piccinini, pic at mayatecnologie dot com * Fix serializer selection logic when passing a hinted JS object into a Java method with either an interface or Object signature. Previously objects unmarshalled by the BeanSerializer had to be passed into a method with the concrete class signature. Now Beans with strong type information (type hints i.e. "javaClass" property) can be passed into methods with Interfaces and Object signatures. * Send Dates in milliseconds - not seconds as before (this didn't really make any sense as both Java and JavaScript natively store Dates internally in milliseconds). Code that unmarshalls Dates currently just sees a plain JavaScript object and access the 'time' field, this code will need to be changed from: new Date(object.time*1000) to the much simpler form: new Date(object.time) * Change jsonrpc.js to set unique id field in request as per JSON-RPC spec * Change JSONRPCBridge to decode id if present and return it in replies. Currently niether the client nor server require the id to be present. This required changes to the protected JSONRPCBridge.call interface to pass in the entire undecoded JSON-RPC request object. This had the effect of simplifying the JSONRPCServlet code which is a good thing. * No longer add objectID attribute to requests made on CallableReferences. This was a break from JSON-RPC protocol. Now we encode the objectID into the method in the form ".obj#.methodName" so our requests are now completely compatible with JSON-RPC spec. * Remove backwards compatibility with 0.7 client/server. This served its purpose as easing upgrades between 0.7 and 0.8 releases but now was just adding to the complexity of the code. * Made JSONRPCBridge.call public instead of protected. * Made JSONRPCResult public and added accessor functions for its properties. * Changed JSONRpcClient JS client instance method names use _ prefix to avoid the possibility of clashing with dynamic proxy methods created from associated Java server side objects (these methods were never exposed as part of a public API but there was the possibility that they may clash). * Added JSONRpcClient.cancelRequest(id) static method to the JS client that will cancel an inflight async call (returns true if it found the request and is able to cancel it). The id is the JSON-RPC request id and is the value returned from the async call when it is submitted. -- Michael Clark json-rpc-java-0.9 (About time for a release release) * Make jsonrpc.js serialize JavaScript Date object as a Java Date by setting the appropriate class hint -- Nicola Piccinini, pic at mayatecnologie dot com * All serializer classes given public access * Modified DateSerializer to accept and convert java.sql.Timestamp and java.sql.Date. * Introduced attribute 'marshallClassHints' in the JSONSerializer class. If set to false, the 'javaClass' JSON hints are not included by serializers. Defaults to true. Modified all serializers to use this setting in JSONSerializer. * Introduced attribute 'marshallNullAttributes' in the JSONSerializer class. If set to false, then any bean field that is null in Java will not serialize the attribute name to the client. Defaults to true. * Exposed getter and setter attributes for the JSONSerializer object in the JSONRPCBridge. * Added constructor to JSONRPCBridge indicating to not register the default serializers in the JSONSerializer. * Allowed NumberSerializer and PrimitiveSerializer to accept JSONObjects of type String, if they can be converted to the appropriate primitive or number. * Allowed StringSerializers to accept JSONObjects of type integer. -- Ryan Gates * Make registerCallback/unregisterCallback non static (again) * Change in JSONRPCBridge.analyzeClass to fix bug with exporting of inherited methods exposed methods of Object which is not a good idea so we exlucde these now. * Add InvocationCallback test case to Test.java and test.js * Add LocalArgResolver test case to Test.java and test.js. The simple test allows set the debug flag on the JSONRPCBridge instance * Complete LocalArgResolver implementation * Make methods to register and unregister InvocationCallback and LocalArgResolver static ie. no longer bridge instance specific. * Added methods to unregister InvocationCallback and LocalArgResolver * Change contextClazz arg of registerLocalArgResolver to contextInterface * Fix hash and equals function of CallbackData to allow registering of the same InvocationCallback with multiple contextInterfaces (previously the equals function would have replaced the previous entry if it was registered again with a different contextInterface). * Change name of contextClazz argument of registerCallback to contextInterface and implement the functionality (previously this argument was ignored). This is a step towards allowing implementation of other transports where the context object passed to callbacks may not be HttpServletRequest. * JSONRPCBridge.call now takes an array of context objects * use clazz.getMethods() instead of clazz.getDeclaredMethods() in JSONRPCBridge.analyzeClass to fix bug with exporting of inherited methods * Add debug="true" to javac attributes in build.xml * Try to work out class for arrays in JSONSerializer.getClassFromHint * Fix marshalling and unmarshalling of null bean values * Added configuration for JBoss 3.2.x and JBoxx 4.0.0 to build.xml * Make [Un]MarshallException constructors public * Don't prepend exception.message with the exception type as this can be got with exception.name * ReferenceSerializer uses System.identityHashCode(o) instead of o.hashCode() to avoid possible clashes. * Change debug messages to use java.util.logger.Logging. * Now 'ant docs' builds javadocs for org.json package. * Documentation fix to Manual for Set type mapping. * Convert BeanSerializer state over to new SerializerState interface and change it to throw exception when encountering circular references to match documentated behaviour. * New SerialiazerState object added and passed as a stack variable to allow Serializers to keep state for the current serialization as Serializer instance variables can't be used for this due to concurrency issues. * Split serializer code out of JSONRPBBridge and into new JSONSerializer class * Make Serializer interface public. Subject to change until 0.9 is released. * Don't register ReferenceSerializer by default. Application now needs to call JSONRPCBridge.enablesReferences(). This is subject to change before release of 0.9 (perhaps automatically registered in session bridges) * Instantiate serializers in global bridge to allow stateless use when no per session bridge is used. * Fix information leak of protected method names. duh! * Rename JSONRPCCallback to InvocationCallback (trivial code changes required for users of the callback interface). * Add Class contextClazz argument to registerCallback so only the specific type of context object is passed to the callback (allows for easier implementation of transport specific callbacks). Need to implement (argument is currently ignored as we so far only have one type of context object passed through 'HttpServletRequest') * Add LocalArgResolver interface and associated registerLocalArgResolver method to JSONRPCBridge and Java Docs (currently unimplemented) -- Michael Clark * Fix logic bug in JSONSerializer when marshalling null with debug enabled -- Spotted by Nicola Piccinini, pic at mayatecnologie dot com * Add servlet config option to disable auto creation of per session bridge. Completely stateless usage should now be possible. -- David Croft, davidc at sargasso dot net * Fix typo in unit.js -- Hendra, hendra at ofs dot edu dot sg * Fix JSONArray join so that "null" is used for null objects rather an empty string * Use System.identityHashCode(o) instead of o.hashCode for circular reference check in BeanSerializer -- Suggested by Christopher Taylor, cstaylor at nanshu dot com * Change type of servlet transport context object used for JSONRPCCallback from HttpSession to HttpServletRequest (to make stateless usage possible). This breaks backwards compatibility for implementors using the callback interface although required changes are trivial. -- Suggested by David Croft, davidc at sargasso dot net * Fix typo in poolReturnHTTPRequest(http) delete http instead of delete htpp -- Evan Leonard, evan at mindreef dot com json-rpc-java-0.8 (Valentine Rooster) Summary of changes * Unicode and other character set support * Asynchronous support * Unicode test suite * Regression test suite * Dictionary demo * Browser Compatiblity database * Hello World sample app * Tutorial and Manual updates * Protocol sync with the JSON-RPC spec Upgrade notes * A change to the JSON-RPC protocol was introduced in this release. * Please upgrade both JavaScript client (jsonrpc.js) and Java server code (jsonrpc.jar) in your applications. * Backwards compatibility code has been added to the server so it will still work with the 0.7 client (although upgrade is recommended). Changes since 0.7 * Add exception documentation to the manual * Add exception error code definitions to JSON-RPC JavaScript client * Restore capability to access remote Java stack trace for remotely thrown exceptions (these were previously in the result from the server but not retained in the JavaScript side exception object). The remote exception type can be retrieved in e.name the message in e.message (both as per JavaScript Error objects). The Java stack trace in e.javaStack. See test.jsp Exception test example. * Add instructions to Tutorial for building and installing from source. * Big change in the way we handle unicode data. - The setCharset call has been removed from JSONRPCBridge as it is no longer required. - All unicode data between the client and server is now escaped using JSON unicode escape sequences so the communication is ASCII clean. - This is a little less efficient although this must be done due to bugs in Safari and Konqueror where they don't honour the encoding in the Content-Type header on recieved data from the server. Data is also escaped in the client to server direction to avoid potentical problems with browsers (that send data in the charset of the window, as the charset cannot be set on some XMLHttpRequest object implementations) and to be symetric. - These changes make the JSON-RPC-Java server and client charset clean. - The server will still accept non escaped unicode data correctly if the charset in the request is set or if not provided defaults to UTF-8 (which appears to be what most XMLHttpRequest object implementations do). This means the server should remain compatible with other JSON-RPC clients such as jsolait. * Add test cases for string and control character escaping * Add back compat code to the JSONRPCServlet for handling <= 0.7 clients * Change JSON marshalling in JavaScript client to use global toJSON function instead of extending various core object prototypes with toJSON methods. This resolves problems with code that does for(var x in obj) seeing the toJSON function and not expecting it. * Change to String marshalling in JSONObject to unicode escape all non ASCII character (>= 0x80) - this fixes Safari and Konqueror whose XMLHttpRequest ignores character encodings so the UTF-8 stream isn't decoded to JavaScripts native UTF-16 (this is a workaround until a better solution is found) * Added unicode test demo which sends and recieves unicode data * Sync JSONObject and JSONArray with json.org changes * Added Browser compatibility database that dynamically tests browsers hitting the page for JSON-RPC capability and records the results * Added new Hello demo showing simplest usage of JSON-RPC-Java * Added new Unit Test that supports profiling and both synchronous and asynchronous testing of various JSON-RPC types * Add profiling support for async requests. A third argument is passed to callbacks if the global flag JSONRpcClient.profile_async == true. The profile object contains 4 fields each with a Date objects as the value: "submit" - when the request was submitted, "start" - when the HTTP request was started, "end" - when the HTTP request completed, "dispatch" - when the result was dispatched to the callback. * Added ability to override toplevel exception handler for cases where there is an uncaught exception in callback functions. eq. JSONRpcClient.toplevel_ex_handler = function(e) { myAlert(e); } * Fix bug in Date marshalling (missing return). Dates are presently marshalled as an Integer in milliseconds (valueOf). * Added Test cases for Float, Double, Long and Integer * Fix bug in JSONObject with marshalling of Float objects * Fix unmarshalling of number object types (Byte, Short, Integer, Long, ...) * Modify build.xml so it works with both newer and older versions of the Jasper2 compiler. Due to changes in semantics of the outputDir attribute, the precompiled JSP now are unpackaged. * Improved error handling in JavaScript JSON-RPC client. * Fixed information leak bug in JSONRPCBridge where private method names of exported objects were showing to clients (although not callable) * Set encoding on JSPs using <%@ page contentType="text/html; charset=UTF-8"%> instead of to workaround tomcat 5.5 forcing a default encoding of ISO-8859-1 overriding the meta tag * Workaround another Opera 8 Beta problem with Content-type headers * Add a simple scheduler for async requests and responses using setTimeout callbacks to make sure requests are not submitted from callback context and to allow control of number of concurrent requests * Add a second argument to JavaScript async callbacks for passing exception information ie. callback(result, null) and callback(null, exception) * Added Dictionary lookup demo - A simple server side Java DICT protocol (RFC2229) client that can make queries against a local dict server, and exposes its API to a JavaScript/DHTML dictionary lookup GUI. * Add Content-Length and Connection: keep-alive headers in JSONRPCServlet * Set charset on all pages to UTF-8 * Use UTF-8 by default for encoding and decoding (can't set charset in Content-type request header with Moz/Firefox) - more testing needed * Servlet decodes using charset in Content-type header (if one exists) otherwise defaults to the charset set on the JSONRPCBridge * Enhance code that fetchs XMLHttpRequestObject with more names for MS XMLHTTP * Change test.jsp to use standard JSP syntax (not XML). * Update khtml patch to version in kdelibs CVS. * Allow specifying the charset to be used for encoding and decoding JSON data to and from the servlet. The charset must be supported by the Java implementation (the mandatory charsets a Java implementation must support are: "US-ASCII", "ISO-8859-1", "UTF-8", "UTF-16BE", "UTF-16LE" and"UTF-16". * Add initial working draft of manual * Add pooling of XMLHttpRequest obejcts to allow multiple outstanding async requests (each async request has its own XMLHttpRequest object) * Add initial async support. Async is enabled by passing a callback function as the first argument to your call. ie. jsonrpc.echo(function (msg) { print(msg); }, "ping"); * Session timeouts result in a 'method not found' due to the object no longer existing in the session. Give a more informative error message * Add support for HTTP authentication to JSON-RPC JavaScript client * Add section to tutorial to show how to use in a servlet -- Michael Clark * Fix txEval value in test.jsp to reflect variable name change in test.js -- Tan Chee Yong, cytan at ofs dot edu dot sg * Fix bug in test.jsp - evalStr should be populated in doEval -- Jay Graves, skabber at gmail dot com * Update protocol to match changes in JSON-RPC specification. 'methodName' -> 'method', 'arguments' -> 'params' -- George White, george at stonehippo dot com * Use try catch to workaround Opera's missing setContentType method instead of useragent test. -- Paul E. Davis, pauledavis at gmail dot com json-rpc-java-0.7 * Fix IE brown paper bag bug. Opera fix in 0.6 broke IE, now look at user agent to make Opera work (without effecting IE). -- Michael Clark json-rpc-java-0.6 * Add more detailed browser support section to documentation * Workaround missing setRequestHeader method of the XMLHttpRequest object in Opera 8 Beta * Add patch and documentation notes on how to resolve POST bug in Konqueror (requires patching kdelibs) * Replace jsolait with lightweight json-rpc JavaScript implementation * Better web navigation for tutorial and demo -- Michael Clark json-rpc-java-0.5 * Fix unmarshalling of generic collection interfaces (List, Map, Set) * Added more details to the tutorial -- Michael Clark * Add test cases for unmarshalling hinted classed into methods with interfaces in their signature * Added circular association detection to BeanSerializer * Added marshalling and unmarshalling implementation to SetSerializer * Added test cases for bean and set to test.js -- Tan Chee Yong, cytan at ofs dot edu dot sg json-rpc-java-0.4 * Documentation updates * Add boolean to list of supported primitive types * Specify Safari supported version as 1.2 * Added BooleanSerializer to add missing support for boolean types * Added boolean array support to ArraySerializer * Added test cases for booleans and boolean arrays to test.js * Fixed bug with calling void methods or methods that return null * Remove stack trace from Exception message objects returned and instead place in a field 'trace' - this is not part of the JSON-RPC spec but it helps me * Add JSONRPCCallback interface and associated registerCallback method to JSONRPCBridge to allow registration of a callback that is called before and after method invocation. * Callback is called with the method arguments and result in preInvoke and postInvoke respectively. * In the case of JSON-RPC over HTTP with the JSONRPCServlet, the HttpSession object is passed as the context object to the callback which allows you to poke around in the session to perform such things as JAAS authentication, ie. login on preInvoke and logout on postInvoke. -- Michael Clark json-rpc-java-0.3 * Intial public release * Renamed attributes in private JSON-RPC-Java protocol additions * object_id => objectID * json_type => JSONRPCType * java_class => javaClass * Changes to make requests on CallableReferences transparent. * Added objectID field to the JSON-RPC protocol message for invocations on methods of a CallableReference * Removed temporary hack to encode objectID in the URL * Automatic JSONRPCBridge creation in servlet if a bridge doesn't already exist in the HttpSession. Documentation changes to reflect this * Global bridge is now just a container for global registration of Classes and objects. * Moved Serializers out of Global bridge which now has no serializers and into session speciifc bridge instance. * No longer special case for per-bridge ReferenceSerializer as all serializers are registered in a session specific bridge instance. * References are always created in the session specific bridge (which allows them to be garbage collected when the session expires) * Moved reference maps from ReferenceSerializer into bridge. -- Michael Clark json-rpc-java-0.2 * First working version posted to json-rpc mailing list -- Michael Clark