uk.ac.ncl.cs.instantsoap.commandlineprocessor
Class CommandLineProcessor

java.lang.Object
  extended by uk.ac.ncl.cs.instantsoap.commandlineprocessor.CommandLineProcessor
All Implemented Interfaces:
MapProcessor

public class CommandLineProcessor
extends Object
implements MapProcessor

A MapProcessor that executes command-line applications.

This is configured with a collection of application descriptors. Given an input, it finds one with a name that matches the job application name and executes it via the command-line.

Author:
Cheng-Yang(Louis) Tang, Matthew Pocock

Constructor Summary
CommandLineProcessor(CommandExecutionStrategy commandExecutionStrategy, ParameterRenamer parameterRenamer, CommandFormatter commandFormatter)
          Construct a new command line processor with the specified configuration objects.
 
Method Summary
 void addApplication(Application app)
          Add an application.
 MetaData describeApplication(String application)
          Describe an application.
 Application getApplication(String appName)
          Get an application by name.
 Set<MetaData> getInputs(String application)
          Get the inputs assocaited with an application.
 Set<MetaData> getOutputs(String application)
          Get the outputs assocaited with an application.
 Map<String,Application> getRegisteredApps()
           
 boolean handlesApplication(String application)
          Indicates if this processor can handle applications with a particuar name.
 List<String> listApplications()
          List all of the applications handled, by name.
 Map<String,String> process(String application, Map<String,String> inputs)
          Handle a request.
 void removeApplication(String appName)
          Remove an application by name.
 void validate(String application, Map<String,String> inputs)
          Validate the inputs for the application.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandLineProcessor

public CommandLineProcessor(CommandExecutionStrategy commandExecutionStrategy,
                            ParameterRenamer parameterRenamer,
                            CommandFormatter commandFormatter)
Construct a new command line processor with the specified configuration objects.

Parameters:
commandExecutionStrategy - the CommandExecutionStrategy that will be used to run command lines
parameterRenamer - the ParameterRenamer encapsulating the rules for mapping between external and internal input and output names
commandFormatter - the CommandFormatter that is able to produce functioning command-line strings
Method Detail

process

public Map<String,String> process(String application,
                                  Map<String,String> inputs)
                           throws JobExecutionException,
                                  UnknownApplicationException
Description copied from interface: MapProcessor
Handle a request.

Specified by:
process in interface MapProcessor
Parameters:
application - the name of the application
inputs - the input Map
Returns:
the result of processing the request
Throws:
JobExecutionException
UnknownApplicationException

addApplication

public void addApplication(Application app)
                    throws ApplicationConfigurationException
Add an application.

Parameters:
app - the Application to add
Throws:
ApplicationConfigurationException - if the application failed validation or an application with the same name is already present.

getApplication

public Application getApplication(String appName)
                           throws UnknownApplicationException
Get an application by name.

Parameters:
appName - the name of the application to fetch
Returns:
the Application with that name
Throws:
UnknownApplicationException - if there is no application known by appName

removeApplication

public void removeApplication(String appName)
                       throws UnknownApplicationException
Remove an application by name.

Parameters:
appName - the name of the Application to remove
Throws:
UnknownApplicationException - if appName doesn't correspond to a registered application

validate

public void validate(String application,
                     Map<String,String> inputs)
              throws InvalidJobSpecificationException
Description copied from interface: MapProcessor
Validate the inputs for the application.

Specified by:
validate in interface MapProcessor
Parameters:
application - the name of the application
inputs - the Map of input values
Throws:
InvalidJobSpecificationException

handlesApplication

public boolean handlesApplication(String application)
Description copied from interface: MapProcessor
Indicates if this processor can handle applications with a particuar name.

This must return true for exactly those application names listed in listApplicaionts.

Specified by:
handlesApplication in interface MapProcessor
Parameters:
application - the name of the application to be checked
Returns:
true if the application can be handled, false otherwise

listApplications

public List<String> listApplications()
Description copied from interface: MapProcessor
List all of the applications handled, by name.

Specified by:
listApplications in interface MapProcessor
Returns:
the List of handled applications

describeApplication

public MetaData describeApplication(String application)
                             throws UnknownApplicationException
Description copied from interface: MapProcessor
Describe an application.

Specified by:
describeApplication in interface MapProcessor
Parameters:
application - the name of the application
Returns:
the MetaData with the name matching application providing the description and semantic annotation for this application
Throws:
UnknownApplicationException

getInputs

public Set<MetaData> getInputs(String application)
                        throws UnknownApplicationException
Description copied from interface: MapProcessor
Get the inputs assocaited with an application.

Specified by:
getInputs in interface MapProcessor
Parameters:
application - the name of the application
Returns:
the application inputs as a Set of MetaData instances
Throws:
UnknownApplicationException

getOutputs

public Set<MetaData> getOutputs(String application)
                         throws UnknownApplicationException
Description copied from interface: MapProcessor
Get the outputs assocaited with an application.

Specified by:
getOutputs in interface MapProcessor
Parameters:
application - the name of the application
Returns:
the application outputs as a Set of MetaData instances
Throws:
UnknownApplicationException

getRegisteredApps

public Map<String,Application> getRegisteredApps()


Copyright © 2006-2008. All Rights Reserved.