• Post Reply Bookmark Topic Watch Topic
  • New Topic

struck in coding plz help  RSS feed

 
Tirthankar Dutta Chaudhuri
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i need to implement a ErrorManager . Which is a singleton class . The client programs would register the listners of the expected Errors .
I am storing all the listners in Vector . If listner for a particular error is registered it wont be added again . Now the problem is that if i have more than one client who register the same listner and one of then removes the listner then the listner gets removed . Is thre any thing that i can do to prevent that . Please suggest me something .
 
karthikeyan Chockalingam
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems the dRegister clears the whole vector... Instead clear only the required listener ...

One way to go is, HashMap can be used instead of so that the listener to be cleared can be specified with a key.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should look at the java.util.Observer interface and the java.util.Observable class. In particular, Observable implements much of the logic you need here. I'm not entirely sure that it will completely solve your problem, but I think it would be worth your time looking into it.

Layne
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!