Package com.jprofiler.api.agent
Interface ScriptContext
public interface ScriptContext
Context object that is passed to all scripts and provides ways to store key-value pairs for all subsequent
invocations of any custom script.
For example, if you need to calculate the change of an observed numeric value between script invocations, you can use the context as follows:
long previousValue = scriptContext.getLong("myValue");
long currentValue = ...;
long delta = currentValue - previousValue;
// Use delta
scriptContext.putLong("myValue", currentValue); // for the next invocation of the script
-
Method Summary
Modifier and TypeMethodDescriptionlong
Store a key-value pair of value type long in the script context.Store a key-value pair in the script context.long
Store a key-value pair of value type long in the script context.Store a key-value pair in the script context.
-
Method Details
-
getObject
Store a key-value pair in the script context.- Parameters:
key
- the key- Returns:
- the value, or
null
if there was no mapping for the key.
-
putObject
Store a key-value pair in the script context. An existing mapping is overwritten.- Parameters:
key
- the keyvalue
- the value- Returns:
- the value that was previously associated with specified key, or
null
if there was no mapping for the key.
-
getLong
Store a key-value pair of value type long in the script context.- Parameters:
key
- the key- Returns:
- the long value, or 0 if there was no mapping
-
putLong
Store a key-value pair of value type long in the script context. An existing mapping is overwritten.- Parameters:
key
- the keyvalue
- the long value- Returns:
- the value that was previously associated with specified key, or 0 if there was no mapping for the key.
-