From: <st...@us...> - 2009-09-23 10:23:24
|
Revision: 7876 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7876&view=rev Author: steve_l Date: 2009-09-23 10:23:13 +0000 (Wed, 23 Sep 2009) Log Message: ----------- SFOS-1296 Move javax.scripting code from components/groovy into sfServices This also involves moving a bit of the scripting component around, so that the shared interface is in services, in a different package from any of the components (in case they are later sealed) Modified Paths: -------------- trunk/core/components/groovy/ivy.xml trunk/core/components/scripting/build.xml trunk/core/components/scripting/src/org/smartfrog/services/scripting/components.sf trunk/core/components/scripting/src/org/smartfrog/services/scripting/examples/examples.sf trunk/core/components/scripting/src/org/smartfrog/services/scripting/examples/function_expression.sf trunk/core/components/scripting/test/org/smartfrog/test/system/components/scripting/TCN80.sf Added Paths: ----------- trunk/core/components/scripting/src/org/smartfrog/services/scripting/bsh/ trunk/core/components/scripting/src/org/smartfrog/services/scripting/bsh/Expression.java trunk/core/components/scripting/src/org/smartfrog/services/scripting/bsh/ScriptPrimImpl.java trunk/core/components/scripting/src/org/smartfrog/services/scripting/bsh/button.sf trunk/core/components/scripting/src/org/smartfrog/services/scripting/bsh/components.sf trunk/core/components/scripting/src/org/smartfrog/services/scripting/bsh/functions.sf trunk/core/components/scripting/src/org/smartfrog/services/scripting/bsh/heartbeat.sf trunk/core/components/scripting/src/org/smartfrog/services/scripting/bsh/scriptPrim.sf trunk/core/components/scripting/src/org/smartfrog/services/scripting/functions.sf trunk/core/components/scripting/src/org/smartfrog/services/scripting/scriptPrim.sf trunk/core/smartfrog/src/org/smartfrog/services/scripting/ trunk/core/smartfrog/src/org/smartfrog/services/scripting/common/ trunk/core/smartfrog/src/org/smartfrog/services/scripting/common/RemoteScriptPrim.java trunk/core/smartfrog/src/org/smartfrog/services/scripting/javax/ trunk/core/smartfrog/src/org/smartfrog/services/scripting/javax/JavaxScript.java trunk/core/smartfrog/src/org/smartfrog/services/scripting/javax/JavaxScriptingCondition.java trunk/core/smartfrog/src/org/smartfrog/services/scripting/javax/JavaxScriptingConditionImpl.java trunk/core/smartfrog/src/org/smartfrog/services/scripting/javax/JavaxScriptingImpl.java trunk/core/smartfrog/src/org/smartfrog/services/scripting/javax/ScriptHelper.java trunk/core/smartfrog/src/org/smartfrog/services/scripting/javax/Variables.java trunk/core/testharness/testcases/org/smartfrog/test/system/scripting/ trunk/core/testharness/testcases/org/smartfrog/test/system/scripting/javax/ trunk/core/testharness/testcases/org/smartfrog/test/system/scripting/javax/ScriptHelperTest.java trunk/core/testharness/testcases/org/smartfrog/test/system/scripting/js/ trunk/core/testharness/testcases/org/smartfrog/test/system/scripting/js/JavascriptTest.java trunk/core/testharness/testcases/org/smartfrog/test/system/scripting/js/components.sf trunk/core/testharness/testcases/org/smartfrog/test/system/scripting/js/condition.js trunk/core/testharness/testcases/org/smartfrog/test/system/scripting/js/hello.js trunk/core/testharness/testcases/org/smartfrog/test/system/scripting/js/testConditionFalse.sf trunk/core/testharness/testcases/org/smartfrog/test/system/scripting/js/testConditionScriptError.sf trunk/core/testharness/testcases/org/smartfrog/test/system/scripting/js/testConditionTrue.sf trunk/core/testharness/testcases/org/smartfrog/test/system/scripting/js/testFailOnStartup.sf trunk/core/testharness/testcases/org/smartfrog/test/system/scripting/js/testInlineLifecycle.sf trunk/core/testharness/testcases/org/smartfrog/test/system/scripting/js/testInlineLifecycleTerminating.sf trunk/core/testharness/testcases/org/smartfrog/test/system/scripting/js/testResourceTerminating.sf Removed Paths: ------------- trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScript.java trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScriptingCondition.java trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScriptingConditionImpl.java trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScriptingImpl.java trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/RemoteCompiledScript.java trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/ScriptHelper.java trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/Variables.java trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/components.sf trunk/core/components/groovy/src/org/smartfrog/services/scripting/js/components.sf trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/javax/ScriptHelperTest.java trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/javax/components.sf trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/JavascriptTest.java trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/components.sf trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/condition.js trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/hello.js trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/testConditionFalse.sf trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/testConditionScriptError.sf trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/testConditionTrue.sf trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/testFailOnStartup.sf trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/testInlineLifecycle.sf trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/testInlineLifecycleTerminating.sf trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/testResourceTerminating.sf trunk/core/components/scripting/rmitargets trunk/core/components/scripting/src/org/smartfrog/services/scripting/Expression.java trunk/core/components/scripting/src/org/smartfrog/services/scripting/RemoteScriptPrim.java trunk/core/components/scripting/src/org/smartfrog/services/scripting/ScriptPrimImpl.java trunk/core/components/scripting/src/org/smartfrog/services/scripting/button.sf trunk/core/components/scripting/src/org/smartfrog/services/scripting/functions.sf trunk/core/components/scripting/src/org/smartfrog/services/scripting/heartbeat.sf trunk/core/components/scripting/src/org/smartfrog/services/scripting/scriptPrim.sf trunk/core/smartfrog/src/org/smartfrog/services/scripting/javax/JavaxScript.java trunk/core/smartfrog/src/org/smartfrog/services/scripting/javax/JavaxScriptingCondition.java trunk/core/smartfrog/src/org/smartfrog/services/scripting/javax/JavaxScriptingConditionImpl.java trunk/core/smartfrog/src/org/smartfrog/services/scripting/javax/JavaxScriptingImpl.java trunk/core/smartfrog/src/org/smartfrog/services/scripting/javax/ScriptHelper.java trunk/core/smartfrog/src/org/smartfrog/services/scripting/javax/Variables.java Modified: trunk/core/components/groovy/ivy.xml =================================================================== --- trunk/core/components/groovy/ivy.xml 2009-09-23 09:39:31 UTC (rev 7875) +++ trunk/core/components/groovy/ivy.xml 2009-09-23 10:23:13 UTC (rev 7876) @@ -5,8 +5,7 @@ <license name="LGPL"/> <ivyauthor name="Hewlett-Packard" url="http://www.smartfrog.org"/> <description> - Beanshell Scripting Component - Created 16-Nov-2006 + Groovy Component </description> </info> <!-- FIXME: Ivy 1.4.1 buildlist bug @@ -57,10 +56,6 @@ changing="true" rev="latest.integration" conf="test->default"/> - <dependency org="org.smartfrog" - name="sf-scripting" changing="true" - rev="latest.integration" - conf="runtime->default"/> <dependency org="org.codehaus.groovy" name="groovy-all-minimal" rev="${groovy.version}" Deleted: trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScript.java =================================================================== --- trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScript.java 2009-09-23 09:39:31 UTC (rev 7875) +++ trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScript.java 2009-09-23 10:23:13 UTC (rev 7876) @@ -1,65 +0,0 @@ -/* (C) Copyright 2009 Hewlett-Packard Development Company, LP - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - For more information: www.smartfrog.org - - */ - -package org.smartfrog.services.scripting.javax; - -import org.smartfrog.services.scripting.RemoteScriptPrim; - -/** - * extras for the javax scripting supporting - */ -public interface JavaxScript extends RemoteScriptPrim { - - /** - * {@value} - */ - String ATTR_SF_DEPLOY_RESOURCE = "sfDeployResource"; - - /** - * {@value} - */ - String ATTR_SF_START_RESOURCE = "sfStartResource"; - - /** - * {@value} - */ - String ATTR_SF_PING_RESOURCE = "sfPingResource"; - - /** - * {@value} - */ - String ATTR_SF_TERMINATE_WITH_RESOURCE = "sfTerminateWithResource"; - - /** - * {@value} - */ - String ATTR_SF_CONDITION_RESOURCE = "sfConditionResource"; - - /** - * {@value} - */ - String ATTR_SF_CONDITION_CODE = "sfConditionCode"; - - /** - * {@value} - */ - String ATTR_COMPILE = "compile"; - -} Deleted: trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScriptingCondition.java =================================================================== --- trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScriptingCondition.java 2009-09-23 09:39:31 UTC (rev 7875) +++ trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScriptingCondition.java 2009-09-23 10:23:13 UTC (rev 7876) @@ -1,57 +0,0 @@ -/* (C) Copyright 2009 Hewlett-Packard Development Company, LP - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -For more information: www.smartfrog.org - -*/ -package org.smartfrog.services.scripting.javax; - -import org.smartfrog.sfcore.common.SmartFrogException; -import org.smartfrog.sfcore.workflow.conditional.Condition; - -import java.rmi.RemoteException; - -/** - * A condition with accessors for the script to read/write the value - */ - - -public interface JavaxScriptingCondition extends Condition { - - /** - * The attribute which is set for a true condition: self.condition = true - */ - String ATTR_CONDITION = "condition"; - - - /** - * Evaluate the condition status - * - * @return true iff the condition is set - * @throws RemoteException network problems - * @throws SmartFrogException SF problems - */ - boolean isCondition() throws RemoteException, SmartFrogException; - - /** - * Set the condition attribute - * - * @param condition new value - * @throws RemoteException network problems - * @throws SmartFrogException SF problems - */ - void setCondition(boolean condition) throws RemoteException, SmartFrogException; -} Deleted: trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScriptingConditionImpl.java =================================================================== --- trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScriptingConditionImpl.java 2009-09-23 09:39:31 UTC (rev 7875) +++ trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScriptingConditionImpl.java 2009-09-23 10:23:13 UTC (rev 7876) @@ -1,60 +0,0 @@ -/* (C) Copyright 2008 Hewlett-Packard Development Company, LP - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - For more information: www.smartfrog.org - - */ - - -package org.smartfrog.services.scripting.javax; - -import org.smartfrog.sfcore.common.SmartFrogException; -import org.smartfrog.sfcore.common.SmartFrogResolutionException; -import org.smartfrog.sfcore.common.SmartFrogRuntimeException; - -import java.rmi.RemoteException; - -/** - * scriptable condition - */ -public class JavaxScriptingConditionImpl extends JavaxScriptingImpl implements JavaxScriptingCondition { - public static final String ERROR_NOT_BOOLEAN = "Return value is not a boolean:"; - - private boolean condition; - - public JavaxScriptingConditionImpl() throws RemoteException { - } - - @Override - protected void bindAttributes() throws SmartFrogResolutionException, RemoteException { - condition = sfResolve(ATTR_CONDITION, condition, true); - super.bindAttributes(); - } - - public boolean isCondition() { - return condition; - } - - public void setCondition(boolean condition) throws SmartFrogRuntimeException, RemoteException { - this.condition = condition; - sfReplaceAttribute(ATTR_CONDITION, condition); - } - - public synchronized boolean evaluate() throws RemoteException, SmartFrogException { - Object result = resolveAndEvaluate(ATTR_SF_CONDITION_RESOURCE, ATTR_SF_CONDITION_CODE); - return isCondition(); - } -} Deleted: trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScriptingImpl.java =================================================================== --- trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScriptingImpl.java 2009-09-23 09:39:31 UTC (rev 7875) +++ trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScriptingImpl.java 2009-09-23 10:23:13 UTC (rev 7876) @@ -1,191 +0,0 @@ -/** (C) Copyright 1998-2009 Hewlett-Packard Development Company, LP - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - For more information: www.smartfrog.org - - */ - -package org.smartfrog.services.scripting.javax; - -import org.smartfrog.sfcore.common.SmartFrogException; -import org.smartfrog.sfcore.common.SmartFrogLivenessException; -import org.smartfrog.sfcore.common.SmartFrogResolutionException; -import org.smartfrog.sfcore.prim.PrimImpl; -import org.smartfrog.sfcore.prim.TerminationRecord; -import org.smartfrog.sfcore.utils.ComponentHelper; - -import javax.script.ScriptException; -import java.rmi.RemoteException; - -/** - * JavaxScriptingImpl is a SmartFrog component which allows the user to write bits of java code in the description. - * javax.scripting is used to interpret them. It also implements the {@link JavaxScript} interface which allows scripts - * to be remotely executed - */ -public class JavaxScriptingImpl extends PrimImpl implements JavaxScript { - - private ScriptHelper scriptHelper; - private ScriptHelper.LoadedEngine engine; - - /** - * {@value} - */ - - public static final String ERROR_EVAL = "There was an error in evaluating the script:"; - - /** - * Standard RMI constructor - * - * @throws RemoteException superclass trouble - */ - public JavaxScriptingImpl() throws RemoteException { - } - - - /** - * Deploy the ScriptPrimImpl component. It binds the 'prim' string to this instance for the interpreter. The - * following attributes are looked up : - <ol> <li>If the 'attributesAsVariables' attribute is set to true / "true" - * in the description, binds all attributes present during deploy phase to their keys for easier use in the - * interpreter.</li> <li> If the 'sfScriptCodeBase' attribute is present it will be used to find all the source - * scripts for all phases.</li> <li> If the 'sfDeployCode' is present the deploy script is evaluated.</li> - */ - @Override - public void sfDeploy() throws SmartFrogException, RemoteException { - super.sfDeploy(); - String language = sfResolve(ATTR_LANGUAGE, "", true); - scriptHelper = new ScriptHelper(this); - engine = scriptHelper.createEngine(language); - bindAttributes(); - resolveAndEvaluate(ATTR_SF_DEPLOY_RESOURCE, ATTR_SF_DEPLOY_CODE); - } - - protected void bindAttributes() throws SmartFrogResolutionException, RemoteException { - engine.bindAttributes(); - } - - /** - * Start phase : execute the startup code, then maybe begin the termination phase - * - * @throws SmartFrogException startup failure - * @throws RemoteException remote failure - */ - @Override - public void sfStart() throws SmartFrogException, RemoteException { - super.sfStart(); - resolveAndEvaluate(ATTR_SF_START_RESOURCE, ATTR_SF_START_CODE); - new ComponentHelper(this).sfSelfDetachAndOrTerminate(null, null, sfCompleteName(), null); - } - - /** - * Ping operation calls the ping script - * - * @param source source of call - * @throws SmartFrogLivenessException liveness failure - * @throws RemoteException netwoork problems - */ - @Override - public void sfPing(Object source) throws SmartFrogLivenessException, RemoteException { - super.sfPing(source); - try { - engine.resolveAndEvaluate(ATTR_SF_PING_RESOURCE, ATTR_SF_PING_CODE); - } catch (Exception e) { - throw (SmartFrogLivenessException) - SmartFrogLivenessException.forward(ERROR_EVAL + e, scriptHelper.convert(e)); - } - } - - /** - * During termination phase execute the code described within the 'sfTerminateWithCode' attribute. Any exception is - * caught and left untreated. - * - * @param status the TerminationRecord for this phase. - */ - @Override - public void sfTerminateWith(TerminationRecord status) { - try { - engine.resolveAndEvaluate(ATTR_SF_TERMINATE_WITH_RESOURCE, ATTR_SF_TERMINATE_WITH_CODE); - } catch (SmartFrogException e) { - sfLog().ignore(e, e); - } catch (RemoteException e) { - sfLog().error(e, e); - } catch (ScriptException e) { - sfLog().error(e, e); - } - super.sfTerminateWith(status); - } - - /** - * Resolve the attributes, evaluate the code, convert Scripting Exceptions into SmartFrog ones - * - * @param resource resource attribute to look for - * @param inline inline source attribute to look for - * @return the return value of the evaluation - * @throws SmartFrogException if the resolution or the script fails - * @throws RemoteException network problems - */ - protected Object resolveAndEvaluate(String resource, String inline) throws SmartFrogException, RemoteException { - try { - return engine.resolveAndEvaluate(resource, inline); - } catch (ScriptException e) { - throw scriptHelper.convert(e); - } - } - - - /** - * Bind an object to a name in the beanshell interpreter. - * - * @param name the name you want the object to be called in the interpreter - * @param obj the object you want to register in the interpreter. - */ - public synchronized void setRemote(String name, Object obj) throws - SmartFrogException, RemoteException { - try { - engine.set(name, obj); - } - catch (Throwable thr) { - throw SmartFrogException.forward(thr); - } - } - - /** - * Evaluate the String as a beanshell script. The string is handed off to the internal interpreter object - * - * @param script the script as a string. - * @return the result - * @throws SmartFrogException execution failure - * @throws RemoteException network trouble - */ - public synchronized Object eval(String script) throws SmartFrogException, - RemoteException { - try { - return engine.eval(script); - } catch (ScriptException e) { - throw scriptHelper.convert(e); - } - } - - /** - * For nested scripts: thrown an exception with a text message - * - * @param message text to include in the message - * @throws SmartFrogException the exception that is thrown - */ - public void fail(String message) throws SmartFrogException { - throw new SmartFrogException(message); - } - -} \ No newline at end of file Deleted: trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/RemoteCompiledScript.java =================================================================== --- trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/RemoteCompiledScript.java 2009-09-23 09:39:31 UTC (rev 7875) +++ trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/RemoteCompiledScript.java 2009-09-23 10:23:13 UTC (rev 7876) @@ -1,30 +0,0 @@ -/* (C) Copyright 2008 Hewlett-Packard Development Company, LP - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - For more information: www.smartfrog.org - - */ - -package org.smartfrog.services.scripting.javax; - -import java.rmi.Remote; - -/** - * - */ -public interface RemoteCompiledScript extends Remote { - -} Deleted: trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/ScriptHelper.java =================================================================== --- trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/ScriptHelper.java 2009-09-23 09:39:31 UTC (rev 7875) +++ trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/ScriptHelper.java 2009-09-23 10:23:13 UTC (rev 7876) @@ -1,337 +0,0 @@ -/* (C) Copyright 2009 Hewlett-Packard Development Company, LP - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -For more information: www.smartfrog.org - -*/ -package org.smartfrog.services.scripting.javax; - -import org.smartfrog.sfcore.common.SmartFrogException; -import org.smartfrog.sfcore.common.SmartFrogLifecycleException; -import org.smartfrog.sfcore.prim.PrimImpl; -import org.smartfrog.sfcore.utils.ComponentHelper; - -import javax.script.Compilable; -import javax.script.CompiledScript; -import javax.script.ScriptContext; -import javax.script.ScriptEngine; -import javax.script.ScriptEngineManager; -import javax.script.ScriptException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.rmi.RemoteException; -import java.util.Enumeration; - -/** - * Anything to help with script engine work - */ - -public class ScriptHelper { - - private PrimImpl owner; - private ComponentHelper compHelper; - private ScriptEngineManager manager; - public static final String ERROR_NO_ENGINE = "Failed to load a scripting engine for the language "; - public static final String FILENAME = "filename"; - public static final String LINE = "line"; - public static final String COLUMN = "column"; - - public ScriptHelper(PrimImpl owner) { - this.owner = owner; - compHelper = new ComponentHelper(owner); - manager = new ScriptEngineManager(); - } - - - /** - * Create an engine in the given language - * - * @param language language to use - * @return the engine - * @throws SmartFrogLifecycleException if the engine could not be created - */ - public LoadedEngine createEngine(String language) throws SmartFrogLifecycleException { - ScriptEngine engine = manager.getEngineByName(language); - if (engine == null) { - throw new SmartFrogLifecycleException(ERROR_NO_ENGINE - + language); - } - return new LoadedEngine(language, engine); - } - - /** - * Load a resource - * - * @param resource resource to load - * @return a reader for that resource - * @throws SmartFrogException if the resource can not be found - * @throws RemoteException for network problems - */ - public Reader loadResource(String resource) throws SmartFrogException, RemoteException { - InputStream inputStream = compHelper.loadResource(resource); - return new InputStreamReader(inputStream); - } - - - /** - * Convert a caught exception into a smartforg exception. This can include extracting of an existing SmartFrog - * exception from inside a ScriptException - * - * @param thrown what was thrown - * @return a SmartFrog exception. - */ - public SmartFrogLifecycleException convert(Throwable thrown) { - String message = thrown.toString(); - SmartFrogException sfe = extractNestedSFE(thrown); - if (sfe != null) { - return (SmartFrogLifecycleException) SmartFrogLifecycleException.forward(message, sfe, owner); - } else { - return (SmartFrogLifecycleException) SmartFrogLifecycleException.forward(message, thrown, owner); - } - } - - /** - * recurse down to find any nested SmartFrog exception - * - * @param thrown what was thrown, can be null - * @return the first SmartFrogException in the chain, or null - */ - public SmartFrogException extractNestedSFE(Throwable thrown) { - if (thrown == null) { - return null; - } - if (thrown instanceof SmartFrogException) { - return (SmartFrogException) thrown; - } - SmartFrogException extracted = extractNestedSFE(thrown.getCause()); - if (extracted != null && thrown instanceof ScriptException) { - ScriptException se = (ScriptException) thrown; - extracted.add(FILENAME, se.getFileName()); - extracted.add(LINE, se.getLineNumber()); - extracted.add(COLUMN, se.getColumnNumber()); - } - return extracted; - } - - - /** - * Represents a loaded engine, has some helper methods - */ - public class LoadedEngine { - - public ScriptEngine engine; - public String language; - private boolean isJavaFX; - - /** - * Bind to a loaded engine - * - * @param language language name - * @param engine engine - */ - public LoadedEngine(String language, ScriptEngine engine) { - this.engine = engine; - this.language = language; - isJavaFX = "FX".equalsIgnoreCase(language); - } - - /** - * Get the engine - * - * @return the engine - */ - public ScriptEngine getEngine() { - return engine; - } - - /** - * Get the language - * - * @return the language - */ - public String getLanguage() { - return language; - } - - /** - * Put a name value pair into the context of the engine. This extends {@link ScriptEngine#put(String,Object)} by - * special support for JavaFX naming policy, copying Ant's example - * - * @param name name to use - * @param value value to put - */ - public void set(String name, Object value) { - if (isJavaFX) { - engine.put(name + ':' + value.getClass().getName(), value); - } else { - engine.put(name, value); - } - } - - /** - * Remove a property - * - * @param name property to remove from context - */ - public void unset(String name) { - engine.getBindings(ScriptContext.ENGINE_SCOPE).remove(name); - } - - /** - * Evaluate a script held in a string - * - * @param script script to evaluate - * @return the result - * @throws ScriptException failure to evaluate - */ - public Object eval(String script) throws ScriptException { - return engine.eval(script); - } - - /** - * Evaluate an input stream - * - * @param reader input - * @return the result - * @throws ScriptException failure to evaluate - */ - public Object eval(Reader reader) throws ScriptException { - return engine.eval(reader); - } - - /** - * Load a resource and evaluate it - * - * @param resource resource to load - * @return the result - * @throws ScriptException failure to evaluate - * @throws SmartFrogException problems loading the resource - * @throws RemoteException network probems - */ - public Object evalResource(String resource) throws ScriptException, SmartFrogException, RemoteException { - set(ScriptEngine.FILENAME, resource); - try { - Reader reader = loadResource(resource); - return eval(reader); - } finally { - unset(ScriptEngine.FILENAME); - } - } - - /** - * Can this engine compile code? - * - * @return true iff the engine implements {@link Compilable} - */ - public boolean canCompile() { - return engine instanceof Compilable; - } - - /** - * Compile the script. Only works if {@link #canCompile()} is true - * - * @param script text to compile - * @return the compiled script - * @throws ScriptException parse/compile problems - * @throws ClassCastException the engine does not compile - */ - CompiledScript compile(String script) - throws ScriptException { - return getCompilable().compile(script); - } - - /** - * Compile the script. Only works if {@link #canCompile()} is true - * - * @param reader input - * @return the compiled script - * @throws ScriptException parse/compile problems - * @throws ClassCastException the engine does not compile - */ - CompiledScript compile(Reader reader) - throws ScriptException { - return getCompilable().compile(reader); - } - - /** - * Compile the script. Only works if {@link #canCompile()} is true - * - * @param resource resource to load - * @return the compiled script - * @throws ScriptException parse/compile problems - * @throws ClassCastException the engine does not compile - * @throws SmartFrogException problems loading the resource - * @throws RemoteException network probems - */ - - public Object compileResource(String resource) throws ScriptException, SmartFrogException, RemoteException { - Reader reader = loadResource(resource); - return compile(reader); - } - - private Compilable getCompilable() { - return ((Compilable) engine); - } - - - /** - * Bind the attributes of the owner to the script context. - */ - public void bindAttributes() { - set(Variables.PRIM, owner); - set(Variables.SELF, owner); - set(Variables.LOG, owner.sfLog()); - - // go through all the attributes and bind them in the interpreter. - for (Enumeration e = owner.sfContext().keys(); e.hasMoreElements();) { - String attName = (String) e.nextElement(); - set(attName, owner.sfContext().get(attName)); - } - } - - - /** - * Resolve the resource and inline attributes (both of which must be present), <ol> <li>If the resource - * attribute resolves to a non-empty string, then the attribute {@link JavaxScript#ATTR_SF_SCRIPT_CODE_BASE} is - * resolved and prepended to the resource attribute; the resource is then loaded and executed</li> <li>If the - * inline attribute resolves to a non-empty string, it is evaluated</li> </ol> - * - * @param attrResource name of an attribute that should resolve to a resource - * @param attrInline name of an an attribute containing an inline string - * @return the result of the evaluation, or null if neither got evaluated - * @throws SmartFrogException Failure to load the resource, resolve attributes - * @throws RemoteException network problems - * @throws ScriptException if the script failed - */ - public Object resolveAndEvaluate(String attrResource, String attrInline) throws SmartFrogException, - RemoteException, ScriptException { - String resourceName = owner.sfResolve(attrResource, "", true); - String inline = owner.sfResolve(attrInline, "", true); - - if (!resourceName.isEmpty()) { - String codebase = owner.sfResolve(JavaxScript.ATTR_SF_SCRIPT_CODE_BASE, "", true); - return evalResource(codebase + resourceName); - } else if (!inline.isEmpty()) { - return eval(inline); - } else { - return null; - } - } - } - -} - Deleted: trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/Variables.java =================================================================== --- trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/Variables.java 2009-09-23 09:39:31 UTC (rev 7875) +++ trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/Variables.java 2009-09-23 10:23:13 UTC (rev 7876) @@ -1,46 +0,0 @@ -/* (C) Copyright 2008 Hewlett-Packard Development Company, LP - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - For more information: www.smartfrog.org - - */ - -package org.smartfrog.services.scripting.javax; - -/** - * - */ -public interface Variables { - - /** - * the component {@value} - */ - - String PRIM = "prim"; - /** - * status variable {@value} - */ - String STATUS = "status"; - String SELF = "self"; - /** - * The log {@value} - */ - String LOG = "log"; - /** - * The attribute which is set for a true condition: self.condition = true {@value} - */ - String CONDITION = "condition"; -} Deleted: trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/components.sf =================================================================== --- trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/components.sf 2009-09-23 09:39:31 UTC (rev 7875) +++ trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/components.sf 2009-09-23 10:23:13 UTC (rev 7876) @@ -1,91 +0,0 @@ -/* (C) Copyright 2009 Hewlett-Packard Development Company, LP - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -For more information: www.smartfrog.org - -*/ - -#include "/org/smartfrog/components.sf" - -/** - * Scripting engine; - * - * the resource attributes are read before the code ones; if both are empty strings then - * that specific phase is a no-op - */ -JavaxScripting extends WorkflowPrim { - sfClass "org.smartfrog.services.scripting.javax.JavaxScriptingImpl"; - language ""; - - sfScriptCodeBase ""; - - - sfDeployResource ""; - sfDeployCode ""; - - sfStartResource ""; - sfStartCode ""; - - sfPingResource ""; - sfPingCode ""; - - sfTerminateWithResource ""; - sfTerminateWithCode ""; - - - JAVASCRIPT "javascript"; - JAVAFX "fx"; - GROOVY "groovy"; - -} - -/** - * this component will terminate after the start operation - */ -JavaxScriptingWorkflow extends JavaxScripting { - sfShouldTerminate true; -} - -/** - * The condition component has all the same scripted events as the main scripting component, - * but also provides a new script that is executed whenever the condition interfaces evaluate() method - * is called. The return value from this script must be boolean/Boolean, or an error is raised - */ -JavaxScriptingCondition extends JavaxScripting { - sfClass "org.smartfrog.services.scripting.javax.JavaxScriptingConditionImpl"; - sfConditionResource ""; - sfConditionCode ""; - //this attribute is read to see if the condition succeeded. - condition false; -} - -/** - * here are some constants - */ -JavaxScriptingErrors extends { - - /** - * Error in a condition when the return is not a boolean - */ - ERROR_NOT_BOOLEAN CONSTANT org.smartfrog.services.scripting.javax.JavaxScriptingConditionImpl.ERROR_NOT_BOOLEAN; - - /** - * text seen when a script would not evaluate - */ - ERROR_EVAL CONSTANT org.smartfrog.services.scripting.javax.JavaxScriptingImpl.ERROR_EVAL; - - -} \ No newline at end of file Deleted: trunk/core/components/groovy/src/org/smartfrog/services/scripting/js/components.sf =================================================================== --- trunk/core/components/groovy/src/org/smartfrog/services/scripting/js/components.sf 2009-09-23 09:39:31 UTC (rev 7875) +++ trunk/core/components/groovy/src/org/smartfrog/services/scripting/js/components.sf 2009-09-23 10:23:13 UTC (rev 7876) @@ -1,33 +0,0 @@ -/* (C) Copyright 2009 Hewlett-Packard Development Company, LP - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -For more information: www.smartfrog.org - -*/ -#include "/org/smartfrog/services/scripting/javax/components.sf" - -JavaScript extends JavaxScripting { - language JAVASCRIPT; -} - -JavaScriptWorkflow extends JavaxScriptingWorkflow { - language JAVASCRIPT; -} - -JavaScriptCondition extends JavaxScriptingCondition { - language JAVASCRIPT; -} - Deleted: trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/javax/ScriptHelperTest.java =================================================================== --- trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/javax/ScriptHelperTest.java 2009-09-23 09:39:31 UTC (rev 7875) +++ trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/javax/ScriptHelperTest.java 2009-09-23 10:23:13 UTC (rev 7876) @@ -1,122 +0,0 @@ -/* (C) Copyright 2009 Hewlett-Packard Development Company, LP - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -For more information: www.smartfrog.org - -*/ -package org.smartfrog.test.system.services.scripting.javax; - -import junit.framework.TestCase; -import org.smartfrog.services.scripting.javax.ScriptHelper; -import org.smartfrog.sfcore.common.SmartFrogException; -import org.smartfrog.sfcore.common.SmartFrogLifecycleException; - -import javax.script.ScriptException; - -/** - * Created 20-Feb-2009 13:44:51 - */ - -public class ScriptHelperTest extends TestCase { - - - ScriptHelper helper; - ScriptException base; - private SmartFrogLifecycleException sfException; - private RuntimeException rte; - private static final int COLUMN_NUMBER = 4; - private static final int LINE_NUMBER = 23; - private static final String FILENAME = "filename"; - private RuntimeException noChild; - - - /** - * Sets up the fixture, for example, open a network connection. This method is called before a test is executed. - */ - @Override - protected void setUp() throws Exception { - super.setUp(); - helper = new ScriptHelper(null); - base = new ScriptException("base", FILENAME, LINE_NUMBER, COLUMN_NUMBER); - rte = new RuntimeException("inner"); - base.initCause(rte); - sfException = new SmartFrogLifecycleException("bottom"); - rte.initCause(sfException); - noChild = new RuntimeException("No child"); - } - - public void testExtractOne() throws Throwable { - assertExtracted(sfException); - } - - public void testExtractTwo() throws Throwable { - assertExtracted(rte); - } - - public void testExtractThree() throws Throwable { - SmartFrogException sfe = assertExtracted(base); - assertScriptLocationPropagated(sfe); - } - - - public void testNullExtract() throws Throwable { - assertNull(extractNestedSFE(null)); - } - - public void testNoChild() throws Throwable { - assertNull(extractNestedSFE(noChild)); - } - - - public void testConvertSFE() throws Throwable { - SmartFrogException sfe = helper.convert(sfException); - assertIsLiveness(sfe); - } - - public void testConvertInner() throws Throwable { - SmartFrogException sfe = helper.convert(rte); - } - - - public void testConvert() throws Throwable { - SmartFrogException sfe = helper.convert(base); - assertIsLiveness(sfe); - assertScriptLocationPropagated(sfe); - } - - private void assertScriptLocationPropagated(SmartFrogException sfe) { - assertEquals(FILENAME, sfe.get(ScriptHelper.FILENAME)); - assertEquals(LINE_NUMBER, sfe.get(ScriptHelper.LINE)); - assertEquals(COLUMN_NUMBER, sfe.get(ScriptHelper.COLUMN)); - } - - private void assertIsLiveness(SmartFrogException sfe) { - assertSame(sfException, sfe); - } - - - private SmartFrogException assertExtracted(Throwable in) { - SmartFrogException sfe = extractNestedSFE(in); - assertNotNull(sfe); - assertIsLiveness(sfe); - return sfe; - } - - private SmartFrogException extractNestedSFE(Throwable in) { - return helper.extractNestedSFE(in); - } - -} Deleted: trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/javax/components.sf =================================================================== --- trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/javax/components.sf 2009-09-23 09:39:31 UTC (rev 7875) +++ trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/javax/components.sf 2009-09-23 10:23:13 UTC (rev 7876) @@ -1,23 +0,0 @@ -/* (C) Copyright 2009 Hewlett-Packard Development Company, LP - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -For more information: www.smartfrog.org - -*/ -#include "/org/smartfrog/services/assertions/components.sf" -#include "/org/smartfrog/services/scripting/js/components.sf" - - Deleted: trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/JavascriptTest.java =================================================================== --- trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/JavascriptTest.java 2009-09-23 09:39:31 UTC (rev 7875) +++ trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/JavascriptTest.java 2009-09-23 10:23:13 UTC (rev 7876) @@ -1,64 +0,0 @@ -/* (C) Copyright 2008 Hewlett-Packard Development Company, LP - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - For more information: www.smartfrog.org - - */ - - -package org.smartfrog.test.system.services.scripting.js; - -import org.smartfrog.test.DeployingTestBase; - -/** - * - */ -public class JavascriptTest extends DeployingTestBase { - - public static final String PACKAGE = "/org/smartfrog/test/system/services/scripting/js/"; - - public JavascriptTest(String name) { - super(name); - } - - public void testInlineLifecycle() throws Throwable { - expectSuccessfulTestRun(PACKAGE, "testInlineLifecycle"); - } - - public void testInlineLifecycleTerminating() throws Throwable { - expectSuccessfulTestRun(PACKAGE, "testInlineLifecycleTerminating"); - } - - public void testResourceTerminating() throws Throwable { - expectSuccessfulTestRun(PACKAGE, "testResourceTerminating"); - } - - public void testConditionTrue() throws Throwable { - expectSuccessfulTestRun(PACKAGE, "testConditionTrue"); - } - - public void testConditionFalse() throws Throwable { - expectSuccessfulTestRun(PACKAGE, "testConditionFalse"); - } - - public void testFailOnStartup() throws Throwable { - expectSuccessfulTestRun(PACKAGE, "testFailOnStartup"); - } - - public void testConditionScriptError() throws Throwable { - expectSuccessfulTestRun(PACKAGE, "testConditionScriptError"); - } -} Deleted: trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/components.sf =================================================================== --- trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/components.sf 2009-09-23 09:39:31 UTC (rev 7875) +++ trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/components.sf 2009-09-23 10:23:13 UTC (rev 7876) @@ -1,139 +0,0 @@ -/* (C) Copyright 2009 Hewlett-Packard Development Company, LP - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -For more information: www.smartfrog.org - -*/ -#include "/org/smartfrog/services/assertions/components.sf" -#include "/org/smartfrog/services/scripting/js/components.sf" -#include "/org/smartfrog/sfcore/workflow/conditional/components.sf" - -scriptbase "/org/smartfrog/test/system/services/scripting/js/"; -hello "hello.js"; - - -LifecycleInlineWorkflow extends JavaScriptWorkflow { - sfScriptCodeBase scriptbase; - sfDeployCode ## - log.info("deploy"); - #; - - sfStartCode ## - log.info("start"); - #; - - sfPingCode ## - log.info("ping"); - #; - - sfTerminateWithCode - ## - log.info("terminated"); - #; -} - - -LifecycleInline extends LifecycleInlineWorkflow { - sfShouldTerminate false; -} - -HelloOnStartup extends LifecycleInlineWorkflow { - sfStartResource hello; -} - - -FailOnStartup extends LifecycleInlineWorkflow { - - sfStartCode ## - self.fail("wake up, time to die"); - #; -} - -testInlineLifecycle extends ExpectDeploy { - - action extends LifecycleInline; - - tests extends Sequence { - - } -} - - -testFailOnStartup extends ExpectDeployFailure { - exitText "wake up, time to die"; - - action extends FailOnStartup { - } -} - -testInlineLifecycleTerminating extends ExpectTerminate { - - action extends LifecycleInlineWorkflow { - } -} - - -testResourceTerminating extends ExpectTerminate { - - action extends HelloOnStartup { - } -} - -ConditionInline extends JavaScriptCondition { - value true; - sfConditionCode "self.condition = value;"; -} - -testConditionTrue extends ExpectTerminate { - - action extends EvaluateCondition { - condition extends ConditionInline { - - } - } -} - -testConditionScriptError extends ExpectDeployFailure { - - action extends EvaluateCondition { - condition extends JavaScriptCondition { - sfConditionCode "this does not parse properly!"; - } - } -} - -testConditionFalse extends ExpectTerminate { - - action extends EvaluateCondition { - condition extends Not { - condition extends ConditionInline { - value false; - } - } - } -} - -testConditionResourceTrue extends ExpectTerminate { - - action extends EvaluateCondition { - condition extends ConditionInline { - - } - } -} - - - Deleted: trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/condition.js =================================================================== --- trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/condition.js 2009-09-23 09:39:31 UTC (rev 7875) +++ trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/condition.js 2009-09-23 10:23:13 UTC (rev 7876) @@ -1,5 +0,0 @@ -/* - This is a javascript condition - */ -log.info("in the condition"); -self.condition = value; Deleted: trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/hello.js =================================================================== --- trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/hello.js 2009-09-23 09:39:31 UTC (rev 7875) +++ trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/hello.js 2009-09-23 10:23:13 UTC (rev 7876) @@ -1 +0,0 @@ -log.info("hello from JavaScript"); Deleted: trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/testConditionFalse.sf =================================================================== --- trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/testConditionFalse.sf 2009-09-23 09:39:31 UTC (rev 7875) +++ trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/testConditionFalse.sf 2009-09-23 10:23:13 UTC (rev 7876) @@ -1,29 +0,0 @@ -/* (C) Copyright 2009 Hewlett-Packard Development Company, LP - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -For more information: www.smartfrog.org - -*/ -#include "/org/smartfrog/test/system/services/scripting/js/components.sf" - - - - -sfConfig testConditionFalse; - - - - Deleted: trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/testConditionScriptError.sf =================================================================== --- trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/testConditionScriptError.sf 2009-09-23 09:39:31 UTC (rev 7875) +++ trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/testConditionScriptError.sf 2009-09-23 10:23:13 UTC (rev 7876) @@ -1,29 +0,0 @@ -/* (C) Copyright 2009 Hewlett-Packard Development Company, LP - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -For more information: www.smartfrog.org - -*/ -#include "/org/smartfrog/test/system/services/scripting/js/components.sf" - - - - -sfConfig testConditionScriptError; - - - - Deleted: trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/testConditionTrue.sf =================================================================== --- trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/testConditionTrue.sf 2009-09-23 09:39:31 UTC (rev 7875) +++ trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/testConditionTrue.sf 2009-09-23 10:23:13 UTC (rev 7876) @@ -1,29 +0,0 @@ -/* (C) Copyright 2009 Hewlett-Packard Development Company, LP - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Less... [truncated message content] |