Which pattern for RMI scenario

Hi ,

I have a database that holds data for shoes and trainers and i have set up 2 seperate applications with simple gui's one for shoes one for trainers.

The applications communicate seperatley through rmi to a server which returns the results of any queries from the database it makes. ie. the client asks a query through rmi to the server which then returns a resultset object which is then diplayed on the application.

The question is how can i bring these 2 seperate applications together to form 1 application. Maybe something with a generic class which can then be subclassed at runtime according to what is needed.

Can anyone suggest a pattern that can be used to do this?

[712 byte] By [sparky45a] at [2007-10-2 9:23:10]
# 1

> Hi ,

>

> I have a database that holds data for shoes and

> trainers and i have set up 2 seperate applications

> with simple gui's one for shoes one for trainers.

>

> The applications communicate seperatley through rmi

> i to a server which returns the results of any

> queries from the database it makes. ie. the client

> asks a query through rmi to the server which then

> returns a resultset object which is then diplayed on

> the application.

Oh, my. I would not return a java.sql.ResultSet, if that's what you mean.

I'd return a data structure or collection that would hold the results of the query. The ResultSet should be closed as soon as the data is loaded into the data structure or collection, in the scope of the method that created it.

> The question is how can i bring these 2 seperate

> applications together to form 1 application. Maybe

> something with a generic class which can then be

> subclassed at runtime according to what is needed.

Just curious: what's the difference between a shoe and a trainer in your model? Some different attributes? I would wonder if a generic class would be Shoe and Trainer would be a subclass, special to the needs of an athletic shoe.

> Can anyone suggest a pattern that can be used to do this?

The RMI signature must either consist of a flag indicating something about the query OR two separate methods.

Two different UIs talking to the same RMI service? How does the service tell the difference between the two?

%

duffymoa at 2007-7-16 23:30:05 > top of Java-index,Other Topics,Patterns & OO Design...
# 2
> Two different UIs talking to the same RMI service?> How does the service tell the difference between the> two?Basically the same way any other server distinguishes between its clients. It sends the response back to wherever the request came from.
DrClapa at 2007-7-16 23:30:05 > top of Java-index,Other Topics,Patterns & OO Design...
# 3

Yes, but there must be two different methods in the RMI interface - one that says "Please return me a Collection of Shoes" and another that says "Please return me a Collection of Trainers". The server has to be able to distinguish between the two types of requests.

Or, if Trainer is a subclass of Shoe, the server can just return a Collection of Shoes and let polymorphism take care of the rest.

%

duffymoa at 2007-7-16 23:30:05 > top of Java-index,Other Topics,Patterns & OO Design...