X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=source%2Fmir%2Fxml%2FXmlConfigurator.java;h=101d65943562fca5c2b8fdce77d729d6b2582a85;hb=baf56cc3d324ffa8715509e559bbe049739f32f3;hp=a67a7c4ad043a6925ed90ac68e23dc19bd81c6e2;hpb=ed555a087df9a68d3b3160ac8b036c0ae3e64b10;p=mir.git diff --git a/source/mir/xml/XmlConfigurator.java b/source/mir/xml/XmlConfigurator.java index a67a7c4a..101d6594 100755 --- a/source/mir/xml/XmlConfigurator.java +++ b/source/mir/xml/XmlConfigurator.java @@ -2,6 +2,7 @@ package mir.xml; import java.io.*; import java.util.*; +import java.lang.reflect.*; import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.*; import javax.xml.parsers.ParserConfigurationException; @@ -22,6 +23,9 @@ import mir.misc.Location; * classes as well as the inclusion of a method to * add parameters (nested tags) that are required. * (the addRequired method) in the config file. + * that part is from tomcat. + * + * much code is stolen from ant ProjectHelper.java. * * @author -mh * @version 2001.10.21 @@ -37,21 +41,46 @@ public class XmlConfigurator { private File configFileParent; private Locator locator; - //private SaxContext saxContext; + private SaxContext saxContext; + + XmlMatch requiredXmlMatch[]=new XmlMatch[256]; //maximum amount of rules + int requiredXmlMatchCount=0; + boolean matched[] = new boolean[256]; + int matchedCount=0; + + XmlMatch mustComeFirstMatch[]=new XmlMatch[256]; //maximum amount of rules + int comeFirstMatchCount=0; + + Property comesFirstArr[]=new Property[128]; + int comesFirstCount=0; + + Property propertyArr[]=new Property[128]; + int propertyCount=0; + + private static XmlConfigurator instance = new XmlConfigurator(); + public static XmlConfigurator getInstance() { return instance; } /** * Configures the Project with the contents of the specified XML file. */ - public static void configure(File configFile) throws ConfigException { - new XmlConfigurator(configFile).parse(); + public void configure(File configFile) throws ConfigException { + setConfigFile(configFile); + parse(); } /** + * konstruktor. private so no one calls "new" on us. + */ + private XmlConfigurator() {} + + + /** * Constructs a new Ant parser for the specified XML file. */ - private XmlConfigurator(File configFile) { + private void setConfigFile(File configFile) { this.configFile = new File(configFile.getAbsolutePath()); configFileParent = new File(this.configFile.getParent()); + saxContext = new SaxContext(); } /** @@ -74,7 +103,24 @@ public class XmlConfigurator { inputSource = new InputSource(inputStream); inputSource.setSystemId(uri); saxParser.parse(inputSource, new RootHandler()); - } + if(matchedCount < requiredXmlMatchCount) { + for( int i=0; i 1 ) ex1.printStackTrace(); + } catch (IllegalAccessException iae) { + throw new Exception("IllegalAccessException for " + classN.getName() + " " + name + "=" + value +")" ); + //if( ctx.getDebug() > 1 ) iae.printStackTrace(); + } catch (InvocationTargetException ie) { + throw new Exception("InvocationTargetException for " + classN.getName() + " " + name + "=" + value +")" ); + //if( ctx.getDebug() > 1 ) ie.printStackTrace(); + } + } + } + }