You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@turbine.apache.org by sg...@apache.org on 2010/04/24 23:33:29 UTC
svn commit: r937706 - in /turbine/fulcrum/trunk/script:
src/java/org/apache/fulcrum/script/
src/java/org/apache/fulcrum/script/impl/ src/test/
src/test/org/apache/fulcrum/script/ src/test/scripts/groovy/
src/test/scripts/js/ xdocs/
Author: sgoeschl
Date: Sat Apr 24 21:33:28 2010
New Revision: 937706
URL: http://svn.apache.org/viewvc?rev=937706&view=rev
Log:
Syncing the ASF repo with my local development
Modified:
turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/ScriptAvalonContext.java
turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/ScriptRunnable.java
turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/ScriptService.java
turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/ScriptAvalonContextImpl.java
turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/ScriptBaseService.java
turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/ScriptCacheEntry.java
turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/ScriptEngineEntry.java
turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/ScriptRunnableImpl.java
turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/ScriptServiceImpl.java
turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/Validate.java
turbine/fulcrum/trunk/script/src/test/TestGroovyComponentConfig.xml
turbine/fulcrum/trunk/script/src/test/TestRhinoComponentConfig.xml
turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/AbstractScriptTest.java
turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/GroovyTest.java
turbine/fulcrum/trunk/script/src/test/scripts/groovy/Avalon.groovy
turbine/fulcrum/trunk/script/src/test/scripts/groovy/CompilableInterface.groovy
turbine/fulcrum/trunk/script/src/test/scripts/groovy/HelloWorld.groovy
turbine/fulcrum/trunk/script/src/test/scripts/groovy/NamespaceDemo2.groovy
turbine/fulcrum/trunk/script/src/test/scripts/groovy/NamespaceDemo3.groovy
turbine/fulcrum/trunk/script/src/test/scripts/groovy/RuntimeError.groovy
turbine/fulcrum/trunk/script/src/test/scripts/js/Avalon.js
turbine/fulcrum/trunk/script/src/test/scripts/js/CompilableInterface.js
turbine/fulcrum/trunk/script/src/test/scripts/js/HelloWorld.js
turbine/fulcrum/trunk/script/src/test/scripts/js/InvocableIntf.js
turbine/fulcrum/trunk/script/src/test/scripts/js/MultiThreaded.js
turbine/fulcrum/trunk/script/src/test/scripts/js/NamespaceDemo2.js
turbine/fulcrum/trunk/script/src/test/scripts/js/NamespaceDemo3.js
turbine/fulcrum/trunk/script/xdocs/index.xml
Modified: turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/ScriptAvalonContext.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/ScriptAvalonContext.java?rev=937706&r1=937705&r2=937706&view=diff
==============================================================================
--- turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/ScriptAvalonContext.java (original)
+++ turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/ScriptAvalonContext.java Sat Apr 24 21:33:28 2010
@@ -29,28 +29,37 @@ import org.apache.avalon.framework.param
import org.apache.avalon.framework.service.ServiceManager;
/**
- * Holder class for Avalon related artifacts to be passed to a script.
+ * Holder class for Avalon related artifacts to be passed to a script. This
+ * allows full access to Avalon service framework from within the script.
*
* @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
*/
public interface ScriptAvalonContext
{
/**
+ * Get the Avalon configuration.
+ *
* @return Returns the configuration
*/
Configuration getConfiguration();
/**
+ * Get the Avalon context.
+ *
* @return Returns the context.
*/
Context getContext();
/**
+ * Get the Avalon logger to access the logger from within the script.
+ *
* @return Returns the logger.
*/
Logger getLogger();
/**
+ * Get the Avalon service manager to lookup services.
+ *
* @return Returns the serviceManager.
*/
ServiceManager getServiceManager();
@@ -61,12 +70,18 @@ public interface ScriptAvalonContext
Parameters getParameters();
/**
+ * Get the working directory of the application.
+ *
* @return Returns the Avalon application directory
+ * @throws ContextException the context entry for the application directory was not found
*/
File getApplicationDir() throws ContextException;
/**
+ * Get the working directory of the application.
+ *
* @return Returns the Avalon application directory
+ * @throws ContextException the context entry for the temp directory was not found
*/
File getTempDir() throws ContextException;
}
Modified: turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/ScriptRunnable.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/ScriptRunnable.java?rev=937706&r1=937705&r2=937706&view=diff
==============================================================================
--- turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/ScriptRunnable.java (original)
+++ turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/ScriptRunnable.java Sat Apr 24 21:33:28 2010
@@ -22,18 +22,23 @@ package org.apache.fulcrum.script;
import java.util.Map;
/**
- * A Runnable executing scripts
+ * A Runnable for executing scripts.
*
* @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
*/
public interface ScriptRunnable extends Runnable
{
/**
+ * Set the arguments for script execution.
+ *
* @param args The args to be used.
*/
void setArgs(Map args);
/**
+ *
+ * Get the result from script execution.
+ *
* @return Returns the result.
*/
Object getResult() throws Exception;
Modified: turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/ScriptService.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/ScriptService.java?rev=937706&r1=937705&r2=937706&view=diff
==============================================================================
--- turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/ScriptService.java (original)
+++ turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/ScriptService.java Sat Apr 24 21:33:28 2010
@@ -19,13 +19,12 @@ package org.apache.fulcrum.script;
* under the License.
*/
-import java.io.IOException;
-
-import javax.script.Namespace;
+import javax.script.Bindings;
import javax.script.ScriptContext;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
+import java.io.IOException;
/**
* An Avalon service to execute scripts based on JSR-223.
@@ -69,12 +68,12 @@ public interface ScriptService
* during the script execution.
*
* @param scriptName the name of the script
- * @param namespace The Namespace of attributes
+ * @param bindings The binding of attributes
* @return result from the executed script
* @throws IOException loading the script failed
* @throws ScriptException if an error occurrs during script execution.
*/
- Object eval( String scriptName, Namespace namespace ) throws IOException, ScriptException;
+ Object eval( String scriptName, Bindings bindings ) throws IOException, ScriptException;
/**
* Causes the immediate execution of the script. State left in the engine
Modified: turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/ScriptAvalonContextImpl.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/ScriptAvalonContextImpl.java?rev=937706&r1=937705&r2=937706&view=diff
==============================================================================
--- turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/ScriptAvalonContextImpl.java (original)
+++ turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/ScriptAvalonContextImpl.java Sat Apr 24 21:33:28 2010
@@ -37,10 +37,10 @@ import org.apache.fulcrum.script.ScriptA
public class ScriptAvalonContextImpl implements ScriptAvalonContext
{
/** context key for persistent directory*/
- private final static String URN_AVALON_HOME = "urn:avalon:home";
+ private final static String URN_AVALON_HOME = "context-root";
/** context key for temporary directory */
- private final static String URN_AVALON_TEMP = "urn:avalon:temp";
+ private final static String URN_AVALON_TEMP = "impl.workDir";
/** the Avalon service manager instance */
private ServiceManager serviceManager;
Modified: turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/ScriptBaseService.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/ScriptBaseService.java?rev=937706&r1=937705&r2=937706&view=diff
==============================================================================
--- turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/ScriptBaseService.java (original)
+++ turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/ScriptBaseService.java Sat Apr 24 21:33:28 2010
@@ -39,8 +39,8 @@ import org.apache.avalon.framework.servi
/**
* Base class for a service implementation capturing the Avalon
- * configuration artifats. This is basically a "copy-and-waste" from
- * the YAAFI framework.
+ * configuration artifacts. This is basically a "copy-and-waste" from
+ * the fulcrum-yaafi framework.
*
* @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
*/
@@ -50,10 +50,10 @@ public abstract class ScriptBaseService
implements Contextualizable, Serviceable, Configurable, Parameterizable, Reconfigurable, Disposable
{
/** context key for persistent directory */
- private final static String URN_AVALON_HOME = "urn:avalon:home";
+ private final static String URN_AVALON_HOME = "context-root";
/** context key for temporary directory */
- private final static String URN_AVALON_TEMP = "urn:avalon:temp";
+ private final static String URN_AVALON_TEMP = "impl.workDir";
/** The context supplied by the avalon framework */
private Context context;
Modified: turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/ScriptCacheEntry.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/ScriptCacheEntry.java?rev=937706&r1=937705&r2=937706&view=diff
==============================================================================
--- turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/ScriptCacheEntry.java (original)
+++ turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/ScriptCacheEntry.java Sat Apr 24 21:33:28 2010
@@ -34,7 +34,7 @@ public class ScriptCacheEntry
/** the plain script */
private String plainScript;
- /** the precompiled script */
+ /** the pre-compiled script */
private CompiledScript compiledScript;
/** the name of the script */
@@ -101,10 +101,10 @@ public class ScriptCacheEntry
}
/**
- * Is the script already compiled
+ * @return Is the script already compiled
*/
public boolean isCompiled()
{
- return ( this.getCompiledScript() != null ? true : false );
+ return (this.getCompiledScript() != null);
}
}
Modified: turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/ScriptEngineEntry.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/ScriptEngineEntry.java?rev=937706&r1=937705&r2=937706&view=diff
==============================================================================
--- turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/ScriptEngineEntry.java (original)
+++ turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/ScriptEngineEntry.java Sat Apr 24 21:33:28 2010
@@ -33,6 +33,9 @@ public class ScriptEngineEntry
/** the name of the script engine */
private String name;
+ /** the default extension of the scripts */
+ private String extension;
+
/** is the script cached or loaded for each execution */
private boolean isCached;
@@ -52,6 +55,7 @@ public class ScriptEngineEntry
* Constructor
*
* @param name the name of the script engine
+ * @param extension the script extension, e.g. "js"
* @param isCached is the script cached or loaded for each execution
* @param isCompiled is the script compiled to improve performance
* @param location the location of the scripts
@@ -59,16 +63,19 @@ public class ScriptEngineEntry
*/
public ScriptEngineEntry(
String name,
+ String extension,
boolean isCached,
boolean isCompiled,
String location,
ScriptEngine scriptEngine)
{
Validate.notEmpty(name, "name");
+ Validate.notEmpty(extension, "extension");
Validate.notEmpty(location, "location");
Validate.notNull(scriptEngine, "scriptEngine");
this.name = name;
+ this.extension = extension;
this.isCached = isCached;
this.isCompiled = isCompiled;
this.location = location;
@@ -108,6 +115,13 @@ public class ScriptEngineEntry
}
/**
+ * @return Returns the script extension
+ */
+ public String getExtension() {
+ return extension;
+ }
+
+ /**
* @return Returns the scriptEngine.
*/
public ScriptEngine getScriptEngine()
Modified: turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/ScriptRunnableImpl.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/ScriptRunnableImpl.java?rev=937706&r1=937705&r2=937706&view=diff
==============================================================================
--- turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/ScriptRunnableImpl.java (original)
+++ turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/ScriptRunnableImpl.java Sat Apr 24 21:33:28 2010
@@ -21,7 +21,7 @@ package org.apache.fulcrum.script.impl;
import java.util.Map;
-import javax.script.SimpleNamespace;
+import javax.script.SimpleBindings;
import org.apache.fulcrum.script.ScriptRunnable;
import org.apache.fulcrum.script.ScriptService;
@@ -40,7 +40,7 @@ public class ScriptRunnableImpl implemen
private ScriptService scriptService;
/** the arguments for executing the script */
- private SimpleNamespace args;
+ private SimpleBindings args;
/** the result of the execution */
private Object result;
@@ -65,7 +65,7 @@ public class ScriptRunnableImpl implemen
this.scriptName = scriptName;
this.scriptService = scriptService;
- this.args = new SimpleNamespace(args);
+ this.args = new SimpleBindings(args);
}
/**
@@ -114,7 +114,7 @@ public class ScriptRunnableImpl implemen
public void setArgs(Map args)
{
Validate.notNull( args, "args" );
- this.args = new SimpleNamespace(args);
+ this.args = new SimpleBindings(args);
}
/**
Modified: turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/ScriptServiceImpl.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/ScriptServiceImpl.java?rev=937706&r1=937705&r2=937706&view=diff
==============================================================================
--- turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/ScriptServiceImpl.java (original)
+++ turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/ScriptServiceImpl.java Sat Apr 24 21:33:28 2010
@@ -29,7 +29,7 @@ import java.util.Set;
import javax.script.Compilable;
import javax.script.CompiledScript;
import javax.script.Invocable;
-import javax.script.Namespace;
+import javax.script.Bindings;
import javax.script.ScriptContext;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
@@ -196,16 +196,16 @@ public class ScriptServiceImpl
}
/**
- * @see org.apache.fulcrum.script.ScriptService#eval(java.lang.String, javax.script.Namespace)
+ * @see org.apache.fulcrum.script.ScriptService#eval(java.lang.String, javax.script.Bindings)
*/
- public Object eval(String scriptName, Namespace namespace)
+ public Object eval(String scriptName, Bindings binding)
throws IOException, ScriptException
{
Validate.notEmpty(scriptName, "scriptName");
- Validate.notNull(namespace, "namespace");
+ Validate.notNull(binding, "binding");
String currScriptName = this.makeScriptName(scriptName);
ScriptCacheEntry scriptCacheEntry = this.createScriptCacheEntry(currScriptName);
- Object result = this.doEval( scriptCacheEntry, namespace, null );
+ Object result = this.doEval( scriptCacheEntry, binding, null );
return result;
}
@@ -291,9 +291,14 @@ public class ScriptServiceImpl
}
/**
+ * Invokes a global script method.
+ *
* @param engineName the engine name
- * @param clazz the inteface to implement
+ * @param name the script method to invoke
+ * @param args the arguments for the script method
* @return a scripting object implementing the given interface
+ * @throws ScriptException script execution failed
+ * @throws NoSuchMethodException the script method was nout found
*/
private Object call(String engineName, String name, Object[] args)
throws ScriptException, NoSuchMethodException
@@ -338,8 +343,10 @@ public class ScriptServiceImpl
/**
* Load a script from the persistent storage.
*
- * @param scriptName the name of the Groovy script
+ * @param engineName the script engine for executing the script
+ * @param scriptName the name of the script
* @return the plain content of the script
+ * @throws IOException loading the script failed
*/
private String loadScript( String engineName, String scriptName )
throws IOException
@@ -349,11 +356,11 @@ public class ScriptServiceImpl
String result = null;
byte[] scriptContent = null;
- String[] sriptContext = {};
+ String[] scriptContext = {};
scriptContent = this.getResourceManagerService().read(
location,
- sriptContext,
+ scriptContext,
scriptName
);
@@ -364,6 +371,7 @@ public class ScriptServiceImpl
/**
* Creates a compiled script.
*
+ * @param engineName the script engine to use
* @param scriptName the name of the scipt to compile
* @param scriptContent the name scipt to compile
* @return the compiled script
@@ -404,10 +412,13 @@ public class ScriptServiceImpl
* Evaluates a script.
*
* @param scriptCacheEntry the script to run
- * @param namespace the parameters to pass to the script
+ * @param binding the parameters to pass to the script
+ * @param scriptContext the script context
* @return the result of the executed script
+ * @throws ScriptException executing the script failed
*/
- private Object doEval( ScriptCacheEntry scriptCacheEntry, Namespace namespace, ScriptContext scriptContext ) throws ScriptException
+ private Object doEval( ScriptCacheEntry scriptCacheEntry, Bindings binding, ScriptContext scriptContext )
+ throws ScriptException
{
Object result = null;
String scriptName = scriptCacheEntry.getScriptName();
@@ -420,9 +431,9 @@ public class ScriptServiceImpl
if( scriptCacheEntry.isCompiled() )
{
- if( namespace != null )
+ if( binding != null )
{
- result = scriptCacheEntry.getCompiledScript().eval(namespace);
+ result = scriptCacheEntry.getCompiledScript().eval(binding);
}
else if( scriptContext != null )
{
@@ -435,9 +446,9 @@ public class ScriptServiceImpl
}
else
{
- if( namespace != null )
+ if( binding != null )
{
- result = scriptEngine.eval(scriptCacheEntry.getPlainScript(), namespace);
+ result = scriptEngine.eval(scriptCacheEntry.getPlainScript(), binding);
}
else if( scriptContext != null )
{
@@ -470,7 +481,14 @@ public class ScriptServiceImpl
}
/**
- * Invokes a global script method
+ * Invokes a global script method.
+ *
+ * @param engineName the name of the script engine to use
+ * @param name the name of the script method
+ * @param args the script method parameters
+ * @return the result of the script invocation
+ * @throws ScriptException if an error occurrs during invocation of the method.
+ * @throws NoSuchMethodException if method with given name or matching argument types cannot be found.
*/
private Object doCall( String engineName, String name, Object[] args )
throws ScriptException, NoSuchMethodException
@@ -483,7 +501,7 @@ public class ScriptServiceImpl
try
{
long startTime = System.currentTimeMillis();
- result = invocable.call(name, args);
+ result = invocable.invokeFunction(name, args);
long endTime = System.currentTimeMillis();
if( this.getLogger().isDebugEnabled() )
@@ -498,13 +516,13 @@ public class ScriptServiceImpl
}
catch( ScriptException e )
{
- String msg= "Caling the following method failed : " + name;
+ String msg= "Calling the following method failed : " + name;
this.getLogger().error( msg, e );
throw e;
}
catch( NoSuchMethodException e )
{
- String msg= "Caling the following method failed : " + name;
+ String msg= "Calling the following method failed : " + name;
this.getLogger().error( msg, e );
throw e;
}
@@ -549,7 +567,9 @@ public class ScriptServiceImpl
}
/**
- * Create the Avalon specific context
+ * Create the Avalon specific context.
+ *
+ * @return the Avalon context for the script
*/
private ScriptAvalonContext createScriptAvalonContext()
{
@@ -592,6 +612,8 @@ public class ScriptServiceImpl
*
* @param scriptName the name of the script to execute
* @return ScriptCacheEntry
+ * @throws IOException the script could not be loaded
+ * @throws ScriptException the script could not be parsed by the script engine
*/
private synchronized ScriptCacheEntry createScriptCacheEntry(String scriptName)
throws IOException, ScriptException
@@ -605,7 +627,7 @@ public class ScriptServiceImpl
// try to load the script from the cache or from the resource manager
- if( scriptEngineEntry.isCached() == true )
+ if(scriptEngineEntry.isCached())
{
scriptCacheEntry = this.getScriptCache().get(scriptName);
@@ -624,7 +646,7 @@ public class ScriptServiceImpl
plainScript = this.loadScript(engineName, scriptName);
}
- if( isInCache == false )
+ if(!isInCache)
{
// compile the script if required
@@ -662,17 +684,18 @@ public class ScriptServiceImpl
throws ConfigurationException
{
String name = configuration.getChild("name").getValue();
+ String extension = configuration.getChild("extension").getValue(name);
boolean isCached = configuration.getChild("isCached").getValueAsBoolean(true);
boolean isCompiled = configuration.getChild("isCompiled").getValueAsBoolean(true);
String location = configuration.getChild("location").getValue(name);
ScriptEngine scriptEngine = this.getScriptEngineManager().getEngineByName(name);
- if( (scriptEngine instanceof Compilable) == false )
+ if(!(scriptEngine instanceof Compilable))
{
isCompiled = false;
}
- ScriptEngineEntry result = new ScriptEngineEntry(name, isCached, isCompiled, location, scriptEngine);
+ ScriptEngineEntry result = new ScriptEngineEntry(name, extension, isCached, isCompiled, location, scriptEngine);
// evaluate the given scripts
@@ -718,7 +741,8 @@ public class ScriptServiceImpl
if( pos > 0 )
{
- return scriptName.substring(pos+1, scriptName.length());
+ String extension = scriptName.substring(pos+1, scriptName.length());
+ return this.getEngineNameForExtension(extension);
}
else
{
@@ -727,6 +751,29 @@ public class ScriptServiceImpl
}
/**
+ * Determines the scripting engine based on the extension
+ *
+ * @param extension the script name extension
+ * @return name of the scripting engine
+ */
+ private String getEngineNameForExtension( String extension )
+ {
+ Iterator iter = this.scriptEngineMap.keySet().iterator();
+
+ while( iter.hasNext() )
+ {
+ String engineName = (String) iter.next();
+ ScriptEngineEntry scriptEngineEntry = this.getScriptEngineEntry(engineName);
+ if(scriptEngineEntry.getExtension().equalsIgnoreCase(extension))
+ {
+ return engineName;
+ }
+ }
+
+ throw new IllegalArgumentException("Unknow script extension : " + extension);
+ }
+
+ /**
* @return Returns the scriptEngineMap.
*/
private HashMap getScriptEngineMap()
@@ -743,7 +790,8 @@ public class ScriptServiceImpl
private String makeScriptName( String name )
{
String engineName = this.getEngineName(name);
- String extension = '.' + engineName;
+ ScriptEngineEntry scriptEngineEntry = this.getScriptEngineEntry(engineName);
+ String extension = '.' + scriptEngineEntry.getExtension();
if( name.endsWith(extension) )
{
Modified: turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/Validate.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/Validate.java?rev=937706&r1=937705&r2=937706&view=diff
==============================================================================
--- turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/Validate.java (original)
+++ turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/Validate.java Sat Apr 24 21:33:28 2010
@@ -38,7 +38,6 @@ import java.util.Map;
* @author Gary Gregory
* @author Norm Deane
* @since 2.0
- * @version $Id: Validate.java,v 1.1.1.1 2005/12/28 12:10:22 sigi Exp $
*/
public class Validate
{
Modified: turbine/fulcrum/trunk/script/src/test/TestGroovyComponentConfig.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/script/src/test/TestGroovyComponentConfig.xml?rev=937706&r1=937705&r2=937706&view=diff
==============================================================================
--- turbine/fulcrum/trunk/script/src/test/TestGroovyComponentConfig.xml (original)
+++ turbine/fulcrum/trunk/script/src/test/TestGroovyComponentConfig.xml Sat Apr 24 21:33:28 2010
@@ -20,39 +20,49 @@
<componentConfig>
- <ResourceManagerService>
- <domain name="groovy">
- <suffix>groovy</suffix>
- <location>./src/test/scripts/groovy</location>
- <useLocator>true</useLocator>
- </domain>
- </ResourceManagerService>
-
- <!--
- ScriptService
-
- scriptEngines := the list of available script engines
- scriptEngines/scriptEngine := configuration of a single script engine
- scriptEngines/scriptEngine/name := the name of the script engine
- scriptEngines/scriptEngine/isCached := cache the scripts or reload it each time from the ResourceManagerService
- scriptEngines/scriptEngine/isCompiled := precompile the script
- scriptEngines/scriptEngine/location := the location of the scripts
- scriptEngines/scriptEngine/preLoad := a list of scripts to load on startup
- scriptEngines/scriptEngine/preLoad/script := the script to preload
- -->
-
- <ScriptService>
- <scriptEngines>
- <scriptEngine>
- <name>groovy</name>
- <isCached>true</isCached>
- <isCompiled>true</isCompiled>
- <location>groovy</location>
- </scriptEngine>
- </scriptEngines>
- <scriptConfiguration>
- <isDebug>true</isDebug>
- </scriptConfiguration>
- </ScriptService>
+ <!--
+ ResourceManagerService
+
+ domain := one or more domain definitions
+ domain@name := the name of a domain
+ domain@type := an optional implementation class - defaults to FileResourceManager
+ domain/suffix := the extension of the resources to manage
+ domain/location := the location were the resources reside
+ domain/useLocator := enable/disable the locator feature
+ -->
+ <ResourceManagerService>
+ <domain name="groovy">
+ <suffix>groovy</suffix>
+ <location>./src/test/scripts/groovy</location>
+ <useLocator>true</useLocator>
+ </domain>
+ </ResourceManagerService>
+
+ <!--
+ ScriptService
+
+ scriptEngines := the list of available script engines
+ scriptEngines/scriptEngine := configuration of a single script engine
+ scriptEngines/scriptEngine/name := the name of the script engine
+ scriptEngines/scriptEngine/isCached := cache the scripts or reload it each time from the ResourceManagerService
+ scriptEngines/scriptEngine/isCompiled := precompile the script (if supported by the scripting engine)
+ scriptEngines/scriptEngine/location := the associated domain name of ResourceManagerService
+ scriptEngines/scriptEngine/preLoad := a list of scripts to load on startup
+ scriptEngines/scriptEngine/preLoad/script := a single script to load on startup
+ -->
+
+ <ScriptService>
+ <scriptEngines>
+ <scriptEngine>
+ <name>groovy</name>
+ <isCached>true</isCached>
+ <isCompiled>true</isCompiled>
+ <location>groovy</location>
+ </scriptEngine>
+ </scriptEngines>
+ <scriptConfiguration>
+ <isDebug>true</isDebug>
+ </scriptConfiguration>
+ </ScriptService>
</componentConfig>
Modified: turbine/fulcrum/trunk/script/src/test/TestRhinoComponentConfig.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/script/src/test/TestRhinoComponentConfig.xml?rev=937706&r1=937705&r2=937706&view=diff
==============================================================================
--- turbine/fulcrum/trunk/script/src/test/TestRhinoComponentConfig.xml (original)
+++ turbine/fulcrum/trunk/script/src/test/TestRhinoComponentConfig.xml Sat Apr 24 21:33:28 2010
@@ -20,6 +20,17 @@
<componentConfig>
+ <!--
+ ResourceManagerService
+
+ domain := one or more domain definitions
+ domain@name := the name of a domain
+ domain@type := an optional implementation class - defaults to FileResourceManager
+ domain/suffix := the extension of the resources to manage
+ domain/location := the location were the resources reside
+ domain/useLocator := enable/disable the locator feature
+ -->
+
<ResourceManagerService>
<domain name="js">
<suffix>js</suffix>
@@ -35,21 +46,22 @@
scriptEngines/scriptEngine := configuration of a single script engine
scriptEngines/scriptEngine/name := the name of the script engine
scriptEngines/scriptEngine/isCached := cache the scripts or reload it each time from the ResourceManagerService
- scriptEngines/scriptEngine/isCompiled := precompile the script
- scriptEngines/scriptEngine/location := the location of the scripts
+ scriptEngines/scriptEngine/isCompiled := precompile the script (if supported by the scripting engine)
+ scriptEngines/scriptEngine/location := the associated domain name of ResourceManagerService
scriptEngines/scriptEngine/preLoad := a list of scripts to load on startup
- scriptEngines/scriptEngine/preLoad/script := the script to preload
+ scriptEngines/scriptEngine/preLoad/script := a single script to load on startup
-->
<ScriptService>
<scriptEngines>
<scriptEngine>
- <name>js</name>
- <isCached>true</isCached>
+ <name>javascript</name>
+ <extension>js</extension>
+ <isCached>true</isCached>
<isCompiled>true</isCompiled>
<location>js</location>
<preLoad>
- <script>InvocableIntf.js</script>
+ <script>InvocableIntf.js</script>
</preLoad>
</scriptEngine>
</scriptEngines>
Modified: turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/AbstractScriptTest.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/AbstractScriptTest.java?rev=937706&r1=937705&r2=937706&view=diff
==============================================================================
--- turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/AbstractScriptTest.java (original)
+++ turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/AbstractScriptTest.java Sat Apr 24 21:33:28 2010
@@ -21,12 +21,11 @@ package org.apache.fulcrum.script;
import java.util.Hashtable;
-import javax.script.GenericScriptContext;
-import javax.script.Namespace;
import javax.script.ScriptContext;
import javax.script.ScriptEngine;
import javax.script.ScriptException;
-import javax.script.SimpleNamespace;
+import javax.script.SimpleBindings;
+import javax.script.SimpleScriptContext;
import org.apache.fulcrum.script.impl.ScriptRunnableImpl;
import org.apache.fulcrum.testcontainer.BaseUnitTest;
@@ -36,7 +35,7 @@ import org.apache.fulcrum.testcontainer.
*
* @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
*/
-public class AbstractScriptTest extends BaseUnitTest
+public abstract class AbstractScriptTest extends BaseUnitTest
{
protected ScriptService scriptService;
@@ -57,13 +56,15 @@ public class AbstractScriptTest extends
}
/**
- * Taken from the JSR 223 reference implementation
+ * Taken from the JSR 223 reference implementation.
+ *
+ * @throws Exception the test failed
*/
public void testCompilableInterface() throws Exception
{
for (int i=0; i<3; i++)
{
- SimpleNamespace args = new SimpleNamespace();
+ SimpleBindings args = new SimpleBindings();
args.put("count",new Integer(i));
args.put("currentTime",new Long(System.currentTimeMillis()));
this.scriptService.eval("CompilableInterface", args);
@@ -71,7 +72,9 @@ public class AbstractScriptTest extends
}
/**
- * Taken from the JSR 223 reference implementation
+ * Taken from the JSR 223 reference implementation.
+ *
+ * @throws Exception the test failed
*/
public void testHelloWorld() throws Exception
{
@@ -80,7 +83,9 @@ public class AbstractScriptTest extends
/**
* Taken from the JSR 223 reference implementation. This test
- * does not work with the "small" interpreter
+ * does not work with the "small" interpreter.
+ *
+ * @throws Exception the test failed
*/
public void testInvocableIntf() throws Exception
{
@@ -98,30 +103,32 @@ public class AbstractScriptTest extends
/**
* Taken from the JSR 223 reference implementation.
+ *
+ * @throws Exception the test failed
*/
public void testNamespaceDemo2() throws Exception
{
ScriptEngine eng = this.scriptService.getScriptEngine();
//create two simple namespaces
- SimpleNamespace eNamespace = new SimpleNamespace();
+ SimpleBindings eNamespace = new SimpleBindings();
eNamespace.put("key", new Testobj("Original engine scope."));
- SimpleNamespace cNamespace = new SimpleNamespace();
+ SimpleBindings cNamespace = new SimpleBindings();
cNamespace.put("key", new Testobj("Original ENGINE_SCOPE in context."));
//use external namespace instead of the default one
- eng.setNamespace(eNamespace,ScriptContext.ENGINE_SCOPE);
+ eng.setBindings(eNamespace,ScriptContext.ENGINE_SCOPE);
System.out.println("Starting value of key in engine scope is \"" + eng.get("key") + "\"");
//execute script using the namespace
- Object ret = this.scriptService.eval("NamespaceDemo2");
+ this.scriptService.eval("NamespaceDemo2");
System.out.println("Ending value of key in engine scope is \"" + eng.get("key") + "\"");
//create a scriptcontext and set its engine scope namespace
- ScriptContext ctxt = new GenericScriptContext();
- ctxt.setNamespace(cNamespace, ScriptContext.ENGINE_SCOPE);
+ ScriptContext ctxt = new SimpleScriptContext();
+ ctxt.setBindings(cNamespace, ScriptContext.ENGINE_SCOPE);
- ret = this.scriptService.eval("NamespaceDemo2", ctxt);
+ this.scriptService.eval("NamespaceDemo2", ctxt);
System.out.println("Ending value of key in engine scope is \"" + eng.get("key") + "\"");
System.out.println("Ending value of key in ENGINE_SCOPE of context is " +
ctxt.getAttribute("key",ScriptContext.ENGINE_SCOPE));
@@ -129,6 +136,8 @@ public class AbstractScriptTest extends
/**
* Taken from the JSR 223 reference implementation.
+ *
+ * @throws Exception the test failed
*/
public void testNamespaceDemo3() throws Exception
{
@@ -138,8 +147,8 @@ public class AbstractScriptTest extends
final ScriptService scriptService = this.scriptService;
//set engine-scope namespace with state=1
- Namespace n = new SimpleNamespace();
- engine.setNamespace(n, ScriptContext.ENGINE_SCOPE);
+ SimpleBindings n = new SimpleBindings();
+ engine.setBindings(n, ScriptContext.ENGINE_SCOPE);
n.put("state", new Integer(STATE1));
//create a new thread to run script
@@ -165,18 +174,22 @@ public class AbstractScriptTest extends
}
/**
- * Test access to the Avalon infrastructure
+ * Test access to the Avalon infrastructure.
+ *
+ * @throws Exception the test failed
*/
public void testAvalonContext() throws Exception
{
- SimpleNamespace args = new SimpleNamespace();
+ SimpleBindings args = new SimpleBindings();
args.put("bar",new Integer(2));
Object result = this.scriptService.eval("Avalon", args);
System.out.println("RESULT ==> " + result);
}
/**
- * Test the general performance of the JSR 223 integration
+ * Test the general performance of the JSR 223 integration.
+ *
+ * @throws Exception the test failed
*/
public void testPerformance() throws Exception
{
@@ -195,8 +208,9 @@ public class AbstractScriptTest extends
}
/**
- * Check ScriptService.exist()
+ * Check ScriptService.exist().
*
+ * @throws Exception the test failed
*/
public void testExists() throws Exception
{
@@ -206,6 +220,8 @@ public class AbstractScriptTest extends
/**
* Execute a script using multiple threads.
+ *
+ * @throws Exception the test failed
*/
public void testMultithreadingScript() throws Exception
{
@@ -241,6 +257,8 @@ public class AbstractScriptTest extends
/**
* Execute a script resulting in a ScriptException.
+ *
+ * @throws Exception the test failed
*/
public void testRuntimeErrorScript() throws Exception
{
@@ -251,12 +269,14 @@ public class AbstractScriptTest extends
}
catch (ScriptException e)
{
- return;
+ // expected
}
}
/**
* Tests the call() method of an Invocable.
+ *
+ * @throws Exception the test failed
*/
public void testCall() throws Exception
{
@@ -268,7 +288,9 @@ public class AbstractScriptTest extends
}
/**
- * Tests the locator functionality
+ * Tests the locator functionality.
+ *
+ * @throws Exception the test failed
*/
public void testLocatorFunctionality() throws Exception
{
@@ -285,6 +307,5 @@ public class AbstractScriptTest extends
// execute locator/bar/foo.extension
result = this.scriptService.eval("locator/bar/foo").toString();
assertTrue(result.startsWith("locator/bar/foo."));
-
}
}
Modified: turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/GroovyTest.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/GroovyTest.java?rev=937706&r1=937705&r2=937706&view=diff
==============================================================================
--- turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/GroovyTest.java (original)
+++ turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/GroovyTest.java Sat Apr 24 21:33:28 2010
@@ -46,23 +46,29 @@ public class GroovyTest extends Abstract
}
/**
- * Add all of our test suites
+ * Add all of our test suites.
+ *
+ * @return the Groovy test suite
*/
public static Test suite()
{
- TestSuite suite= new TestSuite("GroovyTest");
+ TestSuite suite = new TestSuite("GroovyTest");
- suite.addTest( new GroovyTest("testCompilableInterface") );
- suite.addTest( new GroovyTest("testHelloWorld") );
- suite.addTest( new GroovyTest("testNamespaceDemo2") );
- suite.addTest( new GroovyTest("testNamespaceDemo3") );
+ if(System.getProperty("fulcrum.script.groovyEnabled") != null)
+ {
+ // tests from the JSR-223 Reference implementation
+ suite.addTest( new GroovyTest("testCompilableInterface") );
+ suite.addTest( new GroovyTest("testHelloWorld") );
+ suite.addTest( new GroovyTest("testNamespaceDemo2") );
+ suite.addTest( new GroovyTest("testNamespaceDemo3") );
- suite.addTest( new GroovyTest("testAvalonContext") );
- suite.addTest( new GroovyTest("testExists") );
- suite.addTest( new GroovyTest("testPerformance") );
- suite.addTest( new GroovyTest("testMultithreadingScript") );
- suite.addTest( new GroovyTest("testRuntimeErrorScript") );
+ suite.addTest( new GroovyTest("testAvalonContext") );
+ suite.addTest( new GroovyTest("testExists") );
+ suite.addTest( new GroovyTest("testPerformance") );
+ suite.addTest( new GroovyTest("testMultithreadingScript") );
+ suite.addTest( new GroovyTest("testRuntimeErrorScript") );
+ }
return suite;
}
}
Modified: turbine/fulcrum/trunk/script/src/test/scripts/groovy/Avalon.groovy
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/script/src/test/scripts/groovy/Avalon.groovy?rev=937706&r1=937705&r2=937706&view=diff
==============================================================================
--- turbine/fulcrum/trunk/script/src/test/scripts/groovy/Avalon.groovy (original)
+++ turbine/fulcrum/trunk/script/src/test/scripts/groovy/Avalon.groovy Sat Apr 24 21:33:28 2010
@@ -16,25 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-/**
- * Copyright 2004 Apache Software Foundation
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
- *
- */
import java.io.File;
import java.util.Properties;
Modified: turbine/fulcrum/trunk/script/src/test/scripts/groovy/CompilableInterface.groovy
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/script/src/test/scripts/groovy/CompilableInterface.groovy?rev=937706&r1=937705&r2=937706&view=diff
==============================================================================
--- turbine/fulcrum/trunk/script/src/test/scripts/groovy/CompilableInterface.groovy (original)
+++ turbine/fulcrum/trunk/script/src/test/scripts/groovy/CompilableInterface.groovy Sat Apr 24 21:33:28 2010
@@ -16,39 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-/*
- * Copyright (c) 2004 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * -Redistribution of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * -Redistribution in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
- * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
- * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN")
- * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
- * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
- * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
- * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
- * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
- * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
- * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed, licensed or intended
- * for use in the design, construction, operation or maintenance of any
- * nuclear facility.
- */
switch (count) {
case 0:
Modified: turbine/fulcrum/trunk/script/src/test/scripts/groovy/HelloWorld.groovy
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/script/src/test/scripts/groovy/HelloWorld.groovy?rev=937706&r1=937705&r2=937706&view=diff
==============================================================================
--- turbine/fulcrum/trunk/script/src/test/scripts/groovy/HelloWorld.groovy (original)
+++ turbine/fulcrum/trunk/script/src/test/scripts/groovy/HelloWorld.groovy Sat Apr 24 21:33:28 2010
@@ -16,37 +16,4 @@
* specific language governing permissions and limitations
* under the License.
*/
-/*
- * Copyright (c) 2004 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * -Redistribution of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * -Redistribution in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
- * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
- * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN")
- * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
- * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
- * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
- * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
- * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
- * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
- * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed, licensed or intended
- * for use in the design, construction, operation or maintenance of any
- * nuclear facility.
- */
println '\nHello World!';
Modified: turbine/fulcrum/trunk/script/src/test/scripts/groovy/NamespaceDemo2.groovy
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/script/src/test/scripts/groovy/NamespaceDemo2.groovy?rev=937706&r1=937705&r2=937706&view=diff
==============================================================================
--- turbine/fulcrum/trunk/script/src/test/scripts/groovy/NamespaceDemo2.groovy (original)
+++ turbine/fulcrum/trunk/script/src/test/scripts/groovy/NamespaceDemo2.groovy Sat Apr 24 21:33:28 2010
@@ -16,39 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-/*
- * Copyright (c) 2004 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * -Redistribution of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * -Redistribution in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
- * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
- * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN")
- * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
- * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
- * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
- * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
- * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
- * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
- * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed, licensed or intended
- * for use in the design, construction, operation or maintenance of any
- * nuclear facility.
- */
+
println("\n-----Start executing script...");
value = key.getVal();
println("The current value of key is " + value);
Modified: turbine/fulcrum/trunk/script/src/test/scripts/groovy/NamespaceDemo3.groovy
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/script/src/test/scripts/groovy/NamespaceDemo3.groovy?rev=937706&r1=937705&r2=937706&view=diff
==============================================================================
--- turbine/fulcrum/trunk/script/src/test/scripts/groovy/NamespaceDemo3.groovy (original)
+++ turbine/fulcrum/trunk/script/src/test/scripts/groovy/NamespaceDemo3.groovy Sat Apr 24 21:33:28 2010
@@ -16,39 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-/*
- * Copyright (c) 2004 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * -Redistribution of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * -Redistribution in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
- * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
- * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN")
- * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
- * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
- * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
- * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
- * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
- * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
- * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed, licensed or intended
- * for use in the design, construction, operation or maintenance of any
- * nuclear facility.
- */
+
println("\n-----Starting script");
initial = state;
Modified: turbine/fulcrum/trunk/script/src/test/scripts/groovy/RuntimeError.groovy
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/script/src/test/scripts/groovy/RuntimeError.groovy?rev=937706&r1=937705&r2=937706&view=diff
==============================================================================
--- turbine/fulcrum/trunk/script/src/test/scripts/groovy/RuntimeError.groovy (original)
+++ turbine/fulcrum/trunk/script/src/test/scripts/groovy/RuntimeError.groovy Sat Apr 24 21:33:28 2010
@@ -16,24 +16,5 @@
* specific language governing permissions and limitations
* under the License.
*/
-/**
- * Copyright 2004 Apache Software Foundation
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
- *
- */
println(foobar);
Modified: turbine/fulcrum/trunk/script/src/test/scripts/js/Avalon.js
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/script/src/test/scripts/js/Avalon.js?rev=937706&r1=937705&r2=937706&view=diff
==============================================================================
--- turbine/fulcrum/trunk/script/src/test/scripts/js/Avalon.js (original)
+++ turbine/fulcrum/trunk/script/src/test/scripts/js/Avalon.js Sat Apr 24 21:33:28 2010
@@ -38,9 +38,9 @@ function testMe(aBar)
var isDebug = configuration.getChild("isDebug").getValueAsBoolean(false);
serviceManager.lookup("org.apache.fulcrum.script.ScriptService").exists("Avalon");
- // print("applicationDir = " + applicationDir);
- // print("tempDir = " + tempDir);
- // print("isDebug = " + isDebug);
+ print("applicationDir = " + applicationDir);
+ print("tempDir = " + tempDir);
+ print("isDebug = " + isDebug);
logger.info("Logging from within a script ... :-)");
// 3) create a property instance
Modified: turbine/fulcrum/trunk/script/src/test/scripts/js/CompilableInterface.js
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/script/src/test/scripts/js/CompilableInterface.js?rev=937706&r1=937705&r2=937706&view=diff
==============================================================================
--- turbine/fulcrum/trunk/script/src/test/scripts/js/CompilableInterface.js (original)
+++ turbine/fulcrum/trunk/script/src/test/scripts/js/CompilableInterface.js Sat Apr 24 21:33:28 2010
@@ -16,39 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-/*
- * Copyright (c) 2004 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * -Redistribution of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * -Redistribution in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
- * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
- * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN")
- * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
- * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
- * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
- * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
- * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
- * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
- * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed, licensed or intended
- * for use in the design, construction, operation or maintenance of any
- * nuclear facility.
- */
+
importPackage(java.util);
var counter;
switch (parseInt(count)) {
Modified: turbine/fulcrum/trunk/script/src/test/scripts/js/HelloWorld.js
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/script/src/test/scripts/js/HelloWorld.js?rev=937706&r1=937705&r2=937706&view=diff
==============================================================================
--- turbine/fulcrum/trunk/script/src/test/scripts/js/HelloWorld.js (original)
+++ turbine/fulcrum/trunk/script/src/test/scripts/js/HelloWorld.js Sat Apr 24 21:33:28 2010
@@ -16,37 +16,5 @@
* specific language governing permissions and limitations
* under the License.
*/
-/*
- * Copyright (c) 2004 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * -Redistribution of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * -Redistribution in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
- * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
- * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN")
- * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
- * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
- * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
- * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
- * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
- * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
- * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed, licensed or intended
- * for use in the design, construction, operation or maintenance of any
- * nuclear facility.
- */
+
print("\nHello World!");
Modified: turbine/fulcrum/trunk/script/src/test/scripts/js/InvocableIntf.js
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/script/src/test/scripts/js/InvocableIntf.js?rev=937706&r1=937705&r2=937706&view=diff
==============================================================================
--- turbine/fulcrum/trunk/script/src/test/scripts/js/InvocableIntf.js (original)
+++ turbine/fulcrum/trunk/script/src/test/scripts/js/InvocableIntf.js Sat Apr 24 21:33:28 2010
@@ -16,39 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-/*
- * Copyright (c) 2004 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * -Redistribution of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * -Redistribution in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
- * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
- * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN")
- * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
- * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
- * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
- * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
- * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
- * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
- * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed, licensed or intended
- * for use in the design, construction, operation or maintenance of any
- * nuclear facility.
- */
+
var x = "X string";
var y = 5;
Modified: turbine/fulcrum/trunk/script/src/test/scripts/js/MultiThreaded.js
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/script/src/test/scripts/js/MultiThreaded.js?rev=937706&r1=937705&r2=937706&view=diff
==============================================================================
--- turbine/fulcrum/trunk/script/src/test/scripts/js/MultiThreaded.js (original)
+++ turbine/fulcrum/trunk/script/src/test/scripts/js/MultiThreaded.js Sat Apr 24 21:33:28 2010
@@ -16,24 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-/**
-* Copyright 2004 Apache Software Foundation
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-* implied.
-*
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-* @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
-*/
importPackage(java.lang);
Modified: turbine/fulcrum/trunk/script/src/test/scripts/js/NamespaceDemo2.js
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/script/src/test/scripts/js/NamespaceDemo2.js?rev=937706&r1=937705&r2=937706&view=diff
==============================================================================
--- turbine/fulcrum/trunk/script/src/test/scripts/js/NamespaceDemo2.js (original)
+++ turbine/fulcrum/trunk/script/src/test/scripts/js/NamespaceDemo2.js Sat Apr 24 21:33:28 2010
@@ -16,39 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-/*
- * Copyright (c) 2004 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * -Redistribution of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * -Redistribution in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
- * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
- * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN")
- * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
- * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
- * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
- * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
- * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
- * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
- * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed, licensed or intended
- * for use in the design, construction, operation or maintenance of any
- * nuclear facility.
- */
+
print("\n-----Start executing script...");
var value = key.getVal();
print("The current value of key is " + value);
Modified: turbine/fulcrum/trunk/script/src/test/scripts/js/NamespaceDemo3.js
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/script/src/test/scripts/js/NamespaceDemo3.js?rev=937706&r1=937705&r2=937706&view=diff
==============================================================================
--- turbine/fulcrum/trunk/script/src/test/scripts/js/NamespaceDemo3.js (original)
+++ turbine/fulcrum/trunk/script/src/test/scripts/js/NamespaceDemo3.js Sat Apr 24 21:33:28 2010
@@ -16,39 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-/*
- * Copyright (c) 2004 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * -Redistribution of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * -Redistribution in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
- * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
- * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN")
- * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
- * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
- * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
- * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
- * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
- * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
- * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed, licensed or intended
- * for use in the design, construction, operation or maintenance of any
- * nuclear facility.
- */
+
print("\n-----Starting script");
var initial = parseInt(state);
Modified: turbine/fulcrum/trunk/script/xdocs/index.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/script/xdocs/index.xml?rev=937706&r1=937705&r2=937706&view=diff
==============================================================================
--- turbine/fulcrum/trunk/script/xdocs/index.xml (original)
+++ turbine/fulcrum/trunk/script/xdocs/index.xml Sat Apr 24 21:33:28 2010
@@ -36,6 +36,13 @@
and Fulcrum Groovy service.
</p>
+ <p>
+ When you are using JDK 1.5 then you need Bean Scripting
+ Framework (bsf-api-3.0-beta2.jar). If you are using
+ JDK 1.6 then the library will do no harm and you use
+ the JDK 1.6 built-in implementation of JSR-223.
+ </p>
+
<subsection name="Features">
<p>
The Fulcrum Script Service provides the following features:
@@ -62,17 +69,7 @@
<tr>
<td><a href="http://groovy.codehaus.org">Groovy</a></td>
<td>Done</td>
- <td>Currently no support for Invocable</td>
- </tr>
- <tr>
- <td><a href="https://pnuts.dev.java.net">pnuts</a></td>
- <td>Open</td>
- <td>Currently no JDK 1.4 support for JSR 223 integration</td>
- </tr>
- <tr>
- <td><a href="http://www.beanshell.org">Beanshell</a></td>
- <td>Open</td>
- <td>Currently no JSR 223 integration available</td>
+ <td>Not sure if Groovy support Invocable</td>
</tr>
</table>
</subsection>