How to check jndi bind/unbind status?
I'm looking for way of checking bind status of object and appropriate jndi name.
For example, I've got some ldap jms queue name: "/TheRootContext/SomeSubContext/SOME.QUEUE.NAME:queue"
I need to check that appropriate queue exists and it is binded with passed name.
What will be the correct way to check "bind status"?
I see such algorithm:
Perform jn开发者_高级运维di lookup to ensure that provided name exists.
Object obj = ctx.lookup("/TheRootContext/SomeSubContext/SOME.QUEUE.NAME:queue");
%I don't know what to do next%, but suggest something like checking that:
obj != null && obj instanceof javax.jms.Queue
Am I correct? What is the correct way?
Most likely if object is not found lookup will throw a NamingException in 1. You need to either catch an exception or try to use list method to check if object exists.
精彩评论