This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes creating new Data Object for each client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "creating new Data Object for each client" Watch "creating new Data Object for each client" New topic
Author

creating new Data Object for each client

Yassine Lajmi
Greenhorn

Joined: Oct 11, 2002
Posts: 9
Hi all,
I have a question concerning the rmi server :
do i have to create a new Data instance for each client or a single instance of data is Ok.
if yes how to do it.
thanks


SCJP<br />SCJD<br />SCBCD<br />SCWCD<br />OCA 9i
Manish Kumar
Ranch Hand

Joined: Apr 15, 2002
Posts: 53
Hi Lajmi,
I think that creating a new Data object for each client would definitely corrupt your db.db file. You shouldn't create more than one instance of the Data class.
with regards,
Manish Kumar
Yassine Lajmi
Greenhorn

Joined: Oct 11, 2002
Posts: 9
thank you Kumar,
In this case how to be sure that a single instance of data was created for each client.
I have made a simple System.out.println in the constractor of Data, and for each Client it is printed.
i don't understend why a new instance is created.
in the server :
try{
Registry r = LocateRegistry.createRegistry(port);
database = new DataAccessImpl(dbFileName);
r.rebind(bindName, database);
}catch(Exception e){
System.out.println("Exception occurred on DataServer : " + e);
System.exit(0);
}
in the Client side :
System.setSecurityManager(new RMISecurityManager());
dataAccess = (DataAccess) Naming.lookup("rmi://"+serverDNS+":"+port+"/DataAcess_BindName");
Manish Kumar
Ranch Hand

Joined: Apr 15, 2002
Posts: 53
u should use the factory pattern.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: creating new Data Object for each client
 
Similar Threads
create(String[ ] data)
share one instance of remote object
Initial design review
I'm using synchronized blocks. Is it valid?
Static HashSet problem