Package org.apache.hadoop.fs.shell
Class CommandFactory
java.lang.Object
org.apache.hadoop.conf.Configured
org.apache.hadoop.fs.shell.CommandFactory
- All Implemented Interfaces:
Configurable
class to search for and register commands
-
Constructor Summary
ConstructorsConstructorDescriptionFactory constructor for commandsCommandFactory(Configuration conf) Factory constructor for commands -
Method Summary
Modifier and TypeMethodDescriptionvoidRegister the given class as handling the given list of command names.voidRegister the given object as handling the given list of command names.getInstance(String cmd) Returns an instance of the class implementing the given command.getInstance(String cmdName, Configuration conf) Get an instance of the requested commandString[]getNames()Gets all of the registered commandsvoidregisterCommands(Class<?> registrarClass) Invokes "static void registerCommands(CommandFactory)" on the given class.Methods inherited from class org.apache.hadoop.conf.Configured
getConf, setConf
-
Constructor Details
-
CommandFactory
public CommandFactory()Factory constructor for commands -
CommandFactory
Factory constructor for commands- Parameters:
conf- the hadoop configuration
-
-
Method Details
-
registerCommands
Invokes "static void registerCommands(CommandFactory)" on the given class. This method abstracts the contract between the factory and the command class. Do not assume that directly invoking registerCommands on the given class will have the same effect.- Parameters:
registrarClass- class to allow an opportunity to register
-
addClass
Register the given class as handling the given list of command names.- Parameters:
cmdClass- the class implementing the command namesnames- one or more command names that will invoke this class
-
addObject
Register the given object as handling the given list of command names. Avoid calling this method and useaddClass(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.- Parameters:
cmdObject- the object implementing the command namesnames- one or more command names that will invoke this class
-
getInstance
Returns an instance of the class implementing the given command. The class must have been registered viaaddClass(Class, String...)- Parameters:
cmd- name of the command- Returns:
- instance of the requested command
-
getInstance
Get an instance of the requested command- Parameters:
cmdName- name of the command to lookupconf- the hadoop configuration- Returns:
- the
Commandor null if the command is unknown
-
getNames
Gets all of the registered commands- Returns:
- a sorted list of command names
-