This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

creating new Data Object for each client

 
Yassine Lajmi
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Manish Kumar
Ranch Hand
Posts: 53
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 53
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
u should use the factory pattern.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic