File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Doubt in Assignment Architecture ! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Doubt in Assignment Architecture !" Watch "Doubt in Assignment Architecture !" New topic
Author

Doubt in Assignment Architecture !

Dayanand Kangala
Greenhorn

Joined: Sep 09, 2002
Posts: 26
Dear All,
I got my beat assignment a week back and have some doubts ! Some in the assignment question itself and some in the Patterns, RMI. I am interested in discussing them. Please share your thoughts.
The assignment says that I should develop a Swing-Application to operate in network-mode and non-networked mode. And, the assignment also mentions that I should develop a small database server implementation with locking facility. (I was given the database-schema and the storage format)
Regarding the network & non-network modes, there are 2 ways in which the above can be implemented. They are:
(a) The Swing-Application can be run in both the database-server and in non-database-server (client machines used to access the database-server). The Swing-Application running in the database-server will use the "non-network-mode" to access the database and the Swing-Application running in the non-database-server will use the "network-mode" to access the database (using RMI).
(b) The Swing-Application can run in the database-server in non-network-mode and the Swing-Application can run in the non-database-server in network-mode. The Swing-Application running in the non-database-server can also run in the non-network-mode with its own local database (downloaded from the server, when the connection was last established).
The second implementation (b) is complex and has some drawbacks. The drawback being the local database not in sync with the live-database.
Can anyone clarify which one is to be implemented?!
Regarding the database server functionality, I thought of using a singleton pattern - Have only one instance of the database running in the server and let all clients access the database use this instance. Are there any drawbacks in this method?
Also, I thought of having a synchronized method for update() operations. And, implement the lock concept in this method. Is there another method to implement the lock concept?
Regards,
Dayanand.
Mag Hoehme
Ranch Hand

Joined: Apr 07, 2002
Posts: 194
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.


Mag
Dayanand Kangala
Greenhorn

Joined: Sep 09, 2002
Posts: 26
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt in Assignment Architecture !