commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Kersten" <Martin.Kers...@Student.Uni-Magdeburg.DE>
Subject Simple RPC Calls
Date Fri, 16 Apr 2004 13:02:50 GMT
Hi there,

   I am just a student from Germany (Magdeburg) and I have 
written a very handy remote procedure call implementation. It 
will replace a xml-solution currently connecting a server and
an administrational GUI application over here.

It turned out to be very small (about 6KB byte-code on 
client side) and it's really simple.

I googled the net before to find anything similar and all I've
found was RMI, Hessian and Burlap (+SOAP and CORBA
solutions). RMI tend to be overdoing (registery, stub creation 
etc) and Hessian and Burlap seam not to allow overloading.

So if I havn't missed any proper solution, I would like to add
the little solution to the community reprosity. 

The service interface is similar to Hessian but more 
lightweight (in my oppinion). The main scenario is using
a Servlet implementing an interface, creating a proxy on
the client side and handle invocations by sending it
to the servlet and receive the result of the operation.

I currently port the old XML based solution to use 
this simple one. It is session aware and works well. 
I've also ported the calculator example used by 
the jGuru tutorial about RMI:

The solution looks similar:

public class CalculatorServlet 
    extends SimpleRpcServlet implements Calculator {

    //simple implementations of the methods needed
    //to meet the requirements of the Calculator type
    //looks like:
    public long add(long a, long b) { 
     return a + b; 

The client side looks like:

Calculator calculator=
 System.out.println("10 + 12 = "+calculator.add(10,12));

That's it. Not Stub, no nothing. It works for any serializable 
parameter, return value and throwable. Overloading is handled
since the parameter types are added to the signature of the 
invoked method. So calls to simpleCall(int) and simpleCall(Integer)
are handled correctly and not mixed or anything like that.

Really simple and the same can be done using 
SocketConnections (didn't pushed it that far but it's the same
anyways since the bi-connection is relaiable anyways). 
It's simple and fast, which does not be that 
kind of a matter when it comes to database operations anyway. ;-)

Another interresting thing is, the solution uses a POST request 
and uses a parameter to transmit the invocation informations. 
So you can use any existing servlet and add support for RPCs 
without modifications since the RPC is only issused when the 
parameter is set the way it is required 
(this behaviour can also be overridden as well :-)).

The library itself is about 12kb in size currently 
(WebService+client side) and the client side requires about 
6KB (4KB when zipped).

If I missed a similar existing implementation, please tell me. I will
drop my affords instantly then ;-). Since I didn't found anything, 
I think it is a nice add ;)


Martin (Kersten),
European Union

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message