<?xml version="1.0" encoding="ISO-8859-1"?>

<languages>

  <language name="java" source-extension="java" object-extension="class">

    <version name="0.92" stylesheet="java-0.92.xsl"/>

    <init-script><![CDATA[
      var separator = java.io.File.separator;
      var pathSeparator = java.io.File.pathSeparator;
      var classPath = java.lang.System.getProperty("java.class.path");

      var errorStream = java.lang.System.err;
      var Compiler = Packages.sun.tools.javac.Main;

      function init(path) { }
    ]]></init-script>

    <compile-script><![CDATA[
      function compileProgram(baseName, path)
      {
	var cnt = 0;
        var args = new Array();
        var compiler = new Compiler(errorStream, "javac");
        
        args[cnt++] = "-classpath";
        args[cnt++] = classPath + pathSeparator + path;
        
        args[cnt++] = "-d";
        args[cnt++] = path;
        
        args[cnt++] = "-deprecation";
      
        args[cnt++] = "-verbose";
      
        args[cnt++] = path + separator + baseName + ".java";
      
        compiler.compile(args);
      }
    ]]></compile-script>

    <load-script><![CDATA[
      function loadProgram(baseName, path)
      {
        var array = baseName.split(separator);
  
        var className = "";
        for (var i = 0; i < array.length; i++)
        {
          if (i > 0)
          {
            className += ".";
          }

          className += array[i];
        }

        var servletClass = java.lang.Class.forName(className);
        return servletClass.newInstance();
      }
    ]]></load-script>

    <unload-script><![CDATA[
      function unloadProgram(servlet)
      {
        servlet.destroy();
      }
    ]]></unload-script>

    <execute-script><![CDATA[
      function executeProgram(servlet, servletArgument)
      {
        servlet.service(servletArgument.request, servletArgument.response);
      }
    ]]></execute-script>
  </language>

</languages>
