From: Kumaravel G. <kum...@us...> - 2005-03-01 11:38:04
|
Update of /cvsroot/smartfrog/core/components/arithmetic-testharness/src/org/smartfrog/services/scripting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20703/org/smartfrog/services/scripting Modified Files: button.sf components.sf Expression.java functions.sf heartbeat.sf RemoteScriptPrim.java scriptPrim.sf Log Message: Changed to make this component run ... Index: functions.sf =================================================================== RCS file: /cvsroot/smartfrog/core/components/arithmetic-testharness/src/org/smartfrog/services/scripting/functions.sf,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** functions.sf 12 May 2004 11:49:35 -0000 1.1 --- functions.sf 1 Mar 2005 11:37:54 -0000 1.2 *************** *** 1,5 **** /** ! * This SmartFrog function allows you to specify an expression ! * under the 'exp' attribute, expression that will be evaluated * at parsing time by a beanshell interpreter. * Variables used in the expression have to be declared (as attributes) --- 1,25 ---- + /** (C) Copyright 1998-2004 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 + + */ + /** ! * This SmartFrog function allows you to specify an expression ! * under the 'exp' attribute, expression that will be evaluated * at parsing time by a beanshell interpreter. * Variables used in the expression have to be declared (as attributes) *************** *** 11,13 **** // myvariable myvalue // exp "function(myvariable)" ... ! } --- 31,33 ---- // myvariable myvalue // exp "function(myvariable)" ... ! } \ No newline at end of file Index: heartbeat.sf =================================================================== RCS file: /cvsroot/smartfrog/core/components/arithmetic-testharness/src/org/smartfrog/services/scripting/heartbeat.sf,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** heartbeat.sf 12 May 2004 11:49:35 -0000 1.1 --- heartbeat.sf 1 Mar 2005 11:37:54 -0000 1.2 *************** *** 1,5 **** /** * This components prints a heartbeat on the stdout, every 1000 ms. ! * The period can be modified . * The thread stops when the component terminates. */ --- 1,25 ---- + /** (C) Copyright 1998-2004 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 + + */ + /** * This components prints a heartbeat on the stdout, every 1000 ms. ! * The period can be modified . * The thread stops when the component terminates. */ *************** *** 12,16 **** sfDeployCode ## // build the thread ! deathClock() { run() { while(global.x){ // refer to global, otherwise x is reset each evaluation. --- 32,36 ---- sfDeployCode ## // build the thread ! deathClock() { run() { while(global.x){ // refer to global, otherwise x is reset each evaluation. *************** *** 32,38 **** deathClock.stop(); #; ! } ! --- 52,58 ---- deathClock.stop(); #; ! } ! Index: Expression.java =================================================================== RCS file: /cvsroot/smartfrog/core/components/arithmetic-testharness/src/org/smartfrog/services/scripting/Expression.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Expression.java 12 May 2004 11:49:35 -0000 1.1 --- Expression.java 1 Mar 2005 11:37:54 -0000 1.2 *************** *** 1,2 **** --- 1,22 ---- + /** (C) Copyright 1998-2004 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; *************** *** 13,17 **** * The result of the evaluation will be used as the function's value. * - * @author Guillaume Mecheneau */ public class Expression extends BaseFunction implements PhaseAction { --- 33,36 ---- Index: RemoteScriptPrim.java =================================================================== RCS file: /cvsroot/smartfrog/core/components/arithmetic-testharness/src/org/smartfrog/services/scripting/RemoteScriptPrim.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RemoteScriptPrim.java 12 May 2004 11:49:35 -0000 1.1 --- RemoteScriptPrim.java 1 Mar 2005 11:37:54 -0000 1.2 *************** *** 1,11 **** package org.smartfrog.services.scripting; import java.rmi.Remote; /** * A remote interface to trigger evaluation of scripts. - * @author Guillaume Mecheneau */ ! public interface RemoteScriptPrim extends Remote { /** * Evaluate the String as a beanshell script --- 1,36 ---- + /** (C) Copyright 1998-2004 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; import java.rmi.Remote; + import java.rmi.RemoteException; + + import org.smartfrog.sfcore.common.SmartFrogException; + /** * A remote interface to trigger evaluation of scripts. */ ! public interface RemoteScriptPrim ! extends Remote { /** * Evaluate the String as a beanshell script *************** *** 13,17 **** * @throw Exception if the execution of the script fails. */ ! public Object eval(String script) throws Exception; /** * Bind an object to a name in the beanshell interpreter. --- 38,43 ---- * @throw Exception if the execution of the script fails. */ ! public Object eval(String script) throws SmartFrogException, RemoteException; ! /** * Bind an object to a name in the beanshell interpreter. *************** *** 19,23 **** * @param obj the object you want to register in the interpreter. */ ! public void setRemote(String name, Object obj) throws Exception; ! } --- 45,50 ---- * @param obj the object you want to register in the interpreter. */ ! public void setRemote(String name, Object obj) throws SmartFrogException, ! RemoteException; ! } \ No newline at end of file Index: button.sf =================================================================== RCS file: /cvsroot/smartfrog/core/components/arithmetic-testharness/src/org/smartfrog/services/scripting/button.sf,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** button.sf 12 May 2004 11:49:35 -0000 1.1 --- button.sf 1 Mar 2005 11:37:54 -0000 1.2 *************** *** 1,46 **** ! #include "org/smartfrog/functions.sf"; /** ! * Creates a button in a frame which executes arbitrary code when clicked, ! * The default behaviour is to terminate the component abnormally. * The button text, the size, and of course the executed code may be changed */ Button extends ScriptPrim { ! buttonName "My Button"; ! width 200; ! height 100; ! code ## prim.sfTerminate(org.smartfrog.sfcore.prim.TerminationRecord.abnormal("Killed by Click",null)); ! // change this code to whatever you want, // (System.out.println("Button Pressed: " + e); for example) ! // this default code terminates the component ! // when the button is pressed... ! // ! // e is the java.awt.Event object ! #; ! attributesAsVariables true; ! actionListenerScript extends concat{ ! beginScript ## ! import java.awt.event.ActionListener; ! actionPerformed( e ) { ! #; ! actionExecuted PARENT:code; ! endScript ## ! } ! return (ActionListener)this; ! #; ! } ! sfDeployCode ## ! JButton button = new JButton(buttonName); ! button.addActionListener((ActionListener) prim.eval(actionListenerScript)); ! JFrame f = new JFrame(prim.sfCompleteName().toString()); ! prim.interpreter.set("f",f); ! f.getContentPane().add( button ); ! f.setSize(width.intValue() , height.intValue()); ! f.show(); ! #; ! sfTerminateWithCode ## ! f.removeAll(); ! f.dispose(); #; ! } --- 1,67 ---- ! /** (C) Copyright 1998-2004 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" ! #include "org/smartfrog/functions.sf" // india team changes /** ! * Creates a button in a frame which executes arbitrary code when clicked, ! * The default behaviour is to terminate the component abnormally. * The button text, the size, and of course the executed code may be changed */ Button extends ScriptPrim { ! buttonName "My Button"; ! width 200; ! height 100; ! code ## prim.sfTerminate(com.hp.SmartFrog.Prim.TerminationRecord.abnormal("Killed by Click",null)); ! // change this code to whatever you want, // (System.out.println("Button Pressed: " + e); for example) ! // this default code terminates the component ! // when the button is pressed... ! // ! // e is the java.awt.Event object ! #; ! attributesAsVariables true; ! actionListenerScript extends concat{ ! beginScript ## ! import java.awt.event.ActionListener; ! actionPerformed( e ) { ! #; ! actionExecuted PARENT:code; ! endScript ## ! } ! return (ActionListener)this; ! #; ! } ! sfDeployCode ## ! JButton button = new JButton(buttonName); ! button.addActionListener((ActionListener) prim.eval(actionListenerScript)); ! JFrame f = new JFrame(prim.sfCompleteName().toString()); ! prim.interpreter.set("f",f); ! f.getContentPane().add( button ); ! f.setSize(width.intValue() , height.intValue()); ! f.show(); #; ! sfTerminateWithCode ## ! f.removeAll(); ! f.dispose(); ! #; ! } Index: scriptPrim.sf =================================================================== RCS file: /cvsroot/smartfrog/core/components/arithmetic-testharness/src/org/smartfrog/services/scripting/scriptPrim.sf,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** scriptPrim.sf 12 May 2004 11:49:35 -0000 1.1 --- scriptPrim.sf 1 Mar 2005 11:37:54 -0000 1.2 *************** *** 1,21 **** #include "org/smartfrog/components.sf" /** ! * A simple scripting component. It allows you to write lines ! * of Java code in your descriptions, respectively named ! * sfDeployCode, sfStartCode and sfTerminateWithCode. ! * These lines of codes are executed at runtime during * the corresponding lifecycle phases. * n.b.: 1 - to reference the component itself in these lines of Java code * you have to use the name 'prim'. * 2 - For multiline string use ## your string here #; ! * For examples see org/smartfrog/sfServices/scripting/examples.sf */ ScriptPrim extends Prim { ! sfClass "org.smartfrog.services.scripting.ScriptPrimImpl"; // port 1234; // create a http daemon on this port ! attributesAsVariables false; // set to true if you want all attributes of ! // the component to be registered in the bsh interpreter // sfScriptCodeBase "http://..." // prefix for location of scripts // sfDeployCode ""; // code executed during sfDeploy --- 1,42 ---- + /** (C) Copyright 1998-2004 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" /** ! * A simple scripting component. It allows you to write lines ! * of Java code in your descriptions, respectively named ! * sfDeployCode, sfStartCode and sfTerminateWithCode. ! * These lines of codes are executed at runtime during * the corresponding lifecycle phases. * n.b.: 1 - to reference the component itself in these lines of Java code * you have to use the name 'prim'. * 2 - For multiline string use ## your string here #; ! * For examples see com/hp/sfServices/scripting/examples.sf */ ScriptPrim extends Prim { ! sfProcessName "BeanShell"; // BeanShell implements its own class loader. ! sfClass "org.smartfrog.services.scripting.ScriptImpl"; // port 1234; // create a http daemon on this port ! attributesAsVariables false; // set to true if you want all attributes of ! // the component to be registered in the bsh interpreter // sfScriptCodeBase "http://..." // prefix for location of scripts // sfDeployCode ""; // code executed during sfDeploy *************** *** 23,26 **** // sfTerminateWithCode ""; // code executed during sfTerminateWith } ! --- 44,47 ---- // sfTerminateWithCode ""; // code executed during sfTerminateWith } ! Index: components.sf =================================================================== RCS file: /cvsroot/smartfrog/core/components/arithmetic-testharness/src/org/smartfrog/services/scripting/components.sf,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** components.sf 12 May 2004 11:49:35 -0000 1.1 --- components.sf 1 Mar 2005 11:37:54 -0000 1.2 *************** *** 1,3 **** ! #include "com/hp/sfServices/scripting/scriptPrim.sf" ! #include "com/hp/sfServices/scripting/heartbeat.sf" ! #include "com/hp/sfServices/scripting/button.sf" \ No newline at end of file --- 1,24 ---- ! /** (C) Copyright 1998-2004 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/scriptPrim.sf" ! #include "org/smartfrog/services/scripting/functions.sf" ! #include "org/smartfrog/services/scripting/heartbeat.sf" ! #include "org/smartfrog/services/scripting/button.sf" \ No newline at end of file |