Package com.attivio.sdk.commandline
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. TheCommandLineRunner
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; } }
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CREDENTIALS_ARG
the credentials argumentstatic java.lang.String
CREDENTIALS_DESCRIPTION
description for credentialsstatic int
RETURN_CODE_ERROR
The return code to indicate an error occurred requiring shutdown.static int
RETURN_CODE_FORCED
The return code to indicate the user forced shutdown.static int
RETURN_CODE_OK
The return code to indicate normal shutdown occurred.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
run()
Perform logic and return one ofRETURN_CODE_OK
,RETURN_CODE_ERROR
.
-
-
-
Field Detail
-
CREDENTIALS_DESCRIPTION
static final java.lang.String CREDENTIALS_DESCRIPTION
description for credentials- See Also:
- Constant Field Values
-
CREDENTIALS_ARG
static final java.lang.String CREDENTIALS_ARG
the credentials argument- See Also:
- Constant Field Values
-
RETURN_CODE_OK
static final int RETURN_CODE_OK
The return code to indicate normal shutdown occurred.- See Also:
- Constant Field Values
-
RETURN_CODE_ERROR
static final int RETURN_CODE_ERROR
The return code to indicate an error occurred requiring shutdown.- See Also:
- Constant Field Values
-
RETURN_CODE_FORCED
static final int RETURN_CODE_FORCED
The return code to indicate the user forced shutdown.- See Also:
- Constant Field Values
-
-
Method Detail
-
run
int run() throws AttivioException
Perform logic and return one ofRETURN_CODE_OK
,RETURN_CODE_ERROR
.- Throws:
AttivioException
-
-