jorre
Java Object Request Response Exchange
Jorre is a java networking framework based on netty (http://netty.io) that can be used to exchange java objects between remote client and server applications.
Introduction
Jorre builds on netty to provide a simplifed client server model with a typical request/response message exchange. This is done by extending the Client and Server classes. A messaging protocol is defined by extending the ClientInterface and ServerInterface interfaces. Custom requests and responses are made possible by extending the base jorre message classes ServerMessage, ServerRequest, ClientResponse and ClientCallback.
Jorre allows serveral types of messages to be exchanged between clients and servers. They are:
- ServerMessage this object is sent from a client to a server without expecting any response
- ServerRequest this object is sent from a client to a server and implies that a ClientResponse object will be returned from the server at some future time
- ClientResponse this object is sent from a server to a client in response to a ServerRequest receivied from the client
- ClientCallback objects are sent from a server to a client
Each of the above objects have a method named handle for handling those messages once they are receivied. This is where the intial logic for handling messages, requests, responses and callbacks is implemented.
The Client class provides methods for sending messages and requests to a server.
- sendMessage - send a ServerMessage object to the server
- sendRequest - send a ServerRequest object to the server and return a ResponseFuture that will be notified when the ClientResponse is ready
- sendBlockingRequest - send a Request object to the server and block until the ClientResponse is ready
The Server class provides a method for sending a callback to a client
- callback - send a ClientCallback object to a client
Example Projects
An example chat application has been included to illustrate how to use jorre. A complete client-server implementation will require 3 projects.
- A protocol project that defines the client-server interface - the example project is named example-chat-protocol
- A client project that provides the implementation of the client - the example project is named example-chat-client
- A server project that provides the implementation of the server - the example project is named example-chat-server
Protocol project
This project will provide 2 interfaces, one that extends the ClientInterface and one that extends the ServerInterface. It will also provide any objects that will be passed between the client and the server. This includes any ServerMessage, ServerRequest, ClientResponse and ClientCallback objects that will be extended.
Client project
This project will provide a client class that extends Client and implements the client interface that is defined in the Protocol project.
Server project
This project will provide a server class that extends Server and implements the server interface that is defined in the Protocol project.