Java Client

204 views
Skip to first unread message

cyclemenow

unread,
Oct 25, 2010, 6:06:44 PM10/25/10
to jabsorb-user
I've been searching for a java client with no luck.

I did find a reference to a post on this mailing list that referenced
this documentation on how to make calls to jabsorb from a Java client:
http://jabsorb.org/JavaClient.

Unfortunately, this documentation is not clear, and the only code
example it provides appears to be for the server side (which
ironically is already very well documented elsewhere on the site).

I'm looking for a _Java_ library that allows me to make calls to my
existing JSON-RPC server.

Does such a thing exist? The JavaClient documentation at jabsorb.org
makes me think it exists, but how does one use it?

Thank you for your help,

Matthew

progre55

unread,
Oct 26, 2010, 4:30:33 AM10/26/10
to jabsorb-user
Hi Matthew,

The client does not necessarily have to be a jabsorb-client. It can be
any json-rpc java client. For instance, you can have jabsorb on the
server side, and http://code.google.com/p/json-rpc-client/ on the
client side.
Hope that helps.

Regards,
progre55

Matthijs Wensveen

unread,
Oct 26, 2010, 5:40:54 AM10/26/10
to jabsor...@googlegroups.com
Hi Matthew,

Jabsorb is perfectly capable of creating Java clients. There is an example in the unit tests in the source download.
I'll look it up when I'm at home (I don't have the source available here).

If you get the source from svn, you can even create asynchronous clients in java, which may or may not be useful to you. I'll provide an example for that too.

Regards,
Matthijs

--
You received this message because you are subscribed to the Google Groups "jabsorb-user" group.
To post to this group, send email to jabsor...@googlegroups.com.
To unsubscribe from this group, send email to jabsorb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jabsorb-user?hl=en.


Arthur Blake

unread,
Oct 26, 2010, 11:34:22 AM10/26/10
to jabsor...@googlegroups.com
On Tue, Oct 26, 2010 at 4:30 AM, progre55 <ikro...@gmail.com> wrote:
Hi Matthew,

The client does not necessarily have to be a jabsorb-client. It can be
any json-rpc java client. For instance, you can have jabsorb on the
server side, and http://code.google.com/p/json-rpc-client/ on the
client side.

FYI, the project you referenced above is an older version of the actual client that is now part of jabsorb.

Matthijs Wensveen

unread,
Oct 27, 2010, 6:43:29 PM10/27/10
to jabsor...@googlegroups.com
Hi Matthew,

Here is a very simple example that might help you:

        final TransportRegistry registry = new TransportRegistry();
        final Client client = new Client(registry.createSession("http://my.host/webapp/JSON-RPC/"));

        final MyInterface myObject = (MyInterface) client.openProxy("myObject", MyInterface.class);
        myObject.myMethod(args);

So you need to have an interface that the client object can create a proxy for.

The asynchronous version of this code makes using the client a bit more like the javascript version, in which you can provide a callback method that executes when your call has finished. For the http transport, this means it is run on a separate thread (since HttpClient does not natively support asynchronous calls). It is, however, possible to add your own transports that do support asynchronous calling. For more information, see bug #64 (http://issues.jabsorb.org/show_bug.cgi?id=64).

HTH,
(Your Dutch namesake,) Matthijs

@Arthur: My latest patch to bug #64 contains some fixes and some extra unit tests. I think the bug can be closed anyhow since the main functionality was committed to trunk, but it would be nice if this patch was committed as well. So I wouldn't have to have a patched version of the code.

Regards,
Matthijs
Reply all
Reply to author
Forward
0 new messages