Tiny and simple RPC framework.
Please note that it's not a production ready implementation. It is a long way...
See jrpc-example
module for more information
Server server = ServerBuilder.forPort(serverPort)
.addService(`one or more objects which implement interface`)
.build();
ClientChannel clientChannel = ClientBuilder.forPort(serverPort)
.build();
SomeService service = clientChannel.createProxy(SomeService.class);
- primitives and wrappers
- String
- objects which implement
Resource
interface
int response = service.callMethod(new SomeResource());
int result = service.sum(2.0, 2.0);
Note that it's a blocking call but I'm planning to implement a tiny library to work with coroutine
|fibers
in order to avoid blocking calls and usage of callbacks/listeners.
clientChannel.shutdown();
server.shutdown();
server.awaitTermination();
Resource
interface provides two methods to serialize/deserialize objects and an additional method which returns an integer which uniquely identifies a resource. The recommended way to create resource is to extend the BaseResource
abstract class and annotate it with a ResourceId
annotation which has required int value - resource id. jrpc-maven-plugin
instruments all classes with ResoureId
annotation and adds a default constructor, static field _resourceId
and implements a method getResourceId
. These info is used then in runtime to create a proper mapping between resource ids and resource suppliers in order to serialize/desirialize resource during the network call.