Configurable@Private @Unstable public class CommandFactory extends Configured
| Constructor | Description |
|---|---|
CommandFactory() |
Factory constructor for commands
|
CommandFactory(Configuration conf) |
Factory constructor for commands
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
addClass(java.lang.Class<? extends Command> cmdClass,
java.lang.String... names) |
Register the given class as handling the given list of command
names.
|
void |
addObject(Command cmdObject,
java.lang.String... names) |
Register the given object as handling the given list of command
names.
|
Command |
getInstance(java.lang.String cmd) |
Returns an instance of the class implementing the given command.
|
Command |
getInstance(java.lang.String cmdName,
Configuration conf) |
Get an instance of the requested command
|
java.lang.String[] |
getNames() |
Gets all of the registered commands
|
void |
registerCommands(java.lang.Class<?> registrarClass) |
Invokes "static void registerCommands(CommandFactory)" on the given class.
|
getConf, setConfpublic CommandFactory()
public CommandFactory(Configuration conf)
conf - the hadoop configurationpublic void registerCommands(java.lang.Class<?> registrarClass)
registrarClass - class to allow an opportunity to registerpublic void addClass(java.lang.Class<? extends Command> cmdClass, java.lang.String... names)
cmdClass - the class implementing the command namesnames - one or more command names that will invoke this classpublic void addObject(Command cmdObject, java.lang.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(java.lang.String cmd)
addClass(Class, String...)cmd - name of the commandpublic Command getInstance(java.lang.String cmdName, Configuration conf)
cmdName - name of the command to lookupconf - the hadoop configurationCommand or null if the command is unknownpublic java.lang.String[] getNames()
Copyright © 2008–2025 Apache Software Foundation. All rights reserved.