2 * simgrid.msg.ApplicationHandler.java 1.00 07/05/01
4 * Copyright 2006,2007 Martin Quinson, Malek Cherier
7 * This program is free software; you can redistribute
8 * it and/or modify it under the terms of the license
9 *(GNU LGPL) which comes with this package.
15 import org.xml.sax.helpers.*;
16 import java.lang.reflect.*;
19 * The handler used to parse the deployment file which contains
20 * the description of the application (simulation).
22 * @author Abdelmalek Cherier
23 * @author Martin Quinson
24 * @version 1.00, 07/05/01
31 public final class ApplicationHandler extends DefaultHandler
33 /* the current process. */
34 public simgrid.msg.Process process;
36 public ApplicationHandler() {
40 public void startDocument() {} // NOTHING TODO
41 public void endDocument() {} // NOTHING TODO
43 public void characters(char[] chars, int beg, int lgr) {} // NOTHING TODO
48 public void startElement(String nameSpace, String localName,String qName,Attributes attr) {
49 if(localName.equals("process"))
51 else if(localName.equals("argument"))
54 public void endElement(String nameSpace, String localName,String qName) {
55 if(localName.equals("process"))
60 * process element handler.
62 public void onStartProcess(Attributes attr) {
63 String hostName = attr.getValue(0);
64 String className = attr.getValue(1);
68 Class cls = Class.forName(className);
70 process = (simgrid.msg.Process)cls.newInstance();
71 process.name = className;
72 process.id = simgrid.msg.Process.nextProcessId++;
74 Host host = Host.getByName(hostName);
76 Msg.processCreate(process,host);
78 } catch(Exception e) {
83 public void onEndProcess() {} // NOTHING TODO
86 * function arguments handler.
88 public void onArgument(Attributes attr) {
89 //Msg.info("Add "+attr.getValue(0)+" as argument to "+process.msgName());
90 process.addArg(attr.getValue(0));
94 * end of element handler.