KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > proactive > core > config > xml > MasterFileHandler


1 /*
2  * ################################################################
3  *
4  * ProActive: The Java(TM) library for Parallel, Distributed,
5  * Concurrent computing with Security and Mobility
6  *
7  * Copyright (C) 1997-2002 INRIA/University of Nice-Sophia Antipolis
8  * Contact: proactive-support@inria.fr
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23  * USA
24  *
25  * Initial developer(s): The ProActive Team
26  * http://www.inria.fr/oasis/ProActive/contacts.html
27  * Contributor(s):
28  *
29  * ################################################################
30  */

31 package org.objectweb.proactive.core.config.xml;
32
33 import java.io.IOException JavaDoc;
34
35 import org.objectweb.proactive.core.config.ProActiveConfiguration;
36 import org.objectweb.proactive.core.xml.handler.AbstractUnmarshallerDecorator;
37 import org.objectweb.proactive.core.xml.handler.UnmarshallerHandler;
38 import org.objectweb.proactive.core.xml.io.Attributes;
39 import org.xml.sax.SAXException JavaDoc;
40
41 public class MasterFileHandler extends AbstractUnmarshallerDecorator
42     implements MasterFileConstants {
43
44 // static {
45
// BasicConfigurator.configure();
46
// }
47

48     protected static ProActiveConfiguration config;
49
50     public MasterFileHandler() {
51         addHandler(PROPERTIES_TAG, new PropertiesHandler(MasterFileHandler.config));
52         //addHandler(LOG4J_FILE_TAG, new Log4jConfigurationHandler());
53
}
54
55     /**
56      * Create a SAX parser on the specified file
57      * @param filename the full path to the file
58      */

59     public static void createMasterFileHandler(String JavaDoc filename,
60         ProActiveConfiguration config) {
61             MasterFileHandler.config = config;
62         InitialHandler h = new InitialHandler();
63         org.objectweb.proactive.core.xml.io.StreamReader sr;
64         try {
65             sr = new org.objectweb.proactive.core.xml.io.StreamReader(new org.xml.sax.InputSource JavaDoc(
66                         filename), h);
67             sr.read();
68         } catch (IOException JavaDoc e) {
69             e.printStackTrace();
70         }
71     }
72
73     protected void notifyEndActiveHandler(String JavaDoc name,
74         UnmarshallerHandler activeHandler) throws SAXException JavaDoc {
75      // System.out.println("End active handler");
76
}
77
78     public Object JavaDoc getResultObject() throws SAXException JavaDoc {
79       // System.out.println("get result object");
80
return null;
81     }
82
83     public void startContextElement(String JavaDoc name, Attributes attributes)
84         throws SAXException JavaDoc {
85     }
86
87     //
88
// -- INNER CLASSES ------------------------------------------------------
89
//
90
private static class InitialHandler extends AbstractUnmarshallerDecorator {
91         private MasterFileHandler masterFileHandler;
92
93         // private InitialHandler(AbstractManager manager) {
94
private InitialHandler() {
95             super();
96             masterFileHandler = new MasterFileHandler();
97             // managerDescriptorHandler = new ManagerDescriptorHandler(manager);
98
this.addHandler(MASTER_TAG, masterFileHandler);
99         }
100
101         public Object JavaDoc getResultObject() throws org.xml.sax.SAXException JavaDoc {
102             // return managerDescriptorHandler;
103
return null; //masterFileHandler;
104
}
105
106         public void startContextElement(String JavaDoc name, Attributes attributes)
107             throws org.xml.sax.SAXException JavaDoc {
108         }
109
110         protected void notifyEndActiveHandler(String JavaDoc name,
111             UnmarshallerHandler activeHandler) throws org.xml.sax.SAXException JavaDoc {
112         }
113     }
114
115     // private class SingleValueUnmarshaller extends AbstractUnmarshallerDecorator {
116
// public void readValue(String value) throws org.xml.sax.SAXException {
117
// // setResultObject(value);
118
// }
119
//
120
// public void startContextElement(String name, Attributes attributes)
121
// throws org.xml.sax.SAXException {
122
// // String key = attributes.getValue("key");
123
// String value = attributes.getValue("value");
124
// System.out.println("name = " + name + " value = " + value);
125
// // if (checkNonEmpty(key) && checkNonEmpty(value)) {
126
// // properties.put(key, value);
127
// // }
128
// }
129
//
130
// /* (non-Javadoc)
131
// * @see org.objectweb.proactive.core.xml.handler.AbstractUnmarshallerDecorator#notifyEndActiveHandler(java.lang.String, org.objectweb.proactive.core.xml.handler.UnmarshallerHandler)
132
// */
133
// protected void notifyEndActiveHandler(String name,
134
// UnmarshallerHandler activeHandler) throws SAXException {
135
// // TO DO : Auto-generated method stub
136
// }
137
//
138
// /* (non-Javadoc)
139
// * @see org.objectweb.proactive.core.xml.handler.UnmarshallerHandler#getResultObject()
140
// */
141
// public Object getResultObject() throws SAXException {
142
// // TO DO : Auto-generated method stub
143
// return null;
144
// }
145
// }
146
}
147
Popular Tags