Results 1 to 1 of 1
- 03-04-2011, 03:53 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 1
- Rep Power
- 0
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 jndi lookup to ensure that provided name exists.
Java Code:Object obj; try { obj = ctx.lookup("/TheRootContext/SomeSubContext/SOME.QUEUE.NAME:queue"); } catch(NamingException ex) { // process naming exception: name not found, name syntax incorrect, ... }- %I don't know what to do next%, but suggest something like checking that:
Java Code:obj != null && obj instanceof javax.jms.Queue
===
Another way, suggested here: java - How to check jndi bind/unbind status? - Stack Overflow
is to use listBindings method, passing to it parent context name: and checking what interested binding present in returned NamingEnumeration. But this is actually the same as previous method. This way something like this should be done:
So, what is the correct way?Java Code:NamingEnumeration bindings; try { bindings = ctx.listBindings("/TheRootContext/SomeSubContext/SOME.QUEUE.NAME"); } catch(NamingException ex) { // process naming exception: name not found, name syntax incorrect, ... } boolean isFound, isBinded; while (bindings!=null && bindings.hasMore()) { Binding bd = (Binding) bindings.next(); if(bd.getName().equals("queue")) { isFound = true; isBinded = bd.getObject() != null && bd.getObject() instanceof javax.jms.Queue) ; break; } } System.out.println("Is binded: " + isFound && isBinded);
Similar Threads
-
How to bind soap header using jax-rpc
By jadeite100 in forum XMLReplies: 0Last Post: 12-05-2010, 06:17 PM -
Check SMTP server status
By sandeep.ctg in forum New To JavaReplies: 4Last Post: 04-02-2010, 05:45 PM -
Check SMTP server status
By sandeep.ctg in forum Java ServletReplies: 0Last Post: 03-31-2010, 08:10 AM -
Check LAN connection status through JAVA
By shanmathi in forum Advanced JavaReplies: 1Last Post: 04-09-2009, 03:19 PM -
bind slider to column in DB
By nicromonicon in forum New To JavaReplies: 0Last Post: 01-12-2009, 04:14 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks