com.continuent.tungsten.replicator.applier.batch
Class JavascriptRuntime

java.lang.Object
  extended by com.continuent.tungsten.replicator.applier.batch.JavascriptRuntime

public class JavascriptRuntime
extends java.lang.Object

Implements a runtime that can be provided to Javascript scripts with useful functions like launching an OS process or failing with an exception.


Constructor Summary
JavascriptRuntime()
           
 
Method Summary
 java.lang.String exec(java.lang.String command)
          Execute an OS command and return the result of stdout.
 java.lang.String parameterize(java.lang.String command, java.util.Map<java.lang.String,java.lang.String> parameters)
          Substitutes parameter values from a Map into a command.
 java.lang.String sprintf(java.lang.String format, java.lang.Object... args)
          Supplies equivalent of sprintf function for Javascript callers to use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavascriptRuntime

public JavascriptRuntime()
Method Detail

exec

public java.lang.String exec(java.lang.String command)
                      throws ReplicatorException
Execute an OS command and return the result of stdout.

Parameters:
command - Command to run
Returns:
Returns output of the command in a string
Throws:
ReplicatorException - Thrown if command execution fails

parameterize

public java.lang.String parameterize(java.lang.String command,
                                     java.util.Map<java.lang.String,java.lang.String> parameters)
Substitutes parameter values from a Map into a command. This is used to apply %%PARM%% style-parameters to a command template.

Parameters:
command - Command template with parameter names
parameters - Map containing name value pairs of parameters
Returns:
Fully parameter

sprintf

public java.lang.String sprintf(java.lang.String format,
                                java.lang.Object... args)
Supplies equivalent of sprintf function for Javascript callers to use.

Parameters:
format - Printf-style format string
args - Varargs values to substitute into the format.
Returns:
Formatted string