Context Variables Quick Reference
Quick lookup for all built-in variables available in your plugins
Variable Summary Table
Variable | Type | Purpose | Quick Example |
---|---|---|---|
named_jdbc | NamedParameterJdbcTemplate | SQL queries with named parameters (recommended) | named_jdbc.queryForMap("SELECT * FROM table WHERE id = :id", ["id": 123]) |
http | PluginHttpClient | HTTP requests with retry support | http.get("https://api.example.com/data") |
files | PluginFileClient | File I/O operations | files.read("config.json") |
state | State | Plugin-specific persistent storage | state.put("lastBlock", 12345) |
global_state | State | Global storage shared across plugins | global_state.get("networkTip") |
env | Environment | Access configuration properties | env.getProperty("api.key") |
Which Variable Should I Use?
For Database Operations
- Need to query the database? → Use
named_jdbc
- 📖 Full Database Guide
For HTTP/API Calls
- Need to call external APIs? → Use
http
- 📖 Full HTTP Client Guide
For File Operations
- Need to read/write files? → Use
files
- Working with JSON/CSV? →
files
has built-in support - 📖 Full File Operations Guide
For State Management
- Store data for this plugin only? → Use
state
- Share data between plugins? → Use
global_state
- Need atomic operations? → Both support atomic methods
- 📖 Full State Management Guide
For Configuration
- Need environment variables or properties? → Use
env
- 📖 Full Configuration Guide
Common Code Patterns
Database Query with Results
// MVEL - Get count from database
params = ["status": "active"];
result = named_jdbc.queryForMap(
"SELECT COUNT(*) as count FROM users WHERE status = :status",
params
);
count = result["count"];
HTTP POST with Retry
// JavaScript - Send webhook with automatic retry
const response = http.postJson("https://webhook.site/unique-id",
{
event: "user_action",
count: eventCount
});
State with Atomic Counter
// MVEL - Track processed items
itemCount = state.increment("items_processed");
if (itemCount % 100 == 0) {
log.info("Processed " + itemCount + " items");
}
File Operations with JSON
// JavaScript - Read config and write results
const config = files.readJson("config.json");
if (config.isSuccess()) {
const settings = config.getData();
// Process with settings...
files.writeJson("output.json", results);
}