org/objectweb/proactive/core/config/xml/PropertiesHandler.java

00001 /* 
00002  * ################################################################
00003  * 
00004  * ProActive: The Java(TM) library for Parallel, Distributed, 
00005  *            Concurrent computing with Security and Mobility
00006  * 
00007  * Copyright (C) 1997-2007 INRIA/University of Nice-Sophia Antipolis
00008  * Contact: proactive@objectweb.org
00009  * 
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Lesser General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2.1 of the License, or any later version.
00014  *  
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Lesser General Public License for more details.
00019  * 
00020  * You should have received a copy of the GNU Lesser General Public
00021  * License along with this library; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00023  * USA
00024  *  
00025  *  Initial developer(s):               The ProActive Team
00026  *                        http://www.inria.fr/oasis/ProActive/contacts.html
00027  *  Contributor(s): 
00028  * 
00029  * ################################################################
00030  */ 
00031 package org.objectweb.proactive.core.config.xml;
00032 
00033 import java.util.Properties;
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 
00040 
00045 public class PropertiesHandler extends AbstractUnmarshallerDecorator
00046     implements MasterFileConstants {
00047     //protected static Logger logger = Logger.getLogger(PropertiesHandler.class.getName());
00048     private Properties properties = null;
00049 
00050     public PropertiesHandler(ProActiveConfiguration config) {
00051         super();
00052         properties = new Properties();
00053         addHandler(PROP_TAG, new PropHandler(properties, config));
00054     }
00055 
00056     public Object getResultObject() throws org.xml.sax.SAXException {
00057         return properties;
00058     }
00059 
00060     public void startContextElement(String name, Attributes attributes)
00061         throws org.xml.sax.SAXException {
00062     }
00063 
00064     protected void notifyEndActiveHandler(String name,
00065         UnmarshallerHandler activeHandler) throws org.xml.sax.SAXException {
00066     }
00067 
00068     //-----------------------------------------------------------------------------------------------------------
00069     private static class PropHandler extends AbstractUnmarshallerDecorator {
00070         private Properties properties = null;
00071         private ProActiveConfiguration config;
00072 
00073         PropHandler(Properties properties, ProActiveConfiguration config) {
00074             super();
00075             this.properties = properties;
00076             this.config = config;
00077         }
00078 
00079         public Object getResultObject() throws org.xml.sax.SAXException {
00080             return properties;
00081         }
00082 
00083         public void startContextElement(String name, Attributes attributes)
00084             throws org.xml.sax.SAXException {
00085             //   System.out.println("**** PropHandler");
00086             String key = attributes.getValue("key");
00087             String value = attributes.getValue("value");
00088 
00089             //PropertiesHandler.logger.debug("Key " + key + " value  " + value);
00090             // System.out.println("Key " + key + " value  " + value);
00091             //  if (checkNonEmpty(key) && checkNonEmpty(value)) {
00092             //      properties.put(key, value);
00093             //  }
00094             //System.out.println("config is " + config);
00095             config.propertyFound(key, value);
00096         }
00097 
00098         protected void notifyEndActiveHandler(String name,
00099             UnmarshallerHandler activeHandler) throws org.xml.sax.SAXException {
00100         }
00101     }
00102 }

Generated on Mon Jan 22 15:16:07 2007 for ProActive by  doxygen 1.5.1