KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > magnet > domain > BeanShellHandler


1 package org.sapia.magnet.domain;
2
3 // Import of Sun's JDK classes
4
// ---------------------------
5
import java.io.InputStreamReader JavaDoc;
6
7
8 // Import of Bean Shell classes
9
// ----------------------------
10
import bsh.Interpreter;
11 import bsh.EvalError;
12
13 // Import of Sapia's utility classes
14
// ---------------------------------
15
import org.sapia.magnet.MagnetException;
16
17
18 /**
19  *
20  *
21  * @author Jean-Cedric Desrochers
22  *
23  * <dl>
24  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2003 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
25  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
26  * <a HREF="http://www.sapia-oss.org/license.html" target="sapia-license">license page</a> at the Sapia OSS web site</dd></dt>
27  * </dl>
28  */

29 public class BeanShellHandler implements ScriptHandlerIF {
30
31   /**
32    *
33    */

34   public void execute(String JavaDoc aCode) throws MagnetException {
35     try {
36       Interpreter anInterpreter = new Interpreter(new InputStreamReader JavaDoc(System.in), System.out, System.err, false);
37       anInterpreter.eval(aCode);
38     } catch (EvalError ee) {
39       throw new MagnetException("Error executing the bsh script", ee);
40     }
41   }
42 }
43
Popular Tags