Skip to content
Laurent Jourdren edited this page Apr 11, 2017 · 3 revisions

Writing Action class

WARNING: This documentation is outdated and will soon be updated.

Introduction

An Action is a command launched by the Eoulsan user on command line. For example in the next Eoulsan command:

$ eoulsan.sh exec param-local.xml design.txt

exec is the action.

Writing an Action class

The following code shows a basic Action class

public class MyAction extends AbstractAction{

  @Override
  public String getName() {
    
    return "myaction";
  }

  @Override
  public String getDescription() {
    
    return "my test action.";
  }

  @Override
  public void action(final String[arguments) {
    
     System.out.println("My action arguments: " + Arrays.toStrint(arguments);    
  }

When the program enters in the action(), the EoulsanRuntime is already started, so you can use DataFile object in your Action class.

Once class is written, don't forget to register it by adding the full name of the class in the fr.ens.transcriptome.eoulsan.actions.Action text file in the META-INF/services directory. See the Writing Step Plugin for more information:

com.example.MyAction

Test the new Action class

After adding the jar file of your plugin, when you launch eoulsan help, you can see your action in the list of the available commands:

$ eoulsan.sh -h
usage: eoulsan [options](]) command arguments
 -about              display information about this software
 -conf <file>        configuration file to use
 -h,--help           display this help
 -license            display information about the license of this
                     software
 -log <file>         external log file
 -loglevel <level>   log level
 -version            show version of the software
Available commands:
 - awsexec	execute eoulsan on Amazon cloud.
 - createdesign	create a design file from a list of files.
 - createhadoopjar	create a jar file for hadoop with all dependencies include.
 - exec	execute Eoulsan in local mode. (not availlable for your platform).
 - hadoopexec	execute Eoulsan on local hadoop cluster. (not availlable for your platform).
 - s3upload	upload data on Amazon S3.
 - myaction	my test action.

You can also launch your action:

$ eoulsan.sh myaction foo bar
My action arguments: ["bar"]("foo",)

Parsing command line arguments

We use the apache common CLI API to parse arguments of built-in Actions. We strongly advise you to do it also. You can see the source of the classes of the fr.ens.transcriptome.eoulsan.actions here.