@InterfaceAudience.Private @InterfaceStability.Unstable public class CommandFactory extends Configured implements Configurable
Constructor and Description |
---|
CommandFactory()
Factory constructor for commands
|
CommandFactory(Configuration conf)
Factory constructor for commands
|
Modifier and Type | Method and Description |
---|---|
void |
addClass(Class<? extends Command> cmdClass,
String... names)
Register the given class as handling the given list of command
names.
|
void |
addObject(Command cmdObject,
String... names)
Register the given object as handling the given list of command
names.
|
Command |
getInstance(String cmd)
Returns an instance of the class implementing the given command.
|
Command |
getInstance(String cmdName,
Configuration conf)
Get an instance of the requested command
|
String[] |
getNames()
Gets all of the registered commands
|
void |
registerCommands(Class<?> registrarClass)
Invokes "static void registerCommands(CommandFactory)" on the given class.
|
getConf, setConf
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getConf, setConf
public CommandFactory()
public CommandFactory(Configuration conf)
conf
- the hadoop configurationpublic void registerCommands(Class<?> registrarClass)
registrarClass
- class to allow an opportunity to registerpublic void addClass(Class<? extends Command> cmdClass, String... names)
cmdClass
- the class implementing the command namesnames
- one or more command names that will invoke this classpublic void addObject(Command cmdObject, String... names)
addClass(Class, String...)
whenever possible to avoid
startup overhead from excessive command object instantiations. This
method is intended only for handling nested non-static classes that
are re-usable. Namely -help/-usage.cmdObject
- the object implementing the command namesnames
- one or more command names that will invoke this classpublic Command getInstance(String cmd)
addClass(Class, String...)
cmd
- name of the commandpublic Command getInstance(String cmdName, Configuration conf)
cmdName
- name of the command to lookupconf
- the hadoop configurationCommand
or null if the command is unknownpublic String[] getNames()
Copyright © 2013 Apache Software Foundation. All rights reserved.