Пример #1
0
  /**
   * Loads the declarations of the script engines declared in a property set
   *
   * @param props property set containing the configuration
   * @throws ConfigurationException if the scripting languages cannot be loaded
   */
  private void loadScriptingLanguages(Properties props) throws ConfigurationException {
    String strEngineList = loadProperty(props, SCRIPT_ENGINE_LIST_P);

    for (StringTokenizer engineTokenizer = new StringTokenizer(strEngineList);
        engineTokenizer.hasMoreTokens(); ) {
      String engineBaseItem = engineTokenizer.nextToken();
      String engineName = props.getProperty(engineBaseItem + ".name"); // $NON-NLS-1$
      String engineClass = props.getProperty(engineBaseItem + ".class"); // $NON-NLS-1$
      String engineExtProps = props.getProperty(engineBaseItem + ".extensions"); // $NON-NLS-1$
      String[] extArray = null;
      if (engineExtProps != null) {
        List<String> extList = new ArrayList<String>();
        for (StringTokenizer extTokenizer = new StringTokenizer(engineExtProps);
            extTokenizer.hasMoreTokens(); ) {
          String extension = extTokenizer.nextToken();
          ext = extension;
          extList.add(extension);
        }
        extArray = extList.toArray(new String[0]);
      }
      BSFManager.registerScriptingEngine(engineName, engineClass, extArray);
      System.out.println("Script " + engineName + " loaded"); // $NON-NLS-1$ //$NON-NLS-2$
    }

    defaultEngineName = loadProperty(props, DFLT_SCRIPT_ENGINE_P);
  }
Пример #2
0
  /**
   * Loads the BSF engine.
   *
   * @param engineName name of the engine
   * @see #getEngine()
   */
  private void loadEngine(String engineName) throws ConfigurationException {
    System.out.println("Loading script engine " + engineName);
    try {
      engine = bsfManager.loadScriptingEngine(engineName.trim());
    } catch (BSFException bsfEx) {
      String msg = "Could not find script engine " + engineName; // $NON-NLS-1$
      System.err.println(msg + " " + bsfEx);
      throw new ConfigurationException(msg, bsfEx);
    }

    // import the initial packages
    for (String pkgName : scriptImportPkgList) {
      System.out.println("Loading package " + pkgName);
      importPkgToScriptEngine(pkgName);
    }
    System.out.println("Script engine " + engineName + " loaded");
  }