OpenAF plugins
Plugins expose Java functionality to OpenAF’s JavaScript runtime. Load a plugin with plugin("Name"); load JavaScript wrapper modules with their ow.load…() function or an oPack’s documented loadLib() entry point.
Core and optional plugins
| Capability | Load / documentation |
|---|---|
| HTTP client and WebSockets | plugin("HTTP"); HTTP guide |
| HTTP server | plugin("HTTPServer"); server guide |
| SSH and SFTP | plugin("SSH"); SSH guide |
| ZIP archives | plugin("ZIP"); ZIP guide |
| Threads and scheduling | plugin("Threads"); Threads guide |
plugin("Email"); Email guide |
|
| XML | Java XML plugin and E4X |
| SNMP / JMX | SNMP, JMX |
| Spreadsheets | Install plugin-XLS, then plugin("XLS"); spreadsheet guide |
| Git, SMB, SVN, Ignite and JavaFX | Separate oPacks; see the package catalog |
HTTPd and HTTPws are not core plugin names. Use HTTPServer for servers and the HTTP plugin’s WebSocket methods. XLS and Ignite are optional packages, not part of every core installation.
HTTP requests
For JSON APIs, $rest() returns the decoded result directly:
var data = $rest({ throwExceptions: true }).get("https://api.example.com/data");
print(data);
Do not chain .getResponse() onto the object returned by $rest().get(). The lower-level HTTP client has its own request and response methods; see the HTTP reference.
SSH sessions
The constructor opens the session. Close it when the work is complete:
plugin("SSH");
var ssh = new SSH("host.example", 22, "user", "password");
try {
print(ssh.exec("uname -s"));
} finally {
ssh.close();
}
The host and credentials are placeholders. Follow the SSH reference for private keys, host-key handling, timeouts and return options.
ZIP archives
plugin("ZIP");
var zip = new ZIP();
try {
zip.putFile("hello.txt", af.fromString2Bytes("Hello\n"));
io.writeFileBytes("example.zip", zip.generate({ compressionLevel: 9 }));
} finally {
zip.close();
}
putFile receives bytes for the archive entry. To archive a local file, pass io.readFileBytes(path). The ZIP reference also documents streaming operations and resource ownership.
Loading and troubleshooting
Install an optional package before loading its plugin, and check its JVM/native requirements. Use opack list to inspect installed packages and help in oafc to inspect the runtime’s API. ClassNotFoundException usually requires checking the package’s JARs, classpath and Java version.
A Java class alone is not automatically a scriptable OpenAF plugin. Follow the core plugin guide and an existing plugin implementation for Rhino bindings, constructors and exported methods.