In rpcClient, is there an easy way to call any arbitrary method without defining it in the interface first?

37 views
Skip to first unread message

heav...@gmail.com

unread,
Apr 2, 2013, 3:54:38 PM4/2/13
to json...@googlegroups.com
I am trying to connect to an external service, using JsonRpcHttpClient.

I've done some testing, but it seems that the only way to do this is to first define an interface, and then use it in ProxyUtil.createClientProxy( to be able to call the remote service.
The interface has to define each and every possible method to be able to call them, otherwise I get "cannot find method", etc.. error.

Is there an easier way? (ie, I want to be able to call client.arbitraryMethod(arbitraryInt,arbitraryString), without defining it anywhere prior to calling, (and if such a method does not exist in the remote service, or some argument cannot be reliably type-determined, well that's too bad, throw some exception, but otherwise just call it))

Maybe this thread is about similar things? https://groups.google.com/forum/?fromgroups=#!topic/jsonrpc4j/HDW26wkBfPM
It has been a while since some answers in it, perhaps the situation changed?

Brian C. Dilley

unread,
Apr 2, 2013, 4:09:05 PM4/2/13
to json...@googlegroups.com
That's not even possible with java. You can't call methods that aren't
defined somewhere.

There is the invoke method though:

.invoke("arbitraryMethod", int, int)

heav...@gmail.com

unread,
Apr 2, 2013, 4:11:25 PM4/2/13
to json...@googlegroups.com
Alright, thank you. I was using it in Groovy, wasn't sure on how dynamic Java was about these things.

Brian C. Dilley

unread,
Apr 2, 2013, 4:43:48 PM4/2/13
to json...@googlegroups.com
if groovy has a mechanism for handling invocations of methods that don't exist (ie: __call__(..) or whatever) then you could easily implement this using the invoke(name, args..) method that i mentioned below.
--
You received this message because you are subscribed to the Google Groups "jsonrpc4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jsonrpc4j+...@googlegroups.com.
To post to this group, send email to json...@googlegroups.com.
Visit this group at http://groups.google.com/group/jsonrpc4j?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages