00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030  
00031 package org.objectweb.proactive.core.config.xml;
00032 
00033 import java.io.IOException;
00034 
00035 import org.objectweb.proactive.core.config.ProActiveConfiguration;
00036 import org.objectweb.proactive.core.xml.handler.AbstractUnmarshallerDecorator;
00037 import org.objectweb.proactive.core.xml.handler.UnmarshallerHandler;
00038 import org.objectweb.proactive.core.xml.io.Attributes;
00039 import org.xml.sax.InputSource;
00040 import org.xml.sax.SAXException;
00041 
00042 
00043 public class MasterFileHandler extends AbstractUnmarshallerDecorator
00044     implements MasterFileConstants {
00045     
00046     
00047     
00048     protected static ProActiveConfiguration config;
00049 
00050     public MasterFileHandler() {
00051         addHandler(PROPERTIES_TAG,
00052             new PropertiesHandler(MasterFileHandler.config));
00053 
00054         
00055     }
00056 
00061     public static void createMasterFileHandler(String filename,
00062         ProActiveConfiguration config) {
00063         MasterFileHandler.config = config;
00064 
00065         InitialHandler h = new InitialHandler();
00066         org.objectweb.proactive.core.xml.io.StreamReader sr;
00067 
00068         try {
00069             InputSource source = null;
00070 
00071             
00072             if (filename.startsWith("bundle://")) {
00073 
00074                 
00075                 filename = "/ProActiveConfiguration.xml";
00076                 
00077                 source = new InputSource(MasterFileHandler.class.getResourceAsStream(
00078                             filename));
00079             } else {
00080                 source = new org.xml.sax.InputSource(filename);
00081             }
00082             sr = new org.objectweb.proactive.core.xml.io.StreamReader(source, h);
00083             sr.read();
00084         } catch (IOException e) {
00085             e.printStackTrace();
00086         } catch (SAXException e) {
00087             e.printStackTrace();
00088         }
00089     }
00090 
00091     protected void notifyEndActiveHandler(String name,
00092         UnmarshallerHandler activeHandler) throws SAXException {
00093         
00094     }
00095 
00096     public Object getResultObject() throws SAXException {
00097         
00098         return null;
00099     }
00100 
00101     public void startContextElement(String name, Attributes attributes)
00102         throws SAXException {
00103     }
00104 
00105     
00106     
00107     
00108     private static class InitialHandler extends AbstractUnmarshallerDecorator {
00109         private MasterFileHandler masterFileHandler;
00110 
00111         
00112         private InitialHandler() {
00113             super();
00114             masterFileHandler = new MasterFileHandler();
00115 
00116             
00117             this.addHandler(MASTER_TAG, masterFileHandler);
00118         }
00119 
00120         public Object getResultObject() throws org.xml.sax.SAXException {
00121             
00122             return null; 
00123         }
00124 
00125         public void startContextElement(String name, Attributes attributes)
00126             throws org.xml.sax.SAXException {
00127         }
00128 
00129         protected void notifyEndActiveHandler(String name,
00130             UnmarshallerHandler activeHandler) throws org.xml.sax.SAXException {
00131         }
00132     }
00133 
00134     
00135     
00136     
00137     
00138     
00139     
00140     
00141     
00142     
00143     
00144     
00145     
00146     
00147     
00148     
00149     
00150     
00151     
00152     
00153     
00154     
00155     
00156     
00157     
00158     
00159     
00160     
00161     
00162     
00163     
00164     
00165 }