I am currently trying to implement a rudimentary JSON RPC server in small java application but as unexperienced as i am i seem to be unable to do it right..
Therefore i wonder if someone could post a simple Hello World example that would just start a JSON RPC Server without spring or web.xml file..
////////////////////////////////
// RPC COde
///////////////////////////////
RPCService uRPCService = new RPCService() {
public int getBlocks() {
// TODO Auto-generated method stub
return 0;
}
public int getBalance() {
// TODO Auto-generated method stub
return 0;
}
};
Object compositeService = ProxyUtil.createCompositeServiceProxy(
this.getClass().getClassLoader(),
new Object[] { uRPCService},
new Class<?>[] { RPCService.class},
true);
// now compositeService can be used as any of the above service, ie:
int bal = (((RPCService) compositeService).getBalance());
JsonRpcServer jsonRpcServer = new JsonRpcServer( compositeService );
// create the stream server
int maxThreads = 50;
int port = 1420;
InetAddress bindAddress = InetAddress.getByName("localhost");
StreamServer streamServer = new StreamServer(jsonRpcServer, maxThreads, port, 0, bindAddress);
// start it, this method doesn't block
streamServer.start();
///////////////////////////////////
/// RPC CODE
///////////////////////////////////
inside my main() function.. but unfortunately it doesnt work at all...
So would someone be able to somehow post a simple program or snippet to start an RPC Server and how to implement ones own functions?