org.ceryle.script
Class GroovyService

java.lang.Object
  extended by org.ceryle.script.GroovyService

public class GroovyService
extends Object

Implements support for Groovy-based scripting.

This supports both Interpret Script and Script Console commands on the View menu, the latter opening up a console written in the scripting language Groovy (rather than Java).

Since:
JDK1.4
Version:
$Id: GroovyService.java,v 1.5 2007-06-20 01:28:14 altheim Exp $
Author:
Murray Altheim

Field Summary
static String DEFAULT_CONSOLE_SCRIPT
          The default value for the path to the Groovy console script.
static String GROOVY_VERSION
          The Groovy JSR version.
protected static groovy.util.GroovyScriptEngine m_gse
          The single instance of the GroovyScriptEngine used by this class.
static String PROPERTY_SCRIPTS_PATH
          The System property name for the path to the Groovy 'scripts' directory.
 
Constructor Summary
GroovyService(MessageWriter messagewriter, String scriptsPath)
          Constructor with a MessageWriter and a required pathname scriptsPath, which points to the default 'scripts' directory.
 
Method Summary
 void closeService()
          This should be called prior to the GroovyService going away.
 void console()
          Display a Groovy Console.
 groovy.util.GroovyScriptEngine getGroovyScriptEngine()
          Return the GroovyScriptEngine.
static boolean hasService()
          Returns true if the (static) GroovyScriptEngine has been initialized.
 boolean interpret(File file)
          Interpret the incoming script (sourced from File file), returning true if successful.
 boolean interpret(String script)
          Interpret the incoming script, returning true if successful.
 void print(String message)
           
 void println(String message)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CONSOLE_SCRIPT

public static String DEFAULT_CONSOLE_SCRIPT
The default value for the path to the Groovy console script.


PROPERTY_SCRIPTS_PATH

public static final String PROPERTY_SCRIPTS_PATH
The System property name for the path to the Groovy 'scripts' directory. The value is "groovy-scripts-path".

See Also:
Constant Field Values

GROOVY_VERSION

public static final String GROOVY_VERSION
The Groovy JSR version. This must unfortunately be updated to match the current Groovy distribution. This value shows up in the console's About box.

See Also:
Constant Field Values

m_gse

protected static groovy.util.GroovyScriptEngine m_gse
The single instance of the GroovyScriptEngine used by this class.

Constructor Detail

GroovyService

public GroovyService(MessageWriter messagewriter,
                     String scriptsPath)
              throws ScriptException
Constructor with a MessageWriter and a required pathname scriptsPath, which points to the default 'scripts' directory. If the parameter is null, the System property PROPERTY_SCRIPTS_PATH will be tried.

Throws:
ScriptException
Method Detail

getGroovyScriptEngine

public groovy.util.GroovyScriptEngine getGroovyScriptEngine()
                                                     throws ScriptException
Return the GroovyScriptEngine.

Throws:
ScriptException

console

public void console()
Display a Groovy Console. Rather than throw an exception, this reports any problems to the MessageHandler and returning null if unable to create and display a console.


interpret

public boolean interpret(File file)
Interpret the incoming script (sourced from File file), returning true if successful. All errors are sent to the MessageHandler.


println

public void println(String message)

print

public void print(String message)

interpret

public boolean interpret(String script)
Interpret the incoming script, returning true if successful. Any messages, warnings or errors are sent to the MessageHandler.


hasService

public static boolean hasService()
Returns true if the (static) GroovyScriptEngine has been initialized.


closeService

public void closeService()
This should be called prior to the GroovyService going away.



The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.