> For the complete documentation index, see [llms.txt](https://attivio.gitbook.io/sdk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://attivio.gitbook.io/sdk/custom-executables.md).

# Custom Executables

Custom executable functionality can be added to an Attivio project and/or install such that, by entering a command, a user can execute custom code as part of the Attivio environment but in a separate process.

## Implementing AttivioRunnable

`AttivioRunnable` is an interface much like `java.lang.Runnable` in that it has an abstract run method. A class implementing `AttivioRunnable` and supplying a body for that run method can be run using the `aie-exec` executable in the bin directory of any Attivio installation.

In order to take command line arguments to the executable, this class must have getters and setters for all fields to be optained through the command line. The getters should be annotated with `@ConfigurationOption` so that they can be given certain properties as command line arguments such as description, whether or not they are required, and short option for specification. See a sample custom runnable below.

```java
@ConfigurationOption(description="This writes messages to the log file")
public class MyAttivioRunnable implements AttivioRunnable {
  private String message;

  public int run() throws AttivioException {
    Logger.getLogger(MyAttivioRunnable.class).info(message);
  } 

  @ConfigurationOption(optionLevel=OptionLevel.Required, shortOpt="m", description="This message will be written to the log file")
  public String getMessage() {
    return message;
  }

  public void setMessage(String message) {
    this.message = message;
  }
}
```

## Registering the Custom Executable the Module

Any executable classes created in the manner above should be registered in the `executables` field in the `attivio.module.json` file. The attivio module sdk documentation has more information on this.

## Calling an AttivioRunnable

If everything is configured properly as described above, the custom executable should show up in the list of executables available from `aie-exec`:

```
> ./aie_install/bin/aie-exec -h
...
Configured executables:
  myExecutable - This writes messages to the log file
    (com.myapp.MyAttivioRunnable)
...
> ./aie_install/bin/aie-exec myExecutable -h
...
Command Line Options:
 -m, --message <arg>    This message will be written to the log file
...
> ./aie_install/bin/aie-exec myExecutable -m "hello to the log file"
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://attivio.gitbook.io/sdk/custom-executables.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
