edu.vt.middleware.ldap
Class AbstractCli

java.lang.Object
  extended by edu.vt.middleware.ldap.AbstractCli
Direct Known Subclasses:
AuthenticatorCli, LdapCli

public abstract class AbstractCli
extends Object

Abstract base class for all CLI handlers.

Version:
$Revision: 1330 $
Author:
Middleware Services

Field Summary
protected  org.apache.commons.logging.Log logger
          Log.
protected static String OPT_DSMLV1
          Option for dsmlv1 output.
protected static String OPT_DSMLV2
          Option for dsmlv2 output.
protected static String OPT_HELP
          Option to print usage.
protected static String OPT_TRACE
          Option for ldap trace.
protected static String OPT_USE_PROPERTIES
          Option for loading ldap configuration from properties.
protected  org.apache.commons.cli.Options options
          Command line options.
protected  List<String> opts
          List of command options.
protected  boolean outputDsmlv1
          Whether to output dsml version 1, the default is ldif.
protected  boolean outputDsmlv2
          Whether to output dsml version 2, the default is ldif.
 
Constructor Summary
AbstractCli()
          Default constructor.
 
Method Summary
protected abstract  void dispatch(org.apache.commons.cli.CommandLine line)
          Dispatch command line data to the handler that can perform the operation requested on the command line.
protected  Map<String,String> getArgs()
          Returns the command line arguments for this cli.
protected abstract  String getCommandName()
          Gets the name of the command for which this class provides a CLI interface.
protected  void initLdapProperties(PropertyConfig config, org.apache.commons.cli.CommandLine line)
          Initialize the supplied config with command line options.
protected abstract  void initOptions()
          Initialize CLI options.
protected  void initOptions(LdapConfigPropertyInvoker invoker)
          Initialize CLI options with the supplied invoker.
 void performAction(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  void printExamples()
          Prints CLI usage examples.
protected  void printHelp()
          Prints CLI help text.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPT_HELP

protected static final String OPT_HELP
Option to print usage.

See Also:
Constant Field Values

OPT_TRACE

protected static final String OPT_TRACE
Option for ldap trace.

See Also:
Constant Field Values

OPT_USE_PROPERTIES

protected static final String OPT_USE_PROPERTIES
Option for loading ldap configuration from properties.

See Also:
Constant Field Values

OPT_DSMLV1

protected static final String OPT_DSMLV1
Option for dsmlv1 output.

See Also:
Constant Field Values

OPT_DSMLV2

protected static final String OPT_DSMLV2
Option for dsmlv2 output.

See Also:
Constant Field Values

opts

protected List<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.

Constructor Detail

AbstractCli

public AbstractCli()
Default constructor.

Method Detail

performAction

public final void performAction(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 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 Exception
Dispatch command line data to the handler that can perform the operation requested on the command line.

Parameters:
line - Parsed command line arguments container.
Throws:
Exception - On errors thrown by handler.

printHelp

protected void printHelp()
Prints CLI help text.


printExamples

protected void printExamples()
Prints CLI usage examples.


getArgs

protected Map<String,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 Exception
Initialize the supplied config with command line options.

Parameters:
config - property config to configure
line - Parsed command line arguments container.
Throws:
Exception - On errors thrown by handler.


Copyright © 2003-2010 Virginia Tech. All Rights Reserved.