0 Replies Latest reply on Jan 21, 2005 7:38 PM by Michael Clark

    JavaScript to Java remote scripting

    Michael Clark Newbie

      Hi Folks,

      Thought you may be interested in my project "JSON-RPC-Java" which enables simple JavaScript to Java remote scripting using JBoss (tomcat):


      Feedback, testing, contributions much appreciated.


      IntroductionJSON-RPC-Java is a key piece of infrastructure that allows JavaScript DHTML web applications to call remote methods in a Java Application Server (remote scripting) without the need for page reloading (as is the case with the vast majority of current web applications). It enables a new breed of fast and highly dynamic enterprise Java web applications.JSON (JavaScript Object Notation) is a lightweight data-interchange format with language bindings for C, C++, C#, Java, JavaScript, Perl, TCL and others.JSON-RPC is a simple remote procedure call protocol similar to XML-RPC although it uses the lightweight JSON format instead of XML.JSON-RPC-Java is a Java implementation of the JSON-RPC protocol.JSON-RPC-Java OverviewJSON-RPC-Java is a dynamic JSON-RPC to Java ORB (Object Request Broker) that allows you to transparently call server-side Java code from JavaScript. It is designed to run in a Servlet container such as Tomcat and can be used with JBoss to allow calling of EJB methods from within a JavaScript DHTML web application.Minimal or zero changes are necessary to existing server-side Java code to allow calling from JavaScript (such as the marshalling and unmarshalling of special types) as JSON-RPC-Java dynamically maps JavaScript objects to and from Java objects using Java reflection. JSON-RPC-Java also allows simple exporting of Java objects by reflection on their method signatures (a single line of code is required to provide access to a Java object).JSON-RPC-Java currently supports transparent marshalling and unmarshalling of the following types:Primitive types (int, long, short, byte, boolean, char, float, double)Numbers (Float, Integer, etc...), Strings, Char and Byte arraysJava Beans (any Object with set and get methods)Arrays of primitive types, Strings, Numbers, Collections and Java BeansExceptions (although type information isn't currently preserved)Concrete and abstract collection types:List, ArrayList, LinkedList, and VectorMap, HashMap, TreeMap, and LinkedHashMapSet, HashSet, TreeSet, and LinkedHashSetDictionary, HashtableAny arbitrary nested combination of the above (excluding circular references)JSON-RPC-Java has some basic ORB (Object Request Broker) functionality with an API to register Java classes as:References - Objects of classes registered as References will be returned as opaque reference objects to JavaScript that when passed to succussive Java method calls will then be reassociated back to the original Java object (great for security sensitive objects).Callable References - Objects of classes registered as Callable References will return dynamic proxies to allow invocation on the particular object instance in the server-side Java. There are changes to the included jsolait json-rpc client for dynamic proxy creation support.JSON-RPC-Java is intended for use in next generation Java / DHTML / JavaScript enterprise web applications to provide a similar level of speed and interactivity to that of typical standalone client server GUI applications.