Sesat > Docs + Support > Debugging > Sesat-Interpreter

The Sesat-Interpreter

Basic usage

The Sesat-Interpreter is a simple interpreter that let's you add commands with some arbitrary code assosiated with it.

To enable the Sesat-Interpreter set/export SESAT_INTERPRETER=true

an example of how to add a command:
import no.sesat.Interpreter;

static {
    Interpreter.addFunction("gc", new Function() {
        public String execute(final Context ctx) {
            return "GC requested";
        public String describe() {
            return "Request a gc run.";

When you start catelina from the commandline, and the interpreter has been enabled by setting the SESAT_INTERPRETER enironment variable to true, then you will see the functions as they are added.

Console output
Added function: test-arguments
Added function: help
Added function: gc
Added function: all-stacktraces
Added function: loggers
Added function: properties
Added function: save
Added function: read
Added function: macro
Added function: quit
Added function: sites

Now you can invoke a method by typing in it's name.

Console output
Functions available:
        Look at all stacktraces.
        Echo arguments.
        Request a gc run.
        Print this help message
        Print active loggers, and set level if specified. 'loggers [regexp] [level]'
        Make a macro
        List System.getProperties()

test-arguments 1 2 query='en fisk'
Raw argument string:
    1 2 query='en fisk'
Argument array: 2
    QUERY --> en fisk

Most of the functions added, like the one in at the top, are in static blocks. This means that the function will be added when the class is loaded. So all functions might not be available at once.


Some times you do not want to introduce code permanently, then you might want to use AspectJ to instrument the classes. Have a look at this aspectj class.

If you want your aspect code to be active you need to include the interpreter-aspectj profile when building.

I use this:
-P include-fast,development,interpreter-aspectj


Enable this by setting JAVA_OPTS=-javaagent:/home/haavard/.m2/repository/sesat/commons-interpreter/2.0/commons-interpreter-2.0.jar

where home/haavard.... should be changed to wherever you have it.

 © 2007-2009 Schibsted ASA
Contact us