/*
* This example is from the book "Java Enterprise in a Nutshell".
* Copyright (c) 1999 by O'Reilly & Associates.
* You may distribute this source code for non-commercial purposes only.
* You may study, modify, and use this example for any purpose, as long as
* this notice is retained. Note that this example is provided "as is",
* WITHOUT WARRANTY of any kind either expressed or implied.
*/
/******************************************************************************
commands.java
The commands command prints out the known commands for NamingShell.
******************************************************************************/
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
import javax.naming.Context;
public class commands implements Command {
String COMMAND_NAME = "commands";
Hashtable commands = NamingShell.getCommands();
public void execute(Context currentContext, Vector args)
throws CommandException {
System.out.println("Known commands: ");
Enumeration names = commands.elements();
while (names.hasMoreElements())
System.out.println(((Command)
names.nextElement()).getClass().getName());
System.out.println();
}
public void help() { System.out.print("Usage: commands"); }
}
|