You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by sg...@apache.org on 2006/01/07 16:26:15 UTC

svn commit: r366777 [2/3] - in /jakarta/turbine/fulcrum/trunk/script: ./ src/ src/java/ src/java/org/ src/java/org/apache/ src/java/org/apache/fulcrum/ src/java/org/apache/fulcrum/script/ src/java/org/apache/fulcrum/script/impl/ src/test/ src/test/org/...

Added: jakarta/turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/Validate.java
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/Validate.java?rev=366777&view=auto
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/Validate.java (added)
+++ jakarta/turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/Validate.java Sat Jan  7 07:25:56 2006
@@ -0,0 +1,611 @@
+/*
+ * Copyright 2002-2005 The 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.
+ */
+package org.apache.fulcrum.script.impl;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * <p>Assists in validating arguments.</p>
+ *
+ * <p>The class is based along the lines of JUnit. If an argument value is
+ * deemed invalid, an IllegalArgumentException is thrown. For example:</p>
+ *
+ * <pre>
+ * Validate.isTrue( i > 0, "The value must be greater than zero: ", i);
+ * Validate.notNull( surname, "The surname must not be null");
+ * </pre>
+ *
+ * @author <a href="mailto:ola.berg@arkitema.se">Ola Berg</a>
+ * @author Stephen Colebourne
+ * @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
+{
+    // Validate has no dependencies on other classes in Commons Lang at present
+
+    /**
+     * Constructor. This class should not normally be instantiated.
+     */
+    public Validate()
+    {
+        // nothing to do
+    }
+
+    // isTrue
+    //---------------------------------------------------------------------------------
+
+    /**
+     * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+     * if the test result is <code>false</code>.</p>
+     *
+     * <p>This is used when validating according to an arbitrary boolean expression,
+     * such as validating a primitive number or using your own custom validation
+     * expression.</p>
+     *
+     * <pre>
+     * Validate.isTrue( myObject.isOk(), "The object is not OK: ", myObject);
+     * </pre>
+     *
+     * <p>For performance reasons, the object is passed as a separate parameter and
+     * appended to the message string only in the case of an error.</p>
+     *
+     * @param expression  a boolean expression
+     * @param message  the exception message you would like to see if the
+     *  expression is <code>false</code>
+     * @param value  the value to append to the message in case of error
+     * @throws IllegalArgumentException if expression is <code>false</code>
+     */
+    public static void isTrue(boolean expression, String message, Object value)
+    {
+        if (expression == false)
+        {
+            throw new IllegalArgumentException( message + value );
+        }
+    }
+
+    /**
+     * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+     * if the test result is <code>false</code>.</p>
+     *
+     * <p>This is used when validating according to an arbitrary boolean expression,
+     * such as validating a primitive number or using your own custom validation
+     * expression.</p>
+     *
+     * <pre>
+     * Validate.isTrue( i > 0, "The value must be greater than zero: ", i);
+     * </pre>
+     *
+     * <p>For performance reasons, the long value is passed as a separate parameter and
+     * appended to the message string only in the case of an error.</p>
+     *
+     * @param expression  a boolean expression
+     * @param message  the exception message you would like to see if the expression is <code>false</code>
+     * @param value  the value to append to the message in case of error
+     * @throws IllegalArgumentException if expression is <code>false</code>
+     */
+    public static void isTrue(boolean expression, String message, long value)
+    {
+        if (expression == false)
+        {
+            throw new IllegalArgumentException( message + value );
+        }
+    }
+
+    /**
+     * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+     * if the test result is <code>false</code>.</p>
+     *
+     * <p>This is used when validating according to an arbitrary boolean expression,
+     * such as validating a primitive number or using your own custom validation
+     * expression.</p>
+     *
+     * <pre>
+     * Validate.isTrue( d > 0.0, "The value must be greater than zero: ", d);
+     * </pre>
+     *
+     * <p>For performance reasons, the double value is passed as a separate parameter and
+     * appended to the message string only in the case of an error.</p>
+     *
+     * @param expression  a boolean expression
+     * @param message  the exception message you would like to see if the expression
+     *  is <code>false</code>
+     * @param value  the value to append to the message in case of error
+     * @throws IllegalArgumentException if expression is <code>false</code>
+     */
+    public static void isTrue(boolean expression, String message, double value)
+    {
+        if (expression == false)
+        {
+            throw new IllegalArgumentException( message + value );
+        }
+    }
+
+    /**
+     * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+     * if the test result is <code>false</code>.</p>
+     *
+     * <p>This is used when validating according to an arbitrary boolean expression,
+     * such as validating a primitive number or using your own custom validation
+     * expression.</p>
+     *
+     * <pre>
+     * Validate.isTrue( (i > 0), "The value must be greater than zero");
+     * Validate.isTrue( myObject.isOk(), "The object is not OK");
+     * </pre>
+     *
+     * <p>For performance reasons, the message string should not involve a string append,
+     * instead use the {@link #isTrue(boolean, String, Object)} method.</p>
+     *
+     * @param expression  a boolean expression
+     * @param message  the exception message you would like to see if the expression
+     *  is <code>false</code>
+     * @throws IllegalArgumentException if expression is <code>false</code>
+     */
+    public static void isTrue(boolean expression, String message)
+    {
+        if (expression == false)
+        {
+            throw new IllegalArgumentException( message );
+        }
+    }
+
+    /**
+     * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+     * if the test result is <code>false</code>.</p>
+     *
+     * <p>This is used when validating according to an arbitrary boolean expression,
+     * such as validating a primitive number or using your own custom validation
+     * expression.</p>
+     *
+     * <pre>
+     * Validate.isTrue( i > 0 );
+     * Validate.isTrue( myObject.isOk() );
+     * </pre>
+     *
+     * <p>The message in the exception is 'The validated expression is false'.</p>
+     *
+     * @param expression  a boolean expression
+     * @throws IllegalArgumentException if expression is <code>false</code>
+     */
+    public static void isTrue(boolean expression)
+    {
+        if (expression == false)
+        {
+            throw new IllegalArgumentException(
+                            "The validated expression is false" );
+        }
+    }
+
+    // notNull
+    //---------------------------------------------------------------------------------
+
+    /**
+     * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+     * if the argument is <code>null</code>.</p>
+     *
+     * <pre>
+     * Validate.notNull(myObject, "The object must not be null");
+     * </pre>
+     *
+     * @param object  the object to check is not <code>null</code>
+     * @param message  the exception message you would like to see
+     *  if the object is <code>null</code>
+     * @throws IllegalArgumentException if the object is <code>null</code>
+     */
+    public static void notNull(Object object, String message)
+    {
+        if (object == null)
+        {
+            throw new IllegalArgumentException( message );
+        }
+    }
+
+    /**
+     * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+     * if the argument is <code>null</code>.</p>
+     *
+     * <pre>
+     * Validate.notNull(myObject);
+     * </pre>
+     *
+     * <p>The message in the exception is 'The validated object is null'.</p>
+     *
+     * @param object  the object to check is not <code>null</code>
+     * @throws IllegalArgumentException if the object is <code>null</code>
+     */
+    public static void notNull(Object object)
+    {
+        if (object == null)
+        {
+            throw new IllegalArgumentException( "The validated object is null" );
+        }
+    }
+
+    // notEmpty array
+    //---------------------------------------------------------------------------------
+
+    /**
+     * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+     * if the argument array is empty (<code>null</code> or no elements).</p>
+     *
+     * <pre>
+     * Validate.notEmpty(myArray, "The array must not be empty");
+     * </pre>
+     *
+     * @param array  the array to check is not empty
+     * @param message  the exception message you would like to see if the array is empty
+     * @throws IllegalArgumentException if the array is empty
+     */
+    public static void notEmpty(Object [] array, String message)
+    {
+        if (array == null || array.length == 0)
+        {
+            throw new IllegalArgumentException( message );
+        }
+    }
+
+    /**
+     * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+     * if the argument array is empty (<code>null</code> or no elements).</p>
+     *
+     * <pre>
+     * Validate.notEmpty(myArray);
+     * </pre>
+     *
+     * <p>The message in the exception is 'The validated array is empty'.
+     *
+     * @param array  the array to check is not empty
+     * @throws IllegalArgumentException if the array is empty
+     */
+    public static void notEmpty(Object [] array)
+    {
+        if (array == null || array.length == 0)
+        {
+            throw new IllegalArgumentException( "The validated array is empty" );
+        }
+    }
+
+    // notEmpty collection
+    //---------------------------------------------------------------------------------
+
+    /**
+     * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+     * if the argument Collection is empty (<code>null</code> or no elements).</p>
+     *
+     * <pre>
+     * Validate.notEmpty(myCollection, "The collection must not be empty");
+     * </pre>
+     *
+     * @param collection  the collection to check is not empty
+     * @param message  the exception message you would like to see if the collection is empty
+     * @throws IllegalArgumentException if the collection is empty
+     */
+    public static void notEmpty(Collection collection, String message)
+    {
+        if (collection == null || collection.size() == 0)
+        {
+            throw new IllegalArgumentException( message );
+        }
+    }
+
+    /**
+     * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+     * if the argument Collection is empty (<code>null</code> or no elements).</p>
+     *
+     * <pre>
+     * Validate.notEmpty(myCollection);
+     * </pre>
+     *
+     * <p>The message in the exception is 'The validated collection is empty'.</p>
+     *
+     * @param collection  the collection to check is not empty
+     * @throws IllegalArgumentException if the collection is empty
+     */
+    public static void notEmpty(Collection collection)
+    {
+        if (collection == null || collection.size() == 0)
+        {
+            throw new IllegalArgumentException(
+                            "The validated collection is empty" );
+        }
+    }
+
+    // notEmpty map
+    //---------------------------------------------------------------------------------
+
+    /**
+     * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+     * if the argument Map is empty (<code>null</code> or no elements).</p>
+     *
+     * <pre>
+     * Validate.notEmpty(myMap, "The map must not be empty");
+     * </pre>
+     *
+     * @param map  the map to check is not empty
+     * @param message  the exception message you would like to see if the map is empty
+     * @throws IllegalArgumentException if the map is empty
+     */
+    public static void notEmpty(Map map, String message)
+    {
+        if (map == null || map.size() == 0)
+        {
+            throw new IllegalArgumentException( message );
+        }
+    }
+
+    /**
+     * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+     * if the argument Map is empty (<code>null</code> or no elements).</p>
+     *
+     * <pre>
+     * Validate.notEmpty(myMap);
+     * </pre>
+     *
+     * <p>The message in the exception is 'The validated map is empty'.</p>
+     *
+     * @param map  the map to check is not empty
+     * @throws IllegalArgumentException if the map is empty
+     */
+    public static void notEmpty(Map map)
+    {
+        if (map == null || map.size() == 0)
+        {
+            throw new IllegalArgumentException( "The validated map is empty" );
+        }
+    }
+
+    // notEmpty string
+    //---------------------------------------------------------------------------------
+
+    /**
+     * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+     * if the argument String is empty (<code>null</code> or zero length).</p>
+     *
+     * <pre>
+     * Validate.notEmpty(myString, "The string must not be empty");
+     * </pre>
+     *
+     * @param string  the string to check is not empty
+     * @param message  the exception message you would like to see if the string is empty
+     * @throws IllegalArgumentException if the string is empty
+     */
+    public static void notEmpty(String string, String message)
+    {
+        if (string == null || string.length() == 0)
+        {
+            throw new IllegalArgumentException( message );
+        }
+    }
+
+    /**
+     * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+     * if the argument String is empty (<code>null</code> or zero length).</p>
+     *
+     * <pre>
+     * Validate.notEmpty(myString);
+     * </pre>
+     *
+     * <p>The message in the exception is 'The validated string is empty'.</p>
+     *
+     * @param string  the string to check is not empty
+     * @throws IllegalArgumentException if the string is empty
+     */
+    public static void notEmpty(String string)
+    {
+        if (string == null || string.length() == 0)
+        {
+            throw new IllegalArgumentException( "The validated string is empty" );
+        }
+    }
+
+    // notNullElements array
+    //---------------------------------------------------------------------------------
+
+    /**
+     * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+     * if the argument array has <code>null</code> elements or is
+     * <code>null</code>.</p>
+     *
+     * <pre>
+     * Validate.noNullElements(myArray, "The array must not contain null elements");
+     * </pre>
+     *
+     * <p>If the array is null then the message in the exception is 'The validated object is null'.</p>
+     *
+     * @param array  the array to check
+     * @param message  the exception message if the array has
+     *  <code>null</code> elements
+     * @throws IllegalArgumentException if the array has <code>null</code>
+     *  elements or is <code>null</code>
+     */
+    public static void noNullElements(Object [] array, String message)
+    {
+        Validate.notNull( array );
+        for (int i = 0; i < array.length; i++)
+        {
+            if (array[i] == null)
+            {
+                throw new IllegalArgumentException( message );
+            }
+        }
+    }
+
+    /**
+     * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+     * if the argument array has <code>null</code> elements or is
+     * <code>null</code>.</p>
+     *
+     * <pre>
+     * Validate.noNullElements(myArray);
+     * </pre>
+     *
+     * <p>If the array has a null element the message in the exception is
+     * 'The validated array contains null element at index: '.</p>
+     *
+     * <p>If the array is null then the message in the exception is 'The validated object is null'.</p>
+     *
+     * @param array  the array to check
+     * @throws IllegalArgumentException if the array has <code>null</code>
+     *  elements or is <code>null</code>
+     */
+    public static void noNullElements(Object [] array)
+    {
+        Validate.notNull( array );
+        for (int i = 0; i < array.length; i++)
+        {
+            if (array[i] == null)
+            {
+                throw new IllegalArgumentException(
+                                "The validated array contains null element at index: "
+                                                + i );
+            }
+        }
+    }
+
+    // notNullElements collection
+    //---------------------------------------------------------------------------------
+
+    /**
+     * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+     * if the argument Collection has <code>null</code> elements or is
+     * <code>null</code>.</p>
+     *
+     * <pre>
+     * Validate.noNullElements(myCollection, "The collection must not contain null elements");
+     * </pre>
+     *
+     * <p>If the collection is null then the message in the exception is 'The validated object is null'.</p>
+     *
+     * @param collection  the collection to check
+     * @param message  the exception message if the collection has
+     *  <code>null</code> elements
+     * @throws IllegalArgumentException if the collection has
+     *  <code>null</code> elements or is <code>null</code>
+     */
+    public static void noNullElements(Collection collection, String message)
+    {
+        Validate.notNull( collection );
+        for (Iterator it = collection.iterator(); it.hasNext();)
+        {
+            if (it.next() == null)
+            {
+                throw new IllegalArgumentException( message );
+            }
+        }
+    }
+
+    /**
+     * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+     * if the argument Collection has <code>null</code> elements or is
+     * <code>null</code>.</p>
+     *
+     * <pre>
+     * Validate.noNullElements(myCollection);
+     * </pre>
+     *
+     * <p>The message in the exception is 'The validated collection contains null element at index: '.</p>
+     *
+     * <p>If the collection is null then the message in the exception is 'The validated object is null'.</p>
+     *
+     * @param collection  the collection to check
+     * @throws IllegalArgumentException if the collection has
+     *  <code>null</code> elements or is <code>null</code>
+     */
+    public static void noNullElements(Collection collection)
+    {
+        Validate.notNull( collection );
+        int i = 0;
+        for (Iterator it = collection.iterator(); it.hasNext(); i++)
+        {
+            if (it.next() == null)
+            {
+                throw new IllegalArgumentException(
+                                "The validated collection contains null element at index: "
+                                                + i );
+            }
+        }
+    }
+
+    /**
+     * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+     * if the argument collection  is <code>null</code> or has elements that
+     * are not of type <code>clazz</code> or a subclass.</p>
+     *
+     * <pre>
+     * Validate.allElementsOfType(collection, String.class, "Collection has invalid elements");
+     * </pre>
+     *
+     * @param collection  the collection to check, not null
+     * @param clazz  the <code>Class</code> which the collection's elements are expected to be, not null
+     * @param message  the exception message if the <code>Collection</code> has elements not of type <code>clazz</code>
+     * @since 2.1
+     */
+    public static void allElementsOfType(Collection collection, Class clazz,
+        String message)
+    {
+        Validate.notNull( collection );
+        Validate.notNull( clazz );
+        for (Iterator it = collection.iterator(); it.hasNext();)
+        {
+            if (clazz.isInstance( it.next() ) == false)
+            {
+                throw new IllegalArgumentException( message );
+            }
+        }
+    }
+
+    /**
+     * <p>
+     * Validate an argument, throwing <code>IllegalArgumentException</code> if the argument collection is
+     * <code>null</code> or has elements that are not of type <code>clazz</code> or a subclass.
+     * </p>
+     *
+     * <pre>
+     * Validate.allElementsOfType(collection, String.class);
+     * </pre>
+     *
+     * <p>
+     * The message in the exception is 'The validated collection contains an element not of type clazz at index: '.
+     * </p>
+     *
+     * @param collection
+     *            the collection to check, not null
+     * @param clazz
+     *            the <code>Class</code> which the collection's elements are expected to be, not null
+     * @since 2.1
+     */
+    public static void allElementsOfType(Collection collection, Class clazz)
+    {
+        Validate.notNull( collection );
+        Validate.notNull( clazz );
+        int i = 0;
+        for (Iterator it = collection.iterator(); it.hasNext(); i++)
+        {
+            if (clazz.isInstance( it.next() ) == false)
+            {
+                throw new IllegalArgumentException(
+                                "The validated collection contains an element not of type "
+                                                + clazz.getName()
+                                                + " at index: " + i );
+            }
+        }
+    }
+}

Added: jakarta/turbine/fulcrum/trunk/script/src/test/TestGroovyComponentConfig.xml
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/script/src/test/TestGroovyComponentConfig.xml?rev=366777&view=auto
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/TestGroovyComponentConfig.xml (added)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/TestGroovyComponentConfig.xml Sat Jan  7 07:25:56 2006
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<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>
+
+</componentConfig>
\ No newline at end of file

Added: jakarta/turbine/fulcrum/trunk/script/src/test/TestRhinoComponentConfig.xml
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/script/src/test/TestRhinoComponentConfig.xml?rev=366777&view=auto
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/TestRhinoComponentConfig.xml (added)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/TestRhinoComponentConfig.xml Sat Jan  7 07:25:56 2006
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<componentConfig>
+
+  <ResourceManagerService>
+    <domain name="js">
+      <suffix>js</suffix>
+      <location>./src/test/scripts/js</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>js</name>
+  			<isCached>true</isCached>
+  			<isCompiled>true</isCompiled>
+  			<location>js</location>
+  			<preLoad>
+  				<script>InvocableIntf.js</script>
+  			</preLoad>
+  		</scriptEngine>
+  	</scriptEngines>
+  	<scriptConfiguration>
+  	  <isDebug>true</isDebug>
+  	</scriptConfiguration>
+  </ScriptService>
+
+</componentConfig>
\ No newline at end of file

Added: jakarta/turbine/fulcrum/trunk/script/src/test/TestRoleConfig.xml
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/script/src/test/TestRoleConfig.xml?rev=366777&view=auto
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/TestRoleConfig.xml (added)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/TestRoleConfig.xml Sat Jan  7 07:25:56 2006
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<role-list>
+
+    <role
+        name="org.apache.fulcrum.resourcemanager.ResourceManagerService"
+        default-class="org.apache.fulcrum.resourcemanager.impl.ResourceManagerServiceImpl"
+        shorthand="ResourceManagerService"
+        early-init="true"
+        description="Handles the management of resources"
+     />
+
+    <role
+        name="org.apache.fulcrum.script.ScriptService"
+        default-class="org.apache.fulcrum.script.impl.ScriptServiceImpl"
+        shorthand="ScriptService"
+        early-init="true"
+        description="Handles the execution of scripts"
+     />
+
+</role-list>
\ No newline at end of file

Added: jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/AbstractScriptTest.java
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/AbstractScriptTest.java?rev=366777&view=auto
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/AbstractScriptTest.java (added)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/AbstractScriptTest.java Sat Jan  7 07:25:56 2006
@@ -0,0 +1,288 @@
+package org.apache.fulcrum.script;
+
+/*
+ * Copyright 2005 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.
+ */
+
+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 org.apache.fulcrum.script.impl.ScriptRunnableImpl;
+import org.apache.fulcrum.testcontainer.BaseUnitTest;
+
+/**
+ * Common test cases for all scripting languages.
+ *
+ * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
+ */
+public class AbstractScriptTest extends BaseUnitTest
+{
+    protected ScriptService scriptService;
+    
+    /**
+     * Defines the testcase name for JUnit.
+     *
+     * @param name the testcase's name.
+     */
+    public AbstractScriptTest(String name)
+    {
+        super(name);
+    }
+
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        this.scriptService = (ScriptService) this.lookup(ScriptService.class.getName());
+    }
+        
+    /**
+     * Taken from the JSR 223 reference implementation
+     */
+    public void testCompilableInterface() throws Exception
+    {
+        for (int i=0; i<3; i++) 
+        {
+            SimpleNamespace args = new SimpleNamespace();
+            args.put("count",new Integer(i));
+            args.put("currentTime",new Long(System.currentTimeMillis()));
+            this.scriptService.eval("CompilableInterface", args);
+		}
+    }
+
+    /**
+     * Taken from the JSR 223 reference implementation
+     */
+    public void testHelloWorld() throws Exception
+    {
+       this.scriptService.eval("HelloWorld");
+    }
+       
+    /**
+     * Taken from the JSR 223 reference implementation. This test
+     * does not work with the "small" interpreter 
+     */    
+    public void testInvocableIntf() throws Exception
+    {
+        MyInterface myInterface = (MyInterface) scriptService.getInterface(
+            MyInterface.class
+            );
+        
+		System.out.println("Initial value for X: " + myInterface.getX());
+		myInterface.setX("New string");
+		System.out.println("Current value for X: " + myInterface.getX());
+		System.out.println("\nInitial value for Y: " + myInterface.getY());
+		myInterface.setY(100);
+		System.out.println("Current value for Y: " + myInterface.getY());        
+    }
+
+    /**
+     * Taken from the JSR 223 reference implementation. 
+     */    
+    public void testNamespaceDemo2() throws Exception
+    {
+        ScriptEngine eng = this.scriptService.getScriptEngine();
+    
+		//create two simple namespaces
+		SimpleNamespace eNamespace = new SimpleNamespace();
+		eNamespace.put("key", new Testobj("Original engine scope."));
+		SimpleNamespace cNamespace = new SimpleNamespace();
+		cNamespace.put("key", new Testobj("Original ENGINE_SCOPE in context."));
+		
+		//use external namespace instead of the default one
+		eng.setNamespace(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");
+		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);
+		
+		ret = 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));
+    }
+    
+    /**
+     * Taken from the JSR 223 reference implementation. 
+     */    
+    public void testNamespaceDemo3() throws Exception
+    {
+        final int STATE1 = 1;
+        final int STATE2 = 2;
+        final ScriptEngine engine = this.scriptService.getScriptEngine();
+        final ScriptService scriptService = this.scriptService;
+        
+        //set engine-scope namespace with state=1
+        Namespace n = new SimpleNamespace();
+        engine.setNamespace(n, ScriptContext.ENGINE_SCOPE);
+        n.put("state", new Integer(STATE1));
+        
+        //create a new thread to run script
+        Thread t = new Thread(new Runnable(){
+          public void run() {
+            try {
+              scriptService.eval("NamespaceDemo3");
+            } catch (Exception e) {
+              e.printStackTrace();
+            }
+          }
+        });
+        t.start();
+        
+        // wait for the script engine to start and execute the script
+        Thread.sleep(2000);
+        
+        //changes state
+        n.put("state", new Integer(STATE2));
+        t.join();
+        System.out.println("Script has executed.. current state is " + 
+            n.get("state"));
+    }
+
+    /**
+     * Test access to the Avalon infrastructure
+     */
+    public void testAvalonContext() throws Exception
+    {
+        SimpleNamespace args = new SimpleNamespace();
+        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
+     */
+    public void testPerformance() throws Exception
+    {
+        long startTime = System.currentTimeMillis();
+        for( int i=0; i<500; i++ )
+        {
+            this.testHelloWorld();
+            this.testCompilableInterface();
+            this.testNamespaceDemo2();
+            this.testAvalonContext();
+        }
+        long endTime = System.currentTimeMillis();
+        long duration = endTime - startTime;
+        
+        System.out.println("=== Exceution took " + duration + " ms ===");        
+    }
+
+    /**
+     * Check ScriptService.exist()
+     * 
+     */
+    public void testExists() throws Exception
+    {
+        assertTrue(this.scriptService.exists("HelloWorld"));
+        assertFalse(this.scriptService.exists("grmpff"));
+    }
+    
+    /**
+     * Execute a script using multiple threads.
+     */
+    public void testMultithreadingScript() throws Exception
+    {
+        Hashtable args0 = new Hashtable();
+        args0.put("foo", new Double(0));        
+        ScriptRunnable runnable0 = new ScriptRunnableImpl( this.scriptService, "MultiThreaded", args0 );
+
+        Hashtable args1 = new Hashtable();
+        args1.put("foo", new Double(1));        
+        ScriptRunnable runnable1 = new ScriptRunnableImpl( this.scriptService, "MultiThreaded", args1 );
+        Thread thread1 = new Thread(runnable1,"Thread1");
+
+        Hashtable args2 = new Hashtable();
+        args2.put("foo", new Double(2));        
+        ScriptRunnable runnable2 = new ScriptRunnableImpl( this.scriptService, "MultiThreaded", args2 );
+        Thread thread2 = new Thread(runnable2,"Thread2");
+
+        thread1.start();
+        thread2.start();
+        runnable0.run();
+
+        assertTrue( runnable0.getResult() == runnable0.getResult() );
+        assertTrue( runnable1.getResult() == runnable1.getResult() );
+        assertTrue( runnable2.getResult() == runnable2.getResult() );
+
+        thread1.join();
+        thread2.join();
+
+        assertEquals( new Double(0), args0.get("foo") );        
+        assertEquals( new Double(2), args1.get("foo") );
+        assertEquals( new Double(4), args2.get("foo") );
+    }    
+    
+    /**
+     * Execute a script resulting in a ScriptException.
+     */
+    public void testRuntimeErrorScript() throws Exception
+    {
+        try
+        {
+            this.scriptService.eval("RuntimeError");
+            fail("Expected ScriptException");
+        }
+        catch (ScriptException e)
+        {
+            return;
+        }    
+    }
+    
+    /**
+     * Tests the call() method of an Invocable.
+     */
+    public void testCall() throws Exception
+    {
+        String newX = "New X String";
+        String oldX = (String) this.scriptService.call("getX", new Object[0]);
+        this.scriptService.call("setX", new Object[]{newX} );
+        newX = (String) this.scriptService.call("getX", new Object[0]);
+        this.scriptService.call("setX", new Object[]{oldX} );
+    }
+    
+    /**
+     * Tests the locator functionality
+     */
+    public void testLocatorFunctionality() throws Exception
+    {
+        String result = null;
+
+        // execute locator/foo.extension
+        result = this.scriptService.eval("locator/foo").toString();
+        assertTrue(result.startsWith("locator/foo."));
+        
+        // execute locator/foo/foo.extension which is not found but locator/foo.extension is
+        result = this.scriptService.eval("locator/foo/foo").toString();
+        assertTrue(result.startsWith("locator/foo."));
+
+        // execute locator/bar/foo.extension
+        result = this.scriptService.eval("locator/bar/foo").toString();
+        assertTrue(result.startsWith("locator/bar/foo."));
+
+    }    
+}

Added: jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/GroovyTest.java
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/GroovyTest.java?rev=366777&view=auto
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/GroovyTest.java (added)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/GroovyTest.java Sat Jan  7 07:25:56 2006
@@ -0,0 +1,66 @@
+package org.apache.fulcrum.script;
+
+/*
+ * Copyright 2005 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.
+ */
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Regression test for Groovy
+ *
+ * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
+ */
+public class GroovyTest extends AbstractScriptTest
+{
+    /**
+     * Defines the testcase name for JUnit.
+     *
+     * @param name the testcase's name.
+     */
+    public GroovyTest(String name)
+    {
+        super(name);
+        this.setConfigurationFileName("./src/test/TestGroovyComponentConfig.xml");
+    }
+
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+    }
+    
+    /**
+     * Add all of our test suites
+     */
+    public static Test suite()
+    {
+        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") );
+        
+        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;
+    }
+}

Added: jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/MyInterface.java
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/MyInterface.java?rev=366777&view=auto
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/MyInterface.java (added)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/MyInterface.java Sat Jan  7 07:25:56 2006
@@ -0,0 +1,42 @@
+/*
+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.
+*/
+
+package org.apache.fulcrum.script;
+
+public interface MyInterface {
+    public void setX(String value);
+    public String getX();
+    public void setY(int value);
+    public Integer getY();
+}

Added: jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/RhinoTest.java
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/RhinoTest.java?rev=366777&view=auto
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/RhinoTest.java (added)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/RhinoTest.java Sat Jan  7 07:25:56 2006
@@ -0,0 +1,70 @@
+package org.apache.fulcrum.script;
+
+/*
+ * Copyright 2005 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.
+ */
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Regression test for Rhino Javascript
+ *
+ * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
+ */
+public class RhinoTest extends AbstractScriptTest
+{    
+    /**
+     * Defines the testcase name for JUnit.
+     *
+     * @param name the testcase's name.
+     */
+    public RhinoTest(String name)
+    {
+        super(name);
+        this.setConfigurationFileName("./src/test/TestRhinoComponentConfig.xml");
+    }
+
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+    }
+    
+    /**
+     * Add all of our test suites
+     */
+    public static Test suite()
+    {
+        TestSuite suite= new TestSuite("RhinoTest");
+        
+        // tests from the JSR-223 Reference implementation
+        suite.addTest( new RhinoTest("testHelloWorld") );
+        suite.addTest( new RhinoTest("testCompilableInterface") );
+        suite.addTest( new RhinoTest("testNamespaceDemo2") );
+        suite.addTest( new RhinoTest("testNamespaceDemo3") );
+        suite.addTest( new RhinoTest("testInvocableIntf") );
+        
+        suite.addTest( new RhinoTest("testAvalonContext") );     
+        suite.addTest( new RhinoTest("testExists") );        
+        suite.addTest( new RhinoTest("testPerformance") );
+        suite.addTest( new RhinoTest("testMultithreadingScript") );        
+        suite.addTest( new RhinoTest("testRuntimeErrorScript") );        
+        suite.addTest( new RhinoTest("testCall") );
+        suite.addTest( new RhinoTest("testLocatorFunctionality") );
+                                
+        return suite;
+    }    
+}

Added: jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/Testobj.java
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/Testobj.java?rev=366777&view=auto
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/Testobj.java (added)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/Testobj.java Sat Jan  7 07:25:56 2006
@@ -0,0 +1,52 @@
+/*
+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.
+*/
+
+package org.apache.fulcrum.script;
+
+public class Testobj {
+    private String val;
+    public Testobj(String s) {
+        val = s;
+    }
+    public void setVal(String v) {
+        val = v;
+    }
+    public String getVal() {
+        return val;
+    }
+    public String toString() {
+        return "Testobj containing " + val;
+    }
+}
+

Added: jakarta/turbine/fulcrum/trunk/script/src/test/scripts/groovy/Avalon.groovy
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/script/src/test/scripts/groovy/Avalon.groovy?rev=366777&view=auto
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/scripts/groovy/Avalon.groovy (added)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/scripts/groovy/Avalon.groovy Sat Jan  7 07:25:56 2006
@@ -0,0 +1,45 @@
+/**
+  * 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;
+
+// 1) parse the arguments
+
+int foo = bar.intValue();
+
+// 2) access the avalonContext
+
+File applicationDir = avalonContext.getApplicationDir();
+File tempDir = avalonContext.getTempDir();
+
+// 3) create a property instance
+
+Properties props = new Properties();
+props.setProperty( "foo", bar.toString());
+assert( props.size() == 1 );
+props.clear();
+assert( props.size() == 0 );
+
+// 4) return a result
+
+int result = foo*10;
+
+return result;
\ No newline at end of file

Added: jakarta/turbine/fulcrum/trunk/script/src/test/scripts/groovy/CompilableInterface.groovy
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/script/src/test/scripts/groovy/CompilableInterface.groovy?rev=366777&view=auto
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/scripts/groovy/CompilableInterface.groovy (added)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/scripts/groovy/CompilableInterface.groovy Sat Jan  7 07:25:56 2006
@@ -0,0 +1,45 @@
+/*
+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:
+        counter = "first time"; break;
+    case 1:
+        counter = "second time"; break;
+    case 2:
+        counter = "third time";
+}
+println("\nRun compiled script, the " + counter);
+time = new Date(currentTime);
+println("Current time is " + time);

Added: jakarta/turbine/fulcrum/trunk/script/src/test/scripts/groovy/HelloWorld.groovy
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/script/src/test/scripts/groovy/HelloWorld.groovy?rev=366777&view=auto
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/scripts/groovy/HelloWorld.groovy (added)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/scripts/groovy/HelloWorld.groovy Sat Jan  7 07:25:56 2006
@@ -0,0 +1,34 @@
+/*
+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!';

Added: jakarta/turbine/fulcrum/trunk/script/src/test/scripts/groovy/MultiThreaded.groovy
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/script/src/test/scripts/groovy/MultiThreaded.groovy?rev=366777&view=auto
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/scripts/groovy/MultiThreaded.groovy (added)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/scripts/groovy/MultiThreaded.groovy Sat Jan  7 07:25:56 2006
@@ -0,0 +1,22 @@
+/**
+* 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>
+*/
+
+avalonContext.getLogger().debug( Thread.currentThread().getName() + " - Starting to run" );
+foo = foo * 2.0;
+avalonContext.getLogger().debug( Thread.currentThread().getName() + " - Finished running" );

Added: jakarta/turbine/fulcrum/trunk/script/src/test/scripts/groovy/NamespaceDemo2.groovy
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/script/src/test/scripts/groovy/NamespaceDemo2.groovy?rev=366777&view=auto
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/scripts/groovy/NamespaceDemo2.groovy (added)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/scripts/groovy/NamespaceDemo2.groovy Sat Jan  7 07:25:56 2006
@@ -0,0 +1,39 @@
+/*
+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);
+println("\nReplacing value of key with \"new value\"");
+key = "new value";
+println("-----End of script-----\n");

Added: jakarta/turbine/fulcrum/trunk/script/src/test/scripts/groovy/NamespaceDemo3.groovy
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/script/src/test/scripts/groovy/NamespaceDemo3.groovy?rev=366777&view=auto
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/scripts/groovy/NamespaceDemo3.groovy (added)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/scripts/groovy/NamespaceDemo3.groovy Sat Jan  7 07:25:56 2006
@@ -0,0 +1,52 @@
+/*
+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;
+println("In script....Initial state is " + initial);
+loop = 1;
+while (loop == 1) {
+	println("Script continues at state = " + state);
+	if (state != initial) {
+		println("State changed (state = " + state + "). Exit script.");
+		loop = 0;
+	}
+	//it takes groovy to long to start
+	if (state == 2) {
+		loop = 0
+	}
+}
+println("-----End of script-----\n");
+
+

Added: jakarta/turbine/fulcrum/trunk/script/src/test/scripts/groovy/RuntimeError.groovy
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/script/src/test/scripts/groovy/RuntimeError.groovy?rev=366777&view=auto
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/scripts/groovy/RuntimeError.groovy (added)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/scripts/groovy/RuntimeError.groovy Sat Jan  7 07:25:56 2006
@@ -0,0 +1,21 @@
+/**
+ * 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);
\ No newline at end of file

Added: jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/Avalon.js
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/Avalon.js?rev=366777&view=auto
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/Avalon.js (added)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/Avalon.js Sat Jan  7 07:25:56 2006
@@ -0,0 +1,60 @@
+/*
+ * 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.util);
+
+testMe(bar);
+
+function testMe(aBar) 
+{
+  // 1) parse the arguments
+
+  var foo = parseInt(aBar);
+
+  // 2) access the avalonContext
+
+  var logger = avalonContext.getLogger();
+  var applicationDir = avalonContext.getApplicationDir();
+  var tempDir = avalonContext.getTempDir();
+  var serviceManager = avalonContext.getServiceManager();
+  var parameters = avalonContext.getParameters();
+  var configuration = avalonContext.getConfiguration();
+  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);
+  logger.info("Logging from within a script ... :-)");
+  
+  // 3) create a property instance
+
+  var props = new Properties();
+  props.setProperty( "foo", bar );
+  if( props.size() != 1 ) throw "setting a property failed";
+  props.clear();
+  if( props.size() != 0 ) throw "setting a property failed";
+  
+  // 4) return a result
+
+  var result = foo*10;
+
+  return result;
+}
\ No newline at end of file

Added: jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/CompilableInterface.js
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/CompilableInterface.js?rev=366777&view=auto
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/CompilableInterface.js (added)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/CompilableInterface.js Sat Jan  7 07:25:56 2006
@@ -0,0 +1,47 @@
+/*
+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)) {
+	case 0:
+		counter = "first time"; break;
+	case 1:
+		counter = "second time"; break;
+	case 2:
+		counter = "third time";
+}
+// print("\nRun compiled script, the " + counter);
+// print ( "\nCurrentTime in milliSecond = " + currentTime );
+var time = new java.util.Date( new java.lang.Long( currentTime).longValue() );
+print("Current time is " + time);

Added: jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/HelloWorld.js
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/HelloWorld.js?rev=366777&view=auto
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/HelloWorld.js (added)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/HelloWorld.js Sat Jan  7 07:25:56 2006
@@ -0,0 +1,34 @@
+/*
+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!");

Added: jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/InvocableIntf.js
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/InvocableIntf.js?rev=366777&view=auto
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/InvocableIntf.js (added)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/InvocableIntf.js Sat Jan  7 07:25:56 2006
@@ -0,0 +1,52 @@
+/*
+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;
+
+function getX() {
+	return x;
+}
+
+function setX(value) {
+	x = value;
+}
+
+function getY() {
+	return new java.lang.Integer(y);
+}
+
+function setY(value) {
+	y = value;
+}
+

Added: jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/MultiThreaded.js
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/MultiThreaded.js?rev=366777&view=auto
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/MultiThreaded.js (added)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/MultiThreaded.js Sat Jan  7 07:25:56 2006
@@ -0,0 +1,25 @@
+/**
+* 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);
+
+avalonContext.getLogger().debug( Thread.currentThread().getName() + " - Starting to run" );
+Thread.sleep(1000);
+foo = foo * 2.0;
+avalonContext.getLogger().debug( Thread.currentThread().getName() + " - Finished running" );

Added: jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/NamespaceDemo2.js
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/NamespaceDemo2.js?rev=366777&view=auto
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/NamespaceDemo2.js (added)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/NamespaceDemo2.js Sat Jan  7 07:25:56 2006
@@ -0,0 +1,39 @@
+/*
+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);
+print("\nReplacing value of key with \"new value\"");
+key = "new value";
+print("-----End of script-----\n");

Added: jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/NamespaceDemo3.js
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/NamespaceDemo3.js?rev=366777&view=auto
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/NamespaceDemo3.js (added)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/NamespaceDemo3.js Sat Jan  7 07:25:56 2006
@@ -0,0 +1,51 @@
+/*
+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);
+print("In script....Initial state is " + initial);
+var loop = 1;
+while (loop == 1) {
+	print("Script continues at state = " + state);
+	if (parseInt(state) != initial) {
+		print("State changed (state = " + state + "). Exit script.");
+		loop = 0;
+	}
+	//it may take the script engine too long to start
+	if (parseInt(state)==2) {
+		loop = 0;
+	}
+}
+print("-----End of script-----\n");
+

Added: jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/RuntimeError.js
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/RuntimeError.js?rev=366777&view=auto
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/RuntimeError.js (added)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/RuntimeError.js Sat Jan  7 07:25:56 2006
@@ -0,0 +1,21 @@
+/*
+ * 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>
+ *
+ */
+ 
+print(foobar);
\ No newline at end of file

Added: jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/locator/bar/foo.js
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/locator/bar/foo.js?rev=366777&view=auto
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/locator/bar/foo.js (added)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/locator/bar/foo.js Sat Jan  7 07:25:56 2006
@@ -0,0 +1,6 @@
+testMe();
+
+function testMe(aBar) 
+{
+  return "locator/bar/foo.js";
+}

Added: jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/locator/foo.js
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/locator/foo.js?rev=366777&view=auto
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/locator/foo.js (added)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/scripts/js/locator/foo.js Sat Jan  7 07:25:56 2006
@@ -0,0 +1,6 @@
+testMe();
+
+function testMe(aBar) 
+{
+  return "locator/foo.js";
+}

Added: jakarta/turbine/fulcrum/trunk/script/xdocs/changes.xml
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/script/xdocs/changes.xml?rev=366777&view=auto
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/xdocs/changes.xml (added)
+++ jakarta/turbine/fulcrum/trunk/script/xdocs/changes.xml Sat Jan  7 07:25:56 2006
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<document>
+  <properties>
+    <title>Fulcrum Script Service</title>
+    <author email="siegfried.goeschl@it20one.at">Siegfried Goeschl</author>
+  </properties>
+
+  <body>
+    <release version="1.0.0" date="in SVN">
+      <action dev="sgoeschl" type="add">
+        Initial version
+      </action>
+    </release>
+  </body>
+</document>
+

Added: jakarta/turbine/fulcrum/trunk/script/xdocs/configuration.xml
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/script/xdocs/configuration.xml?rev=366777&view=auto
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/xdocs/configuration.xml (added)
+++ jakarta/turbine/fulcrum/trunk/script/xdocs/configuration.xml Sat Jan  7 07:25:56 2006
@@ -0,0 +1,160 @@
+<?xml version="1.0"?>
+
+<document>
+
+  <properties>
+    <title>Fulcrum Script Service</title>
+    <author email="siegfried.goeschl@it20one.at">Siegfried Goeschl</author>
+  </properties>
+
+  <body>
+
+    <section name="Configuration">
+
+      <subsection name="Component Configuration">
+        <table>
+          <tr>
+            <th>Item</th>
+            <th>Datatype</th>
+            <th>Cardinality</th>
+            <th>Description</th>
+          </tr>
+          <tr>
+            <td>scriptEngines</td>
+            <td>Complex</td>
+            <td>[1]</td>
+            <td>
+            	The list of available script engines
+            </td>
+          </tr>
+          <tr>
+            <td>scriptEngines\scriptEngine</td>
+            <td>Complex</td>
+            <td>[1..n]</td>
+            <td>
+              Metadata about a particular script engine
+            </td>
+          </tr>
+          <tr>
+            <td>scriptEngines\scriptEngine\name</td>
+            <td>String</td>
+            <td>[1]</td>
+            <td>
+              The name of the script engine to lookup the implementation
+              using the ScriptEngineManager.getEngineByName()
+            </td>
+          </tr>
+          <tr>
+            <td>scriptEngines\scriptEngine\isCached</td>
+            <td>boolean</td>
+            <td>[0|1]</td>
+            <td>
+            	Is the script cached or reloaded from the resource service
+            	each time? This setting is useful for debugging when you edit
+            	the script on the fly since the changes take place immediatly.
+            </td>
+          </tr>
+          <tr>
+            <td>scriptEngines\scriptEngine\isCompiled</td>
+            <td>boolean</td>
+            <td>[0|1]</td>
+            <td>
+            	Is the script compiled to an internal representation before being
+            	executed. Using a compiled script improves the performance together
+            	with cached scripts (see above)
+            </td>
+          </tr>
+          <tr>
+            <td>scriptEngines\scriptEngine\location</td>
+            <td>String</td>
+            <td>[0|1]</td>
+            <td>
+            	The location of the scripts regarding the resource service. If no 
+              value is supplied than &lt;name&gt; is used.
+            </td>
+          </tr>
+          <tr>
+            <td>scriptEngines\scriptEngine\preLoad</td>
+            <td>Complex</td>
+            <td>[0|1]</td>
+            <td>
+              A list of scripts to preload during startup.
+            </td>
+          </tr>
+          <tr>
+            <td>scriptEngines\scriptEngine\preLoad\script</td>
+            <td>String</td>
+            <td>[0..n]</td>
+            <td>
+              A script to preload during startup.
+            </td>
+          </tr>
+          <tr>
+            <td>scriptConfiguration</td>
+            <td>Complex</td>
+            <td>[0|1]</td>
+            <td>
+              Contains the user-defined configuration to pass
+              to the executed script using the AvalonScriptContext.
+            </td>
+          </tr>          
+        </table>
+      </subsection>
+
+      <subsection name="Component Configuration Example">
+
+        <source>
+          <![CDATA[
+<ResourceManagerService>
+  <domain name="js">
+    <suffix>js</suffix>
+    <location>./src/test/scripts/js</location>
+    <useLocator>true</useLocator>
+  </domain>
+</ResourceManagerService>
+
+<ScriptService>
+  <scriptEngines>
+    <scriptEngine>
+      <name>js</name>
+      <isCached>true</isCached>
+      <isCompiled>true</isCompiled>
+      <location>js</location>
+      <preLoad>
+        <script>InvocableIntf.js</script>
+      </preLoad>
+    </scriptEngine>
+  </scriptEngines>
+  <scriptConfiguration>
+    <isDebug>true</isDebug>
+  </scriptConfiguration>
+</ScriptService>
+          ]]>
+        </source>
+      </subsection>
+
+      <subsection name="Role Configuration Example">
+        <source>
+          <![CDATA[
+<role
+    name="org.apache.fulcrum.resourcemanager.ResourceManagerService"
+    default-class="org.apache.fulcrum.resourcemanager.impl.ResourceManagerServiceImpl"
+    shorthand="ResourceManagerService"
+    early-init="true"
+    description="Handles the management of resources"
+ />
+<role
+    name="org.apache.fulcrum.script.ScriptService"
+    default-class="org.apache.fulcrum.script.impl.ScriptServiceImpl"
+    shorthand="ScriptService"
+    early-init="true"
+    description="Handles the execution of scripts"
+ />
+          ]]>
+        </source>
+      </subsection>
+    </section>
+
+  </body>
+
+</document>



---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org