Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use now the SimGrid parser instead of Xerces.
authorcherierm <cherierm@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 11 Jul 2008 15:16:45 +0000 (15:16 +0000)
committercherierm <cherierm@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 11 Jul 2008 15:16:45 +0000 (15:16 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@5867 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/java/simgrid/msg/ApplicationHandler.java
src/java/simgrid/msg/Msg.java

index fd59889..37c6e66 100644 (file)
@@ -13,8 +13,6 @@ package simgrid.msg;
 
 import java.util.Vector;
 import java.util.Hashtable;
 
 import java.util.Vector;
 import java.util.Hashtable;
-import org.xml.sax.*;
-import org.xml.sax.helpers.*;
 
 /**
  * The handler used to parse the deployment file which contains 
 
 /**
  * The handler used to parse the deployment file which contains 
@@ -29,12 +27,12 @@ import org.xml.sax.helpers.*;
  * @since SimGrid 3.3
  * @since JDK1.5011 
  */
  * @since SimGrid 3.3
  * @since JDK1.5011 
  */
-public final class ApplicationHandler extends DefaultHandler {
+public final class ApplicationHandler{
 
   /* 
    * This class is used to create the processes descibed in the deployment file.
    */
 
   /* 
    * This class is used to create the processes descibed in the deployment file.
    */
-  class ProcessFactory {
+  static class ProcessFactory {
                 /**
                 * The vector which contains the arguments of the main function 
                 * of the process object.
                 /**
                 * The vector which contains the arguments of the main function 
                 * of the process object.
@@ -77,11 +75,11 @@ public final class ApplicationHandler extends DefaultHandler {
       this.hostName = hostName;
       this.function = function;
 
       this.hostName = hostName;
       this.function = function;
 
-      if (!this.args.isEmpty())
-        this.args.clear();
+      if (!args.isEmpty())
+        args.clear();
         
         
-      if(!this.properties.isEmpty())
-       this.properties.clear();
+      if(!properties.isEmpty())
+       properties.clear();
     }
                 /**
                 * This method is called by the startElement() handler.
     }
                 /**
                 * This method is called by the startElement() handler.
@@ -91,17 +89,17 @@ public final class ApplicationHandler extends DefaultHandler {
                 * @arg                                 The argument to add.
                 *
                 */ public void registerProcessArg(String arg) {
                 * @arg                                 The argument to add.
                 *
                 */ public void registerProcessArg(String arg) {
-      this.args.add(arg);
+      args.add(arg);
     }
     
     public void setProperty(String id, String value)
     {
     }
     
     public void setProperty(String id, String value)
     {
-       this.properties.put(id,value);  
+       properties.put(id,value);       
     }
     
     public String getHostName()
     {
     }
     
     public String getHostName()
     {
-       return this.hostName;
+       return hostName;
     }
 
     public void createProcess() {
     }
 
     public void createProcess() {
@@ -158,7 +156,7 @@ public final class ApplicationHandler extends DefaultHandler {
   /* 
    * the ProcessFactory object used to create the processes.
    */
   /* 
    * the ProcessFactory object used to create the processes.
    */
-  private ProcessFactory processFactory;
+  public static ProcessFactory processFactory;
 
   public ApplicationHandler() {
     super();
 
   public ApplicationHandler() {
     super();
@@ -166,53 +164,27 @@ public final class ApplicationHandler extends DefaultHandler {
     /**
      * instanciates the process factory 
      */
     /**
      * instanciates the process factory 
      */
-  public void startDocument() {
-    this.processFactory = new ProcessFactory();
-  }
-
-  public void characters(char[]caracteres, int debut, int longueur) {
-  }                             // NOTHING TODO
-
-   /**
-    * element handlers
-    */
-  public void startElement(String nameSpace, String localName, String qName,
-                           Attributes attr) {
-    if (localName.equals("process"))
-      onProcessIdentity(attr);
-    else if(localName.equals("prop"))
-      onProperty(attr);
-    else if (localName.equals("argument"))
-      onProcessArg(attr);
-  }
-
-     /**
-     * process attributs handler.
-     */
-  public void onProcessIdentity(Attributes attr) {
-    processFactory.setProcessIdentity(attr.getValue(0), attr.getValue(1));
+  public static void onStartDocument() {
+    processFactory = new ProcessFactory();
   }
   
   }
   
-  public void onProperty(Attributes attr) {
-    processFactory.setProperty(attr.getValue(0), attr.getValue(1));
+   public static void onBeginProcess(String hostName, String function)
+   {
+        processFactory.setProcessIdentity(hostName, function);
+}
+       public static void onProperty(String id, String value) {
+    processFactory.setProperty(id, value);
   }
   }
-
-        /**
-     * process arguments handler.
-     */
-  public void onProcessArg(Attributes attr) {
-    processFactory.registerProcessArg(attr.getValue(0));
+  
+   public static void onProcessArg(String arg) {
+    processFactory.registerProcessArg(arg);
   }
   }
-
-    /**
-     * creates the process
-     */
-  public void endElement(String nameSpace, String localName, String qName) {
-    if (localName.equals("process")) {
+  
+  public static void onEndProcess() {
+    
       processFactory.createProcess();
       processFactory.createProcess();
-    }
-  }
+  }        
 
 
-  public void endDocument() {
-  }                             // NOTHING TODO
+  public static void onEndDocument() {
+  }  // NOTHING TODO
 }
 }
index 81fd4f4..0c10771 100644 (file)
@@ -113,36 +113,15 @@ public final class Msg {
      */
   public final static native void createEnvironment(String platformFile)
   throws NativeException;
      */
   public final static native void createEnvironment(String platformFile)
   throws NativeException;
-
-
-    /**
+  
+   /**
      * The method to deploy the simulation.
      *
      * @param platformFile    The XML file which contains the description of the application to deploy.
      */
      * The method to deploy the simulation.
      *
      * @param platformFile    The XML file which contains the description of the application to deploy.
      */
-
-
-  public static void deployApplication(String platformFile) {
-    try {
-      Class c =
-        Class.forName("com.sun.org.apache.xerces.internal.parsers.SAXParser");
-      XMLReader reader = (XMLReader) c.newInstance();
-
-      reader.setEntityResolver(new DTDResolver());
-      ApplicationHandler handler = new ApplicationHandler();
-
-      reader.setContentHandler(handler);
-      reader.setFeature("http://xml.org/sax/features/validation", false);
-      reader.parse(platformFile);
-
-    } catch(Exception e) {
-      /* FIXME: do not swallow exception ! */
-      System.out.println("Exception in Msg.launchApplication()");
-      System.out.println(e);
-      e.printStackTrace();
-    }
-  }
-
+  public final static native void deployApplication(String deploymentFile)
+  throws NativeException;
   /* The launcher */
   static public void main(String[]args) throws MsgException {
     /* initialize the MSG simulation. Must be done before anything else (even logging). */
   /* The launcher */
   static public void main(String[]args) throws MsgException {
     /* initialize the MSG simulation. Must be done before anything else (even logging). */