Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Stop RMI Registry from code

 
Liang Anmian
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I started the RMI registry using the following code:



How do I remove the RMI registry? It's not enough to unbind the remote object. I want to destroy the registry. Is there any way?
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think there is a way. Neither LocateRegistry nor Registry provide a destroy or unload method of some sort.

Of course the registry will be gone when the JVM it runs in (in the case you started it from code that's the JVM your application runs in) terminates.
 
Liang Anmian
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gosh. My server GUI has 2 buttons. One of them is the start RMI service button, while the other is the halt RMI service button. Now I guess I have to think of other workarounds for the halt button.

Thanks for your input.
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can use registry.unbind(String) to remove a service from the running registry.
Or alternatively define a NullObject implementing the same interface as your real service and rebind to that.
That way the client could still call the service without getting exceptions and the remote dummy service could then give nothing back on every read request and ignore all updates (maybe handing a message that the service is unavailable instead as a statuscode).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic