Commit 3e1ff9b1 authored by Andre Freyssinet's avatar Andre Freyssinet

Adds JNDI lookup operation.

parent b3056789
......@@ -65,7 +65,8 @@ import org.objectweb.joram.client.jms.Session;
* any user to send or receive messages on this queue.
* - delete: deletes the queue in the JMS server.
* - statistics: prints all statistics about the queue.
* - unbind: removes the binding in JNDI.
* - lookup: gets the registered object in JNDI (name asked on terminal).
* - unbind: removes the binding in JNDI (name asked on terminal).
* - password: updates a user password (parameters asked in command line).
*
* The client returns 0 if the command is ok, -1 otherwise.
......@@ -86,6 +87,7 @@ public class Tool {
public final static String PAUSE_OFF_CMD = "pause_off";
public final static String STAT_CMD = "statistics";
public final static String LOOKUP_CMD = "lookup";
public final static String UNBIND_CMD = "unbind";
public final static String PASSWORD_CMD = "password";
......@@ -110,7 +112,8 @@ public class Tool {
" -D" + CF + "=cf -D" + QUEUE + "=queue -D" + FORWARD_QUEUE + "=forward -jar jmstool.jar\n" +
" [" + HELP_CMD + "|" + BROWSE_CMD + "|" + PURGE_CMD +
"|" + FORWARD_CMD + "|" + REMOVE_CMD + "|" + PAUSE_ON_CMD + '/' + PAUSE_OFF_CMD +
"|" + CREATE_CMD + "|" + DELETE_CMD + "|" + STAT_CMD + "|" + UNBIND_CMD +
"|" + CREATE_CMD + "|" + DELETE_CMD + "|" + STAT_CMD +
"|" + LOOKUP_CMD +"|" + UNBIND_CMD +
"|" + PASSWORD_CMD+ "]\n");
System.err.println("Options and parameters, set by Java environment variable (\"-Dproperty=value\" in command line)");
......@@ -145,8 +148,9 @@ public class Tool {
" any user to send or receive messages on this queue.\n" +
" - delete: deletes the queue in the JMS server.\n" +
" - statistics: prints all statistics about the queue.\n" +
" - unbind: removes the binding in JNDI.\n" +
" - password: updates a user password (parameters asked in command line).");
" - lookup: gets the registered object in JNDI (name asked on terminal).\n" +
" - unbind: removes the binding in JNDI (name asked on terminal).\n" +
" - password: updates a user password (parameters asked on terminal).");
}
static Context ictx = null;
......@@ -166,7 +170,7 @@ public class Tool {
!FORWARD_CMD.equals(command) && !REMOVE_CMD.equals(command) &&
!PAUSE_ON_CMD.equals(command) && !PAUSE_OFF_CMD.equals(command) &&
!STAT_CMD.equals(command) &&
!UNBIND_CMD.equals(command) &&
!UNBIND_CMD.equals(command) && !LOOKUP_CMD.equals(command) &&
!PASSWORD_CMD.equals(command)) {
usage();
return;
......@@ -181,6 +185,14 @@ public class Tool {
System.exit(-1);
}
if (LOOKUP_CMD.equals(command)) {
String name = System.console().readLine("name: ");
lookup(name);
} else if (UNBIND_CMD.equals(command)) {
String name = System.console().readLine("name: ");
unbind(name);
}
// Get the JMS administration connection
try {
cnx = getJMSConnection(ictx);
......@@ -319,8 +331,6 @@ public class Tool {
pause(queue, false);
} else if (STAT_CMD.equals(command)) {
statistics(queue);
} else if (UNBIND_CMD.equals(command)) {
unbind(qname);
}
} catch (Exception exc) {
System.exit(-1);
......@@ -664,6 +674,20 @@ public class Tool {
System.out.println("Message \"" + msgid + "\" forwarded.");
}
/* ********************************************************************************
* Lookup in JNDI.
* ******************************************************************************** */
public static void lookup(String name) {
try {
Object obj = ictx.lookup(name);
System.out.println("Name \"" + name + "\" bind to: " + obj);
} catch (NamingException exc) {
System.err.println("Name \"" + name +"\" unknown.");
if (debug) exc.printStackTrace(System.err);
}
}
/* ********************************************************************************
* Unbind the queue.
* ******************************************************************************** */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment