Interface AttivioRunnable


  • public interface AttivioRunnable
    Describes a class that can be run from the command line and provides automatic command line argument parsing.

    AttivioRunnable subclasses should be written as standard java beans with get/set methods for all options. By default all bean properties will be converted to command line options however ConfigurationOption annotations can be added to the get methods to provide more information about the option. Currently only base data types plus Lists and Maps are supported for command line argument generation and parsing. The CommandLineRunner class is used to invoke AttivioRunnables.

    Implementations which wish to handle SIGINT (ctrl-c) must also implement AttivioStoppable.

    Example Code

     public class MyRunnable implements AttivioRunnable {
    
       private String foo = null;
       private int count = 0;
    
       @Override
       public int run() throws AttivioException {
         System.err.println(foo + "=" + count);
       }
    
       @ConfigurationOption(required = true, description = "Foo value", shortOpt = "f")
       public String getFoo() {
         return foo;
       }
    
       public void setFoo(String newFoo) {
         foo = newFoo;
       }
    
       // automatically uses --count for command line option
       public int getCount() {
         return count;
       }
    
       public void setCount(int newCount) {
         count = newCount;
       }
     }