2.1.2.3 Embedded Mode
In embedded mode, you instantiate an instance of the TXST interpreter in your Java code and use it to run TXST commands and scripts. Except for startRecording() and stopRecording(), all TXST commands and variables that you use in interactive and script mode can be run in embedded mode.
The following code snippet illustrates how to instantiate an instance of the TXST interpreter and use it to connect to a running domain and create a server.
Running TXST From a Java Class
import java.util.*;
import oracle.tuxedo.jmx.tux.jyscript.TXSTInterpreter;
import org.python.util.InteractiveInterpreter;
public class EmbeddedTXST {
static InteractiveInterpreter interp = null;
EmbeddedTXST() {
interp = new TXSTInterpreter();
}
private static void connect() {
interp.exec("connect('//localhost:5037', 'simpapp', ‘38075’)");
}
private static void create_server() {
StringBuffer buffer = new StringBuffer();
buffer.append("cd('simple/GROUP1')\n");
buffer.append("srv1= create(‘simpserv’, ‘SERVER’, srvID=40)\n");
buffer.append("print 'Script ran successfully...'\n");
interp.exec(buffer.toString());
}
public static void main(String[] args) {
new EmbeddedTXST();
connect();
create_server();
}
}Parent topic: Modes of Operation