• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

LocateRegistry.createRegistry

 
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My best solution so far is to create it an ignore the exception
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic