= ![応用機能]インタープリタ アプリケーション開発において、動的に場合があります。 ソースコードを渡してインタープリタ実行する機能を抽象化したのが、[wiki:#header_Interpreter Interpreter]です。 関連するパッケージは、以下です。 * [http://nimbus.sourceforge.jp/reports/apidocs/jp/ossc/nimbus/service/interpreter/package-summary.html jp.ossc.nimbus.service.interpreter] == アプリケーション向けインタフェース Interpreter #header_Interpreter アプリケーション向けインタフェース[http://nimbus.sourceforge.jp/reports/apidocs/jp/ossc/nimbus/service/interpreter/Interpreter.html Interpreter]を使った簡単なアプリケーションのサンプルを示します。 {{{ code java import java.util.Map; import jp.ossc.nimbus.core.ServiceManagerFactory; import jp.ossc.nimbus.service.interpreter.Interpreter; // Interpreterを取得 Interpreter interpreter = (Interpreter)ServiceManagerFactory.getServiceObject("Interpreter"); // ソースコードをインタープリタ実行する Map map = (Map)interpreter.evaluate( "import java.util.*;" + "Map map = new HashMap();" + "map.put("hoge", new Integer(100));" + "map.put("fuga", new Integer(200));" + "return map;" ); }}} 実装サービスの一覧は以下のとおりです。 ||実装サービス||実装概要|| ||[wiki:Function/service/interpreter/BeanShellInterpreterService jp.ossc.nimbus.service.interpreter.BeanShellInterpreterService]||Java言語のインタープリタエンジンを使うインタープリタ|| ||[wiki:Function/service/interpreter/ScriptEngineInterpreterService jp.ossc.nimbus.service.interpreter.ScriptEngineInterpreterService]||javax.script.ScriptEngineを使うインタープリタ|| サンプルは、以下。 * [cvs://nimbus/sample/example/interpreter/ex1 サンプル1:Javaをインタープリット実行してみよう。] * [cvs://nimbus/sample/example/interpreter/ex2 サンプル2:コマンドベースで、Javaをインタープリット実行してみよう。] * [cvs://nimbus/sample/example/interpreter/ex3 サンプル3:コマンドベースで、別VM上でJavaをインタープリット実行してみよう。]