| 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.
|
 |
 |
|
|
subject: creating new Data Object for each client
|
|
|