Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

LocateRegistry.createRegistry

 
Tony Morris
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A call to LocateRegistry.createRegistry (understandably) throws an exception if the registry already exists on the given port, etc. Is there a nice way to either:
- determine if a registry already exists before creating it ?
- shut down the created registry ?
Cheers.
 
Tony Morris
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My best solution so far is to create it an ignore the exception
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tony,
There does not appear to be a way of shutting down a running registry.
As far as checking if one is already running: you could try binding to the registry (which will throw an exception if it is not already running). So this does not really gain you much. It depends on which situation is more likely - for the SCJD assignment, having no registry running is the more likely scenario, so just trying to start the registry and catching the exception in the unlikely case that it is already running may make the most sense.
I wouldn't just ignore the exception though. At the bare minimum, I would log it and/or display a message to the user stating that the registry could not be started. But you have to then decide what to do next - is this a fatal error, or do you try to bind to the already running registry (probably setting the codebase before you do so).
Personally I chose the latter - that gave my server a bit more flexibility - it could run with the registry that it started, or it could run with a registry that someone else started.
Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic