I thought I must decouple the gui from the application logic and also ensure that RMI calls are not made in the Event Dispatch
thread (to keep GUI responsive). So I have implemented a listener
pattern. I have defined RequestJob interface and implemented it in separate classes each representing a type of request job. For eg. RequestInfoJob, RequestBookingJob. Each such class has a run method which contains the logic for the job.
The relevant gui element executes a request by instantiating the appropriate RequestJob. The gui element then attaches itself as the listener to that RequestJob object. The RequestJob object is then submitted to a Dispatcher object which maintains a queue of RequestJob objects and processes the queue in a separate thread.
When in the execution of its run-method the RequestJob object receives a final response from the server it throws a ResponseEvent which is notified to all the listener gui elements registered with the RequestJob object. I think the notifying of the listeners should also be done in the EventDispatch thread by calling the InvokeLater() methods.
Upon receiving the notification the listener-gui elements analyse the RequestJob object to find out the fate/result of the request and then present the information to the user.
Is this a sensible design. I would be grateful for any help, since I don't have much practical experience.
Thanks