}
private void doExecute( String commandName, String[] commandArgs, String originalCommand )
throws JMException, IOException
{
Command cmd = commandFactory.createCommand( commandName );
if ( cmd instanceof HelpCommand )
{
( (HelpCommand) cmd ).setCommandCenter( this );
}
ArgumentProcessor<Command> ap = (ArgumentProcessor<Command>) ArgumentProcessor.newInstance( cmd.getClass() );
ap.process( commandArgs, cmd );
// Print out usage if help option is specified
if ( cmd.isHelp() )
{
ap.printHelp( new PrintWriter( System.out, true ) );
return;
}
cmd.setSession( session );
// Make sure concurrency and run command
lock.lock();
try
{
cmd.execute();
}
finally
{
lock.unlock();
}