Originally posted by Mag Hoehme:
Hi dayanand,
this is how I interpreted the instructions:
You have a Swing Client application which may open a local database file or connect to a remote database server. I opted for RMI. This is how I did it:
In local mode, the client works like an ordinary non-RMI application: The client gets a DataAccess object from a Connection Factory; the Connection Factory creates the Data Access object, which in turn creates the Data object (for the specified database file).
In remote mode, I have a Connection Server that creates a single Data object for the specified database file. My client asks the connection factory, the connection factory asks the remote connection server, and the remote connection server creates a DataAccess object for the (running) Data object.
I hope this helps.
Hi,
Thanks for the quick reply.
I decided to implement the architecture (a) - simpler compared to (b) and also does not have the drawback as (b).
Can you also clarify the following:
(a) Your implementation of ConnectionFactory accessing a DataAccess (local/remote) which inturn accesses Data object, what pattern is this? (Abstract Factory(AF) / Factory Method(FM)).
(b) I am not clear about the difference (of using patterns) though! Regardless of the pattern, we are going to write code like the following in the connectionfactory right?
Class ConnectionFactory {
String mode
ConnectionFactory(String m) {
mode = m;
}
DataAccess getConnection() {
if (mode == "local") {
return new DataAccess();
} else {
DataAccess remoteda = Naming.Lookup("rmi:/..");
return DataAccess;
}
}
}
I am assuming that the "if" condition is avoided somehow by using patterns! So, what is the difference in using (AF/FM) patterns?!
Am I making a mistake somewhere?
(c) I am also going to use RMI. Since you have also implemented using RMI, did you use any "Activatable" objects feature? (I read somewhere that the beta
test checks if the latest api are used!)
(d) Did you use any of java.nio classes? It is possible to map a memory buffer to a file so that if any change is done to the memory buffer, it will synchronize with the file. Have you used this in your implementation?
Dayanand.