Package edu.vt.middleware.ldap
Class AbstractCli
- java.lang.Object
-
- edu.vt.middleware.ldap.AbstractCli
-
- Direct Known Subclasses:
AuthenticatorCli,LdapCli
public abstract class AbstractCli extends java.lang.ObjectAbstract base class for all CLI handlers.- Version:
- $Revision: 1330 $
- Author:
- Middleware Services
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.commons.logging.LogloggerLog.protected static java.lang.StringOPT_DSMLV1Option for dsmlv1 output.protected static java.lang.StringOPT_DSMLV2Option for dsmlv2 output.protected static java.lang.StringOPT_HELPOption to print usage.protected static java.lang.StringOPT_TRACEOption for ldap trace.protected static java.lang.StringOPT_USE_PROPERTIESOption for loading ldap configuration from properties.protected org.apache.commons.cli.OptionsoptionsCommand line options.protected java.util.List<java.lang.String>optsList of command options.protected booleanoutputDsmlv1Whether to output dsml version 1, the default is ldif.protected booleanoutputDsmlv2Whether to output dsml version 2, the default is ldif.
-
Constructor Summary
Constructors Constructor Description AbstractCli()Default constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voiddispatch(org.apache.commons.cli.CommandLine line)Dispatch command line data to the handler that can perform the operation requested on the command line.protected java.util.Map<java.lang.String,java.lang.String>getArgs()Returns the command line arguments for this cli.protected abstract java.lang.StringgetCommandName()Gets the name of the command for which this class provides a CLI interface.protected voidinitLdapProperties(PropertyConfig config, org.apache.commons.cli.CommandLine line)Initialize the supplied config with command line options.protected abstract voidinitOptions()Initialize CLI options.protected voidinitOptions(LdapConfigPropertyInvoker invoker)Initialize CLI options with the supplied invoker.voidperformAction(java.lang.String[] args)Parses command line options and invokes the proper handler to perform the requested action, or the default action if no action is specified.protected voidprintExamples()Prints CLI usage examples.protected voidprintHelp()Prints CLI help text.
-
-
-
Field Detail
-
OPT_HELP
protected static final java.lang.String OPT_HELP
Option to print usage.- See Also:
- Constant Field Values
-
OPT_TRACE
protected static final java.lang.String OPT_TRACE
Option for ldap trace.- See Also:
- Constant Field Values
-
OPT_USE_PROPERTIES
protected static final java.lang.String OPT_USE_PROPERTIES
Option for loading ldap configuration from properties.- See Also:
- Constant Field Values
-
OPT_DSMLV1
protected static final java.lang.String OPT_DSMLV1
Option for dsmlv1 output.- See Also:
- Constant Field Values
-
OPT_DSMLV2
protected static final java.lang.String OPT_DSMLV2
Option for dsmlv2 output.- See Also:
- Constant Field Values
-
opts
protected java.util.List<java.lang.String> opts
List of command options.
-
logger
protected final org.apache.commons.logging.Log logger
Log.
-
options
protected org.apache.commons.cli.Options options
Command line options.
-
outputDsmlv1
protected boolean outputDsmlv1
Whether to output dsml version 1, the default is ldif.
-
outputDsmlv2
protected boolean outputDsmlv2
Whether to output dsml version 2, the default is ldif.
-
-
Method Detail
-
performAction
public final void performAction(java.lang.String[] args)
Parses command line options and invokes the proper handler to perform the requested action, or the default action if no action is specified.- Parameters:
args- Command line arguments.
-
initOptions
protected abstract void initOptions()
Initialize CLI options.
-
initOptions
protected void initOptions(LdapConfigPropertyInvoker invoker)
Initialize CLI options with the supplied invoker.- Parameters:
invoker-PropertyInvoker
-
getCommandName
protected abstract java.lang.String getCommandName()
Gets the name of the command for which this class provides a CLI interface.- Returns:
- Name of CLI command.
-
dispatch
protected abstract void dispatch(org.apache.commons.cli.CommandLine line) throws java.lang.ExceptionDispatch command line data to the handler that can perform the operation requested on the command line.- Parameters:
line- Parsed command line arguments container.- Throws:
java.lang.Exception- On errors thrown by handler.
-
printHelp
protected void printHelp()
Prints CLI help text.
-
printExamples
protected void printExamples()
Prints CLI usage examples.
-
getArgs
protected java.util.Map<java.lang.String,java.lang.String> getArgs()
Returns the command line arguments for this cli.- Returns:
- map of arg name to description
-
initLdapProperties
protected void initLdapProperties(PropertyConfig config, org.apache.commons.cli.CommandLine line) throws java.lang.Exception
Initialize the supplied config with command line options.- Parameters:
config- property config to configureline- Parsed command line arguments container.- Throws:
java.lang.Exception- On errors thrown by handler.
-
-