You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ek...@apache.org on 2005/09/15 17:42:39 UTC

svn commit: r289264 - in /beehive/trunk/netui: src/pageflow/org/apache/beehive/netui/pageflow/ src/pageflow/org/apache/beehive/netui/pageflow/handler/ src/tags-html/org/apache/beehive/netui/tags/divpanel/ src/util/ src/util/org/apache/beehive/netui/uti...

Author: ekoneil
Date: Thu Sep 15 08:42:24 2005
New Revision: 289264

URL: http://svn.apache.org/viewcvs?rev=289264&view=rev
Log:
Reimplement the parsing of beehive-netui-config.xml to use XML processing infrastructure in the JDK rather than XMLBeans.

This adds a NetUIConfigParser and removes the XmlBeanConfigFactory / ConfigFactory.  The former just validates (if possible) and walks the DOM to build up a NetUIConfig JavaBean.  The PageFlowContextListener changed (simplified!) in that it now uses a simple XmlInputStreamResolver to pull the beehive-netui-config.xml file from the ServletContext.  

Also add / rework a pile of JUnit tests for parsing and detecting validation failures.

BB: self
Test: NetUI BVT pass


Added:
    beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/parser/
    beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/parser/NetUIConfigParser.java   (with props)
    beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/schema/
    beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/schema/beehive-netui-config.xsd
      - copied unchanged from r289153, beehive/trunk/netui/src/util/schema/netui-config/beehive-netui-config.xsd
    beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/ParserTest.java   (with props)
    beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/SchemaValidationTest.java   (with props)
    beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/TestXmlInputStreamResolver.java   (with props)
    beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/instances/beehive-netui-config-default.xml   (with props)
    beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/instances/beehive-netui-config-pageflowConfig.xml   (with props)
    beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/instances/invalid-beehive-netui-config-default.xml   (with props)
Removed:
    beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/ConfigFactory.java
    beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/internal/
    beehive/trunk/netui/src/util/schema/
Modified:
    beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowContextListener.java
    beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/Handlers.java
    beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/divpanel/DivPanel.java
    beehive/trunk/netui/src/util/build.xml
    beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/ConfigUtil.java
    beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/ConfigBeanTest.java
    beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/TestConfigUtil.java

Modified: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowContextListener.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowContextListener.java?rev=289264&r1=289263&r2=289264&view=diff
==============================================================================
--- beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowContextListener.java (original)
+++ beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowContextListener.java Thu Sep 15 08:42:24 2005
@@ -30,6 +30,7 @@
 import org.apache.beehive.netui.util.config.bean.UrlConfig;
 import org.apache.beehive.netui.util.internal.DiscoveryUtils;
 import org.apache.beehive.netui.util.logging.Logger;
+import org.apache.beehive.netui.util.xml.XmlInputStreamResolver;
 
 import javax.servlet.ServletContext;
 import javax.servlet.ServletContextEvent;
@@ -97,26 +98,7 @@
         {
             try
             {
-                InputStream configInput = servletContext.getResourceAsStream( InternalConstants.NETUI_CONFIG_PATH );
-                
-                try
-                {
-                    ConfigUtil.init( configInput );
-                }
-                finally
-                {
-                    try
-                    {
-                        if ( configInput != null ) configInput.close();
-                    }
-                    catch ( IOException e )
-                    {
-                        if ( _log.isErrorEnabled() )
-                        {
-                            _log.error( "Could not close input for " + InternalConstants.NETUI_CONFIG_PATH );
-                        }
-                    }
-                }
+                ConfigUtil.init( new NetUIConfigResolver(servletContext) );
             }
             catch ( ConfigInitializationException e )
             {
@@ -266,5 +248,23 @@
         }
 
         return formatter;
+    }
+
+    private static class NetUIConfigResolver
+        extends XmlInputStreamResolver {
+
+        private ServletContext _servletContext = null;
+
+        private NetUIConfigResolver(ServletContext servletContext) {
+            _servletContext = servletContext;
+        }
+
+        public String getResourcePath() {
+            return InternalConstants.NETUI_CONFIG_PATH;
+        }
+
+        public InputStream getInputStream() {
+            return _servletContext.getResourceAsStream(getResourcePath());
+        }
     }
 }

Modified: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/Handlers.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/Handlers.java?rev=289264&r1=289263&r2=289264&view=diff
==============================================================================
--- beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/Handlers.java (original)
+++ beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/Handlers.java Thu Sep 15 08:42:24 2005
@@ -190,12 +190,13 @@
                 {
                     HandlerConfig config = new HandlerConfig( handlerClass );
 
-                    for ( int j = 0; j < props.length; j++ )
-                    {
-                        CustomPropertyConfig prop = props[j];
-                        config.addCustomProperty( prop.getName(), prop.getValue() );
+                    if(props != null) {
+                        for ( int j = 0; j < props.length; j++ )
+                        {
+                            CustomPropertyConfig prop = props[j];
+                            config.addCustomProperty( prop.getName(), prop.getValue() );
+                        }
                     }
-                    
                     handler.init( config, retVal, servletContext );
                     retVal = handler;
                 }

Modified: beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/divpanel/DivPanel.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/divpanel/DivPanel.java?rev=289264&r1=289263&r2=289264&view=diff
==============================================================================
--- beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/divpanel/DivPanel.java (original)
+++ beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/divpanel/DivPanel.java Thu Sep 15 08:42:24 2005
@@ -114,7 +114,6 @@
     public void setFirstPage(String firstPage)
     {
         _firstPage = firstPage;
-
     }
 
     /**

Modified: beehive/trunk/netui/src/util/build.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/util/build.xml?rev=289264&r1=289263&r2=289264&view=diff
==============================================================================
--- beehive/trunk/netui/src/util/build.xml (original)
+++ beehive/trunk/netui/src/util/build.xml Thu Sep 15 08:42:24 2005
@@ -23,13 +23,6 @@
         <echo>module classpath: ${classpath}</echo>
         <mkdir dir="${classes.dir}/${module.name}"/>
 
-        <ant antfile="${netui.ant.dir}/xmlBean.xml">
-            <property name="xsd.root.dir" value="${module.dir}/schema/"/>
-            <property name="class.output.dir" value="${classes.dir}/${module.name}"/>
-            <property name="xbean.inputs" value="${module.dir}/schema/**/*.xsd*"/>
-            <property name="xbean.output" value="${build.lib.dir}/${util.jar.name}"/>
-        </ant>
-
         <javac srcdir="${module.dir}"
                destdir="${classes.dir}/${module.name}"
                classpathref="module.classpath"
@@ -43,6 +36,7 @@
 
         <copy todir="${classes.dir}/${module.name}">
             <fileset dir="${module.dir}" includes="**/*.properties"/>
+            <fileset dir="${module.dir}" includes="**/*.xsd"/>
         </copy>
 
         <!-- copy the default config file used when one isn't found in /WEB-INF/beehive-netui-config.xml -->

Modified: beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/ConfigUtil.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/ConfigUtil.java?rev=289264&r1=289263&r2=289264&view=diff
==============================================================================
--- beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/ConfigUtil.java (original)
+++ beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/ConfigUtil.java Thu Sep 15 08:42:24 2005
@@ -17,25 +17,22 @@
  */
 package org.apache.beehive.netui.util.config;
 
-import java.io.InputStream;
-
 import org.apache.beehive.netui.util.config.bean.NetUIConfig;
-import org.apache.beehive.netui.util.config.internal.XmlBeanConfigFactory;
+import org.apache.beehive.netui.util.config.parser.NetUIConfigParser;
 import org.apache.beehive.netui.util.logging.Logger;
+import org.apache.beehive.netui.util.xml.XmlInputStreamResolver;
 
 /**
- * <p/>
+ * <p>
  * Utility class for reading properties from the NetUI configuration file.
- * <br/>
- * <br/>
- * The webapp runtime is read from the InputStream passed to the {@link #init(InputStream)} method.
- * The configuration should be initialized with this method and a valid {@link java.io.InputStream}
- * before the first time the {@link #getConfig()} method is called.  If the configuration
- * has not been initialized, {@link #getConfig()} will initialize a bare bones runtime
+ * </p>
+ * <p>
+ * The webapp runtime is read from the {@link XmlInputStreamResolver} passed to the
+ * {@link #init(XmlInputStreamResolver)} method.  The configuration should be initialized with
+ * this method before the first call to the {@link #getConfig()} method.  If the configuration
+ * has not been initialized, {@link #getConfig()} will initialize a default, minimal runtime
  * configuration.  Depending on the web application, this default configuration
  * may lead to runtime errors.
- * <br/>
- * <br/>
  * </p>
  */
 public class ConfigUtil {
@@ -47,27 +44,32 @@
     protected ConfigUtil() {}
 
     /**
-     * <p/>
+     * <p>
      * Initialize the NetUI configuration JavaBean.
-     * <br/>
-     * <br/>
-     * This method can be called exactly once in a J2EE web application.  The
-     * {@link java.io.InputStream} parameter should reference a
-     * netui-config.xml file.  If an error occurs loading the configuration
-     * file, a {@link ConfigInitializationException} will be thrown.
+     * </p>
+     * <p>
+     * This method can be called exactly once in the a given J2EE web application.  The provided
+     * {@link XmlInputStreamResolver} is used to resolve an {@link java.io.InputStream} that references
+     * a NetUI config file instance.  If an error occurs loading the configuration, a
+     * {@link ConfigInitializationException} exception will be thrown.
      * </p>
      *
-     * @param is the {@link java.io.InputStream} from which to read the configuration file
+     * @param xmlInputStreamResolver a resolver that can provide an InputStream to the config file
      * @throws ConfigInitializationException thrown when an error occurs loading the configuration file
-     *                                       or when the configuration is reinitialized.
+     * or when the configuration is reinitialized.
      */
-    public static void init(InputStream is)
+    public static void init(XmlInputStreamResolver xmlInputStreamResolver)
         throws ConfigInitializationException {
 
         if(CONFIG_BEAN != null)
             throw new ConfigInitializationException("Config initialization already completed; unable to reload the NetUI config file.");
 
-        internalInit(is);
+        internalInit(xmlInputStreamResolver);
+    }
+
+    protected static void internalInit(XmlInputStreamResolver xmlInputStreamResolver) {
+       NetUIConfigParser configParser = new NetUIConfigParser();
+        CONFIG_BEAN = configParser.parse(xmlInputStreamResolver);
     }
 
     public static boolean isInit() {
@@ -98,10 +100,4 @@
             throw new IllegalStateException("The NetUI runtime could not find the default config file.  The webapp may not function properly.");
         }
     }
-
-    protected static void internalInit(InputStream is) {
-        /* todo: this factory should be created via a ServletContext param */
-        ConfigFactory configFactory = new XmlBeanConfigFactory();
-        CONFIG_BEAN = configFactory.getConfig(is);
-    }    
 }

Added: beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/parser/NetUIConfigParser.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/parser/NetUIConfigParser.java?rev=289264&view=auto
==============================================================================
--- beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/parser/NetUIConfigParser.java (added)
+++ beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/parser/NetUIConfigParser.java Thu Sep 15 08:42:24 2005
@@ -0,0 +1,657 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.util.config.parser;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.InputStream;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.beehive.netui.util.config.ConfigInitializationException;
+import org.apache.beehive.netui.util.config.bean.NetUIConfig;
+import org.apache.beehive.netui.util.config.bean.JspTagConfig;
+import org.apache.beehive.netui.util.config.bean.SharedFlowRefConfig;
+import org.apache.beehive.netui.util.config.bean.PageFlowActionInterceptorsConfig;
+import org.apache.beehive.netui.util.config.bean.PageFlowConfig;
+import org.apache.beehive.netui.util.config.bean.TypeConverterConfig;
+import org.apache.beehive.netui.util.config.bean.ExpressionLanguagesConfig;
+import org.apache.beehive.netui.util.config.bean.UrlConfig;
+import org.apache.beehive.netui.util.config.bean.RequestInterceptorsConfig;
+import org.apache.beehive.netui.util.config.bean.PageFlowFactoriesConfig;
+import org.apache.beehive.netui.util.config.bean.PageFlowHandlersConfig;
+import org.apache.beehive.netui.util.config.bean.IteratorFactoryConfig;
+import org.apache.beehive.netui.util.config.bean.PrefixHandlerConfig;
+import org.apache.beehive.netui.util.config.bean.GlobalPageFlowActionInterceptorConfig;
+import org.apache.beehive.netui.util.config.bean.InterceptorConfig;
+import org.apache.beehive.netui.util.config.bean.SimpleActionInterceptorConfig;
+import org.apache.beehive.netui.util.config.bean.PerActionInterceptorConfig;
+import org.apache.beehive.netui.util.config.bean.PerPageFlowActionInterceptorConfig;
+import org.apache.beehive.netui.util.config.bean.PreventCache;
+import org.apache.beehive.netui.util.config.bean.MultipartHandler;
+import org.apache.beehive.netui.util.config.bean.ModuleConfigLocatorConfig;
+import org.apache.beehive.netui.util.config.bean.PageFlowFactoryConfig;
+import org.apache.beehive.netui.util.config.bean.DocType;
+import org.apache.beehive.netui.util.config.bean.IdJavascript;
+import org.apache.beehive.netui.util.config.bean.ExpressionLanguageConfig;
+import org.apache.beehive.netui.util.config.bean.BindingContextConfig;
+import org.apache.beehive.netui.util.config.bean.HandlerConfig;
+import org.apache.beehive.netui.util.config.bean.CustomPropertyConfig;
+import org.apache.beehive.netui.util.xml.validation.SchemaValidatorFactory;
+import org.apache.beehive.netui.util.xml.validation.SchemaValidator;
+import org.apache.beehive.netui.util.xml.validation.SchemaValidationException;
+import org.apache.beehive.netui.util.xml.DomUtils;
+import org.apache.beehive.netui.util.xml.XmlInputStreamResolver;
+import org.apache.beehive.netui.util.logging.Logger;
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+
+public final class NetUIConfigParser {
+
+    private static final Logger LOGGER = Logger.getInstance(NetUIConfigParser.class);
+
+    private static final String DEFAULT_CONFIG = "org/apache/beehive/netui/util/config/beehive-netui-config-default.xml";
+    private static final String CONFIG_SCHEMA = "org/apache/beehive/netui/util/config/schema/beehive-netui-config.xsd";
+
+    private static final XmlInputStreamResolver SCHEMA_RESOLVER = new XmlInputStreamResolver() {
+        public String getResourcePath() {
+            return CONFIG_SCHEMA;
+        }
+
+        public InputStream getInputStream() {
+            return NetUIConfigParser.class.getClassLoader().getResourceAsStream(getResourcePath());
+        }
+    };
+
+    private static final XmlInputStreamResolver DEFAULT_CONFIG_RESOLVER = new XmlInputStreamResolver() {
+        public String getResourcePath() {
+            return DEFAULT_CONFIG;
+        }
+
+        public InputStream getInputStream() {
+            return NetUIConfigParser.class.getClassLoader().getResourceAsStream(getResourcePath());
+        }
+    };
+
+    public NetUIConfig parse(final XmlInputStreamResolver xmlResolver) {
+
+        NetUIConfig configBean = null;
+        InputStream xmlInputStream = null;
+        InputStream xsdInputStream = null;
+        XmlInputStreamResolver theXmlResolver = xmlResolver;
+        try {
+            /* use the default XmlInputStream */
+            if(theXmlResolver == null)
+                theXmlResolver = DEFAULT_CONFIG_RESOLVER;
+
+            xmlInputStream = theXmlResolver.getInputStream();
+
+            /* the default XmlInputStream could not provide a valid InputStream; try the default */
+            if(xmlInputStream == null) {
+                theXmlResolver = DEFAULT_CONFIG_RESOLVER;
+                xmlInputStream = theXmlResolver.getInputStream();
+
+                if(LOGGER.isInfoEnabled())
+                    LOGGER.info("Loading the default NetUI config file.  The runtime will be configured " +
+                        "with a set of minimum parameters.");
+            }
+
+            if(LOGGER.isInfoEnabled())
+                LOGGER.info("NetUIConfigParser -- load config: " + theXmlResolver.getResourcePath());
+
+            /* todo: should this throw an exception? */
+            if(xmlInputStream == null)
+                throw new ConfigInitializationException("The NetUI runtime could not find the default config file.  " +
+                        "The webapp may not function properly.");
+
+            xsdInputStream = SCHEMA_RESOLVER.getInputStream();
+            try {
+                SchemaValidator schemaValidator = SchemaValidatorFactory.getInstance();
+                schemaValidator.validate(xsdInputStream, xmlInputStream);
+            }
+            catch(SchemaValidationException e) {
+                throw new ConfigInitializationException("Validation errors occurred parsing the config file \"" +
+                    theXmlResolver.getResourcePath() + "\".  Cause: " + e, e);
+            }
+
+            try {
+                if(xmlInputStream != null)
+                    xmlInputStream.close();
+            }
+            catch(IOException io) {
+                throw new ConfigInitializationException("An exception occurred closing the input stream for \"" + theXmlResolver.getResourcePath());
+            }
+
+            configBean = parse(theXmlResolver.getResourcePath(), theXmlResolver.getInputStream());
+        }
+        finally {
+            try {if(xmlInputStream != null) xmlInputStream.close();} catch(IOException ignore) {}
+            try {if(xsdInputStream != null) xsdInputStream.close();} catch(IOException ignore) {}
+        }
+
+        return configBean;
+    }
+
+    private NetUIConfig parse(final String resourcePath, final InputStream is) {
+        assert is != null;
+
+        NetUIConfig netuiConfig = null;
+        try {
+            /* parse the config document */
+            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+            DocumentBuilder db = dbf.newDocumentBuilder();
+            Document document = db.parse(is);
+
+            PageFlowActionInterceptorsConfig pfActionInterceptorsConfig = parsePfActionInterceptorsConfig(document);
+            PageFlowHandlersConfig pfHandlersConfig = parsePfHandlersConfig(document);
+            PageFlowConfig pfConfig = parsePfConfig(document);
+            PageFlowFactoriesConfig pfFactoriesConfig = parsePfFactoriesConfig(document);
+            SharedFlowRefConfig[] sharedFlowRefConfigs = parseSharedFlowRefConfigs(document);
+            RequestInterceptorsConfig requestInterceptorsConfig = parseRequestInterceptorsConfig(document);
+
+            JspTagConfig jspTagConfig = parseJspTagConfig(document);
+            ExpressionLanguagesConfig elConfig = parseExpressionLanguageConfig(document);
+            TypeConverterConfig[] typeConvertersConfig = parseTypeConvertersConfig(document);
+            UrlConfig urlConfig = parseUrlConfig(document);
+            IteratorFactoryConfig[] iteratorFactories = parseIteratorFactoryConfig(document);
+            PrefixHandlerConfig[] prefixHandlers = parsePrefixHandlerConfig(document);
+
+            netuiConfig = new NetUIConfig(
+                pfActionInterceptorsConfig,
+                pfHandlersConfig,
+                pfConfig,
+                pfFactoriesConfig,
+                sharedFlowRefConfigs,
+                requestInterceptorsConfig,
+                jspTagConfig,
+                prefixHandlers,
+                elConfig,
+                iteratorFactories,
+                typeConvertersConfig,
+                urlConfig
+                );
+        }
+        catch(ParserConfigurationException e) {
+            throw new ConfigInitializationException("Error occurred parsing the config file \"" + resourcePath + "\"", e);
+        }
+        catch(IOException e) {
+            throw new ConfigInitializationException("Error occurred parsing the config file \"" + resourcePath + "\"", e);
+        }
+        catch(SAXException e) {
+            throw new ConfigInitializationException("Error occurred parsing the config file \"" + resourcePath + "\"", e);
+        }
+        return netuiConfig;
+    }
+
+    private static final PageFlowActionInterceptorsConfig parsePfActionInterceptorsConfig(Document document) {
+        final Element elem = DomUtils.getChildElementByName(document.getDocumentElement(), "pageflow-action-interceptors");
+        if(elem == null)
+            return null;
+
+        /* global */
+        Element globalElem = DomUtils.getChildElementByName(elem, "global");
+        GlobalPageFlowActionInterceptorConfig global = null;
+        InterceptorConfig[] globalInterceptorConfigs = null;
+        SimpleActionInterceptorConfig[] globalSimpleActionInterceptorConfig = null;
+        if(globalElem != null) {
+            globalSimpleActionInterceptorConfig =
+                parseSimpleActionInterceptorConfigs(DomUtils.getChildElementsByName(globalElem, "simple-action-interceptor"));
+            globalInterceptorConfigs =
+                parseInterceptorConfigs(DomUtils.getChildElementsByName(globalElem, "action-interceptor"));
+        }
+        global = new GlobalPageFlowActionInterceptorConfig(globalSimpleActionInterceptorConfig, globalInterceptorConfigs);
+
+        /* per page flow */
+        PerPageFlowActionInterceptorConfig[] perPageFlow = null;
+        NodeList perJpfList = elem.getElementsByTagName("per-pageflow");
+        if(perJpfList != null && perJpfList.getLength() > 0) {
+            perPageFlow = new PerPageFlowActionInterceptorConfig[perJpfList.getLength()];
+            for(int i = 0; i < perJpfList.getLength(); i++) {
+                Element perJpfElem = (Element)perJpfList.item(i);
+
+                PerActionInterceptorConfig[] perActionInterceptorConfigs = null;
+                NodeList perAction = perJpfElem.getElementsByTagName("per-action");
+                if(perAction != null && perAction.getLength() > 0) {
+                    perActionInterceptorConfigs = new PerActionInterceptorConfig[perAction.getLength()];
+                    for(int j = 0; j < perAction.getLength(); j++) {
+                        perActionInterceptorConfigs[j] = new PerActionInterceptorConfig(
+                            DomUtils.getChildElementText((Element)perAction.item(j), "action-name"),
+                            parseSimpleActionInterceptorConfigs(DomUtils.getChildElementsByName((Element)perAction.item(j), "simple-action-interceptor")),
+                            parseInterceptorConfigs(DomUtils.getChildElementsByName((Element)perAction.item(j), "action-interceptor"))
+                        );
+                    }
+                }
+
+                perPageFlow[i] = new PerPageFlowActionInterceptorConfig(
+                    DomUtils.getChildElementText(perJpfElem, "pageflow-uri"),
+                    parseSimpleActionInterceptorConfigs(DomUtils.getChildElementsByName(perJpfElem, "simple-action-interceptor")),
+                    parseInterceptorConfigs(DomUtils.getChildElementsByName(perJpfElem, "action-interceptor")),
+                    perActionInterceptorConfigs
+                );
+            }
+        }
+
+        return new PageFlowActionInterceptorsConfig(global, perPageFlow);
+    }
+
+    private static final SimpleActionInterceptorConfig[] parseSimpleActionInterceptorConfigs(List list) {
+        if(list == null || list.size() == 0)
+            return null;
+
+        SimpleActionInterceptorConfig[] simpleActionInterceptorConfigs =
+            new SimpleActionInterceptorConfig[list.size()];
+        for(int i = 0; i < list.size(); i++) {
+            Boolean afterAction = null;
+
+            String tmp = DomUtils.getChildElementText((Element)list.get(i), "after-action");
+            if(tmp != null)
+                afterAction = new Boolean(Boolean.parseBoolean(tmp));
+
+            simpleActionInterceptorConfigs[i] = new SimpleActionInterceptorConfig(
+                afterAction,
+                DomUtils.getChildElementText((Element)list.get(i), "intercept-path")
+            );
+        }
+        return simpleActionInterceptorConfigs;
+    }
+
+    private static final PageFlowHandlersConfig parsePfHandlersConfig(Document document) {
+        Element elem = DomUtils.getChildElementByName(document.getDocumentElement(), "pageflow-handlers");
+        if(elem == null)
+            return null;
+
+        return new PageFlowHandlersConfig(
+            parseHandlerConfig(elem.getElementsByTagName("action-forward-handler")),
+            parseHandlerConfig(elem.getElementsByTagName("exceptions-handler")),
+            parseHandlerConfig(elem.getElementsByTagName("forward-redirect-handler")),
+            parseHandlerConfig(elem.getElementsByTagName("login-handler")),
+            parseHandlerConfig(elem.getElementsByTagName("storage-handler")),
+            parseHandlerConfig(elem.getElementsByTagName("reloadable-class-handler"))
+        );
+    }
+
+    private static final PageFlowConfig parsePfConfig(Document document) {
+        Element elem = DomUtils.getChildElementByName(document.getDocumentElement(), "pageflow-config");
+
+        if(elem == null)
+            return new PageFlowConfig();
+
+        PageFlowConfig pfConfig = null;
+
+        Boolean enableSelfNesting = null;
+        Boolean ensureSecureForwards = null;
+        Boolean throwSessionExpiredException = null;
+        Integer maxForwardsPerRequest = null;
+        Integer maxNestingStackDepth = null;
+        MultipartHandler mpHandler = null;
+        PreventCache preventCache = null;
+        ModuleConfigLocatorConfig[] moduleConfigLocators = null;
+
+        String tmp = null;
+
+        tmp = DomUtils.getChildElementText(elem, "enable-self-nesting");
+        if(tmp != null)
+            enableSelfNesting = new Boolean(Boolean.parseBoolean(tmp));
+
+        tmp = DomUtils.getChildElementText(elem, "ensure-secure-forwards");
+        if(tmp != null)
+            ensureSecureForwards = new Boolean(Boolean.parseBoolean(tmp));
+
+        tmp = DomUtils.getChildElementText(elem, "throw-session-expired-exception");
+        if(tmp != null)
+            throwSessionExpiredException = new Boolean(Boolean.parseBoolean(tmp));
+
+        tmp = DomUtils.getChildElementText(elem, "max-forwards-per-request");
+        if(tmp != null)
+            maxForwardsPerRequest = new Integer(Integer.parseInt(tmp));
+
+        tmp = DomUtils.getChildElementText(elem, "max-nesting-stack-depth");
+        if(tmp != null)
+            maxNestingStackDepth = new Integer(Integer.parseInt(tmp));
+
+        tmp = DomUtils.getChildElementText(elem, "multipart-handler");
+        if(tmp != null) {
+            if(tmp.equals("disabled"))
+                mpHandler = MultipartHandler.DISABLED;
+            else if(tmp.equals("disk"))
+                mpHandler = MultipartHandler.DISK;
+            else if(tmp.equals("memory"))
+                mpHandler = MultipartHandler.MEMORY;
+        }
+
+        tmp = DomUtils.getChildElementText(elem, "prevent-cache");
+        if(tmp != null) {
+            if(tmp.equals("always"))
+                preventCache = PreventCache.ALWAYS;
+            else if(tmp.equals("default"))
+                preventCache = PreventCache.DEFAULT;
+            else if(tmp.equals("inDevMode"))
+                preventCache = PreventCache.IN_DEV_MODE;
+        }
+
+        moduleConfigLocators =
+            parseModuleConfigLocators(DomUtils.getChildElementByName(elem, "module-config-locators"));
+
+        pfConfig = new PageFlowConfig(
+            enableSelfNesting,
+            ensureSecureForwards,
+            throwSessionExpiredException,
+            maxForwardsPerRequest,
+            maxNestingStackDepth,
+            mpHandler,
+            preventCache,
+            moduleConfigLocators
+        );
+
+        return pfConfig;
+    }
+
+    private static final ModuleConfigLocatorConfig[] parseModuleConfigLocators(Element element) {
+        if(element == null)
+            return null;
+
+        NodeList list = element.getElementsByTagName("module-config-locator");
+        if(list == null || list.getLength() == 0)
+            return null;
+
+        ModuleConfigLocatorConfig[] mclConfig = new ModuleConfigLocatorConfig[list.getLength()];
+        for(int i = 0; i < list.getLength(); i++) {
+            mclConfig[i] = new ModuleConfigLocatorConfig(
+                DomUtils.getChildElementText((Element)list.item(i), "locator-class"),
+                DomUtils.getChildElementText((Element)list.item(i), "description")
+            );
+        }
+        return mclConfig;
+    }
+
+    private static final PageFlowFactoriesConfig parsePfFactoriesConfig(Document document) {
+        Element elem = DomUtils.getChildElementByName(document.getDocumentElement(), "pageflow-factories");
+        if(elem == null)
+            return null;
+
+        PageFlowFactoryConfig pfFactory = parsePageFlowFactoryConfig(DomUtils.getChildElementByName(elem, "flowcontroller-factory"));
+        PageFlowFactoryConfig fbbFactoyr = parsePageFlowFactoryConfig(DomUtils.getChildElementByName(elem, "faces-backing-bean-factory"));
+
+        return new PageFlowFactoriesConfig(pfFactory, fbbFactoyr);
+    }
+
+    private static final SharedFlowRefConfig[] parseSharedFlowRefConfigs(Document document) {
+        Element elem = DomUtils.getChildElementByName(document.getDocumentElement(), "default-shared-flow-refs");
+        if(elem == null)
+            return null;
+
+        NodeList list = elem.getElementsByTagName("shared-flow-ref");
+        if(list == null || list.getLength() == 0)
+            return null;
+
+        SharedFlowRefConfig[] sharedFlowRefConfigs = new SharedFlowRefConfig[list.getLength()];
+        for(int i = 0; i < list.getLength(); i++) {
+            Node node = list.item(i);
+            sharedFlowRefConfigs[i] = new SharedFlowRefConfig(
+                DomUtils.getChildElementText((Element)node, "name"),
+                DomUtils.getChildElementText((Element)node, "type")
+            );
+        }
+
+        return sharedFlowRefConfigs;
+    }
+
+    private static final RequestInterceptorsConfig parseRequestInterceptorsConfig(Document document) {
+
+        Element elem = DomUtils.getChildElementByName(document.getDocumentElement(), "request-interceptors");
+        if(elem == null)
+            return null;
+
+        RequestInterceptorsConfig requestInterceptorsConfig = null;
+        Element global = DomUtils.getChildElementByName(elem, "global");
+        if(global == null)
+            return null;
+
+        InterceptorConfig[] interceptorConfigs = parseInterceptorConfigs(DomUtils.getChildElementsByName(global, "request-interceptor"));
+        if(interceptorConfigs != null)
+            requestInterceptorsConfig = new RequestInterceptorsConfig(interceptorConfigs);
+
+        return requestInterceptorsConfig;
+    }
+
+    private static final JspTagConfig parseJspTagConfig(Document document) {
+        DocType docType = null;
+        IdJavascript idJavascript = null;
+        String treeImageLocation = null;
+
+        String tmp = null;
+        Element elem = DomUtils.getChildElementByName(document.getDocumentElement(), "jsp-tag-config");
+
+        if(elem == null)
+            return new JspTagConfig();
+
+        tmp = DomUtils.getChildElementText(elem, "doctype");
+        if(tmp != null) {
+            if(tmp.equals("html4-loose"))
+                docType = DocType.HTML4_LOOSE;
+            else if(tmp.equals("html4-loose-quirks"))
+                docType = DocType.HTML4_LOOSE_QUIRKS;
+            else if(tmp.equals("xhtml1-transitional"))
+                docType = DocType.XHTML1_TRANSITIONAL;
+        }
+
+        tmp = DomUtils.getChildElementText(elem, "id-javascript");
+        if(tmp != null) {
+            if(tmp.equals("default"))
+                idJavascript = IdJavascript.DEFAULT;
+            else if(tmp.equals("legacy"))
+                idJavascript = IdJavascript.LEGACY;
+            else if(tmp.equals("legacyOnly"))
+                idJavascript = IdJavascript.LEGACY_ONLY;
+        }
+
+        treeImageLocation = DomUtils.getChildElementText(elem, "tree-image-location");
+
+        return new JspTagConfig(docType, idJavascript, treeImageLocation);
+    }
+
+    private static final PrefixHandlerConfig[] parsePrefixHandlerConfig(Document document) {
+        Element elem = DomUtils.getChildElementByName(document.getDocumentElement(), "prefix-handlers");
+        if(elem == null)
+            return null;
+
+        NodeList list = elem.getElementsByTagName("prefix-handler");
+        if(list == null || list.getLength() == 0)
+            return null;
+
+        PrefixHandlerConfig[] prefixHandlers = new PrefixHandlerConfig[list.getLength()];
+        for(int i = 0; i < list.getLength(); i++) {
+            Node node = list.item(i);
+            prefixHandlers[i] = new PrefixHandlerConfig(
+                DomUtils.getChildElementText((Element)node, "name"),
+                DomUtils.getChildElementText((Element)node, "handler-class")
+            );
+        }
+
+        return prefixHandlers;
+    }
+
+    private static final ExpressionLanguagesConfig parseExpressionLanguageConfig(Document document) {
+
+        Element elem = DomUtils.getChildElementByName(document.getDocumentElement(), "expression-languages");
+        if(elem == null)
+            return null;
+
+        String defaultLanguage = DomUtils.getChildElementText(elem, "default-language");
+        ExpressionLanguageConfig[] elConfigs = null;
+
+        NodeList list = elem.getElementsByTagName("expression-language");
+        if(list != null && list.getLength() > 0) {
+            elConfigs = new ExpressionLanguageConfig[list.getLength()];
+            for(int i = 0; i < list.getLength(); i++) {
+                Node node = list.item(i);
+
+                BindingContextConfig[] bindingContextConfig = null;
+                Node bindingContexts = DomUtils.getChildElementByName((Element)node, "binding-contexts");
+                if(bindingContexts != null) {
+                    NodeList bcList = ((Element)bindingContexts).getElementsByTagName("binding-context");
+                    if(bcList != null && bcList.getLength() > 0) {
+                        bindingContextConfig = new BindingContextConfig[bcList.getLength()];
+                        for(int j = 0; j < bcList.getLength(); j++) {
+                            bindingContextConfig[j] = new BindingContextConfig(
+                                DomUtils.getChildElementText((Element)bcList.item(j), "name"),
+                                DomUtils.getChildElementText((Element)bcList.item(j), "factory-class")
+                            );
+                        }
+                    }
+                }
+
+                elConfigs[i] = new ExpressionLanguageConfig(
+                    DomUtils.getChildElementText((Element)node, "name"),
+                    DomUtils.getChildElementText((Element)node, "factory-class"),
+                    bindingContextConfig
+                );
+            }
+        }
+
+        return new ExpressionLanguagesConfig(defaultLanguage, elConfigs);
+    }
+
+    private static final TypeConverterConfig[] parseTypeConvertersConfig(Document document) {
+        Element elem = DomUtils.getChildElementByName(document.getDocumentElement(), "type-converters");
+        if(elem == null)
+            return null;
+
+        NodeList list = elem.getElementsByTagName("type-converter");
+        if(list == null || list.getLength() == 0)
+            return null;
+
+        TypeConverterConfig[] typeConverterConfig = new TypeConverterConfig[list.getLength()];
+        for(int i = 0; i < list.getLength(); i++) {
+            Node node = list.item(i);
+            typeConverterConfig[i] = new TypeConverterConfig(
+                DomUtils.getChildElementText((Element)node, "type"),
+                DomUtils.getChildElementText((Element)node, "converter-class")
+            );
+        }
+
+        return typeConverterConfig;
+    }
+
+    private static final IteratorFactoryConfig[] parseIteratorFactoryConfig(Document document) {
+        Element elem = DomUtils.getChildElementByName(document.getDocumentElement(), "iterator-factories");
+        if(elem == null)
+            return null;
+
+        NodeList list = elem.getElementsByTagName("iterator-factory");
+        if(list == null || list.getLength() == 0)
+            return null;
+
+        IteratorFactoryConfig[] iteratorFactoryConfig = new IteratorFactoryConfig[list.getLength()];
+        for(int i = 0; i < list.getLength(); i++) {
+            Node node = list.item(i);
+            iteratorFactoryConfig[i] = new IteratorFactoryConfig(
+                DomUtils.getChildElementText((Element)node, "name"),
+                DomUtils.getChildElementText((Element)node, "factory-class")
+            );
+        }
+        return iteratorFactoryConfig;
+    }
+
+    private static final UrlConfig parseUrlConfig(Document document) {
+        Element elem = DomUtils.getChildElementByName(document.getDocumentElement(), "url-config");
+        if(elem == null)
+            return new UrlConfig();
+
+        Boolean urlEncodeUrls = null;
+        Boolean htmlAmpEntity = null;
+        String templatedUrlFormatterClass = null;
+
+        String tmp = null;
+
+        tmp = DomUtils.getChildElementText(elem, "url-encode-urls");
+        if(tmp != null)
+            urlEncodeUrls = new Boolean(Boolean.parseBoolean(tmp));
+
+        tmp = DomUtils.getChildElementText(elem, "html-amp-entity");
+        if(tmp != null)
+            htmlAmpEntity = new Boolean(Boolean.parseBoolean(tmp));
+
+        templatedUrlFormatterClass = DomUtils.getChildElementText(elem, "templated-url-formatter-class");
+
+        return new UrlConfig(urlEncodeUrls, htmlAmpEntity, templatedUrlFormatterClass);
+    }
+
+    /* -----------------------------------------------------------------------------------
+
+       Utilities used to parse reused NetUI config types
+
+       ----------------------------------------------------------------------------------
+     */
+
+    private static final HandlerConfig[] parseHandlerConfig(NodeList list) {
+        if(list == null || list.getLength() == 0)
+            return null;
+
+        HandlerConfig[] handlerConfigs = new HandlerConfig[list.getLength()];
+        for(int i = 0; i < handlerConfigs.length; i++) {
+            handlerConfigs[i] = new HandlerConfig(
+                DomUtils.getChildElementText((Element)list.item(i), "handler-class"),
+                parseCustomProperties(((Element)list.item(i)).getElementsByTagName("custom-property"))
+            );
+        }
+        return handlerConfigs;
+    }
+
+    private static final InterceptorConfig[] parseInterceptorConfigs(List list) {
+        if(list == null || list.size() == 0)
+            return null;
+
+        InterceptorConfig[] interceptorConfigs = new InterceptorConfig[list.size()];
+        for(int i = 0; i < list.size(); i++) {
+            interceptorConfigs[i] = new InterceptorConfig(
+                DomUtils.getChildElementText((Element)list.get(i), "interceptor-class"),
+                parseCustomProperties( ((Element)list.get(i)).getElementsByTagName("custom-property"))
+            );
+        }
+        return interceptorConfigs;
+    }
+
+    private static final CustomPropertyConfig[] parseCustomProperties(NodeList customProperties) {
+        if(customProperties == null || customProperties.getLength() == 0)
+            return null;
+
+        CustomPropertyConfig[] cpConfig = new CustomPropertyConfig[customProperties.getLength()];
+        for(int i = 0; i < cpConfig.length; i++) {
+            cpConfig[i] = new CustomPropertyConfig(
+                DomUtils.getChildElementText((Element)customProperties.item(i), "name"),
+                DomUtils.getChildElementText((Element)customProperties.item(i), "value")
+            );
+        }
+        return cpConfig;
+    }
+
+    private static final PageFlowFactoryConfig parsePageFlowFactoryConfig(Node node) {
+        if(node != null) {
+            return new PageFlowFactoryConfig(
+                DomUtils.getChildElementText((Element)node, "factory-class"),
+                parseCustomProperties((((Element)node).getElementsByTagName("custom-property")))
+            );
+        }
+        else return null;
+    }
+}

Propchange: beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/parser/NetUIConfigParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/ConfigBeanTest.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/ConfigBeanTest.java?rev=289264&r1=289263&r2=289264&view=diff
==============================================================================
--- beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/ConfigBeanTest.java (original)
+++ beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/ConfigBeanTest.java Thu Sep 15 08:42:24 2005
@@ -22,13 +22,12 @@
 import junit.framework.TestCase;
 import junit.framework.Test;
 import junit.framework.TestSuite;
-import org.apache.beehive.netui.util.config.internal.xmlbean.generated.NetuiConfigDocument;
-import org.apache.beehive.netui.util.config.internal.XmlBeanConfigFactory;
 import org.apache.beehive.netui.util.config.ConfigUtil;
-import org.apache.beehive.netui.util.config.ConfigFactory;
 import org.apache.beehive.netui.util.config.ConfigInitializationException;
+import org.apache.beehive.netui.util.config.parser.NetUIConfigParser;
 import org.apache.beehive.netui.util.config.bean.NetUIConfig;
 import org.apache.beehive.netui.util.config.bean.DocType;
+import org.apache.beehive.netui.util.xml.XmlInputStreamResolver;
 
 /**
  *
@@ -38,21 +37,14 @@
 
     public void testConfigUtil()
         throws Exception {
-        InputStream is = null;
-        try {
-            is = getClass().getClassLoader().getResourceAsStream("WEB-INF/beehive-netui-config.xml");
+        XmlInputStreamResolver xmlResolver = new TestXmlInputStreamResolver("WEB-INF/beehive-netui-config.xml");
 
-            ConfigUtil.init(is);
+        ConfigUtil.init(xmlResolver);
 
-            NetUIConfig config = ConfigUtil.getConfig();
-            assertNotNull(config);
-            assertFalse(config.getPageFlowConfig().isEnableSelfNesting());
-            assertTrue(config.getJspTagConfig().getDocType() == DocType.HTML4_LOOSE_QUIRKS);
-        }
-        finally{
-            if(is != null)
-                is.close();
-        }
+        NetUIConfig config = ConfigUtil.getConfig();
+        assertNotNull(config);
+        assertFalse(config.getPageFlowConfig().isEnableSelfNesting());
+        assertTrue(config.getJspTagConfig().getDocType() == DocType.HTML4_LOOSE_QUIRKS);
     }
 
     public void testValidationFailure()
@@ -74,18 +66,9 @@
     private NetUIConfig loadConfigBean(String resourcePath)
         throws Exception {
 
-        NetUIConfig config = null;
-        InputStream is = null;
-        try {
-            is = getClass().getClassLoader().getResourceAsStream(resourcePath);
-            config = (new XmlBeanConfigFactory()).getConfig(is);
-        }
-        finally{
-            if(is != null)
-                is.close();
-        }
-
-        return config;
+        XmlInputStreamResolver xmlResolver = new TestXmlInputStreamResolver(resourcePath);
+        NetUIConfigParser configParser = new NetUIConfigParser();
+        return configParser.parse(xmlResolver);
     }
 
     public ConfigBeanTest(String name) {

Added: beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/ParserTest.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/ParserTest.java?rev=289264&view=auto
==============================================================================
--- beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/ParserTest.java (added)
+++ beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/ParserTest.java Thu Sep 15 08:42:24 2005
@@ -0,0 +1,67 @@
+/**
+ Copyright 2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ $Header:$
+ */
+package org.apache.beehive.netui.test.util.config;
+
+import junit.framework.TestCase;
+import org.apache.beehive.netui.util.config.bean.NetUIConfig;
+import org.apache.beehive.netui.util.config.bean.DocType;
+import org.apache.beehive.netui.util.config.bean.IdJavascript;
+import org.apache.beehive.netui.util.config.parser.NetUIConfigParser;
+import org.apache.beehive.netui.util.xml.XmlInputStreamResolver;
+
+/**
+ */
+public class ParserTest
+    extends TestCase {
+
+    public void testParsing() {
+        String resourcePath = "org/apache/beehive/netui/test/util/config/instances/beehive-netui-config-default.xml";
+
+        NetUIConfig config = parseNetUIConfig(resourcePath);
+
+        assertNotNull(config);
+        assertNotNull(config.getJspTagConfig());
+
+        assertTrue(config.getJspTagConfig().getDocType() == DocType.HTML4_LOOSE_QUIRKS);
+        assertTrue(config.getJspTagConfig().getIdJavascript() == IdJavascript.DEFAULT);
+        assertNull(config.getJspTagConfig().getTreeImageLocation());
+
+        assertNotNull(config.getTypeConverters());
+        assertTrue(config.getTypeConverters().length > 0);
+        assertEquals("org.foo.FooBean", config.getTypeConverters()[0].getType());
+        assertEquals("org.foo.FooBeanConverter", config.getTypeConverters()[0].getConverterClass());
+    }
+
+    public void testPageFlowConfigParsing() {
+        String resourcePath = "org/apache/beehive/netui/test/util/config/instances/beehive-netui-config-pageflowConfig.xml";
+
+        NetUIConfig netuiConfig = parseNetUIConfig(resourcePath);
+
+        assertEquals(314, netuiConfig.getPageFlowConfig().getMaxForwardsPerRequest());
+        assertEquals(10, netuiConfig.getPageFlowConfig().getMaxNestingStackDepth());
+        assertFalse(netuiConfig.getPageFlowConfig().isEnableSelfNesting());
+
+    }
+
+    private NetUIConfig parseNetUIConfig(String resourcePath) {
+        XmlInputStreamResolver xmlResolver = new TestXmlInputStreamResolver(resourcePath);
+
+        NetUIConfigParser parser = new NetUIConfigParser();
+        return parser.parse(xmlResolver);
+    }
+}

Propchange: beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/ParserTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/SchemaValidationTest.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/SchemaValidationTest.java?rev=289264&view=auto
==============================================================================
--- beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/SchemaValidationTest.java (added)
+++ beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/SchemaValidationTest.java Thu Sep 15 08:42:24 2005
@@ -0,0 +1,83 @@
+/**
+ Copyright 2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ $Header:$
+ */
+package org.apache.beehive.netui.test.util.config;
+
+import junit.framework.TestCase;
+
+import org.apache.beehive.netui.util.xml.validation.SchemaValidationException;
+import org.apache.beehive.netui.util.xml.validation.SchemaValidator;
+import org.apache.beehive.netui.util.xml.validation.SchemaValidatorFactory;
+import org.apache.beehive.netui.util.xml.XmlInputStreamResolver;
+
+import java.io.InputStream;
+import java.io.IOException;
+
+/**
+ */
+public class SchemaValidationTest
+    extends TestCase {
+
+    public void testValidationSuccess() {
+        SchemaValidator schemaValidator = SchemaValidatorFactory.getInstance();
+
+        XmlInputStreamResolver xsdInputStreamResolver =
+            new TestXmlInputStreamResolver("org/apache/beehive/netui/util/config/schema/beehive-netui-config.xsd");
+
+        XmlInputStreamResolver xmlInputStreamResolver =
+            new TestXmlInputStreamResolver("org/apache/beehive/netui/test/util/config/instances/beehive-netui-config-default.xml");
+
+        InputStream xsdIs = xsdInputStreamResolver.getInputStream();
+        InputStream xmlIs = xmlInputStreamResolver.getInputStream();
+        try {
+            schemaValidator.validate(xsdIs, xmlIs);
+        }
+        catch(SchemaValidationException e) {
+            assertTrue("Received an unexpected schema validation error", false);
+        }
+        finally {
+            try {if(xsdIs != null) xsdIs.close();}catch(IOException io) {}
+            try {if(xmlIs != null) xmlIs.close();}catch(IOException io) {}
+        }
+    }
+
+    public void testValidationFailure() {
+
+        SchemaValidator schemaValidator = SchemaValidatorFactory.getInstance();
+
+        XmlInputStreamResolver xsdInputStreamResolver =
+            new TestXmlInputStreamResolver("org/apache/beehive/netui/util/config/schema/beehive-netui-config.xsd");
+
+        XmlInputStreamResolver xmlInputStreamResolver =
+            new TestXmlInputStreamResolver("org/apache/beehive/netui/test/util/config/instances/invalid-beehive-netui-config-default.xml");
+
+        InputStream xsdIs = xsdInputStreamResolver.getInputStream();
+        InputStream xmlIs = xmlInputStreamResolver.getInputStream();
+        try {
+            schemaValidator.validate(xsdIs, xmlIs);
+        }
+        catch(SchemaValidationException e) {
+            return;
+        }
+        finally {
+            try {if(xsdIs != null) xsdIs.close();}catch(IOException io) {}
+            try {if(xmlIs != null) xmlIs.close();}catch(IOException io) {}
+        }
+
+        assertTrue("Expected a validation failure but did not receive one", false);
+    }
+}

Propchange: beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/SchemaValidationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/TestConfigUtil.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/TestConfigUtil.java?rev=289264&r1=289263&r2=289264&view=diff
==============================================================================
--- beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/TestConfigUtil.java (original)
+++ beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/TestConfigUtil.java Thu Sep 15 08:42:24 2005
@@ -22,6 +22,7 @@
 
 import org.apache.beehive.netui.util.config.ConfigUtil;
 import org.apache.beehive.netui.util.config.ConfigInitializationException;
+import org.apache.beehive.netui.util.xml.XmlInputStreamResolver;
 
 /**
  *
@@ -31,17 +32,12 @@
 
     private static final String DEFAULT_CONFIG = "WEB-INF/beehive-netui-config.xml";
 
-    public static void testInit(InputStream is)
-        throws ConfigInitializationException {
-        internalInit(is);
-    }
-
     public static void testInit() {
 
         InputStream is = null;
         try {
-            is = TestConfigUtil.class.getClassLoader().getResourceAsStream(DEFAULT_CONFIG);
-            testInit(is);
+            XmlInputStreamResolver xmlResolver = new TestXmlInputStreamResolver(DEFAULT_CONFIG);
+            internalInit(null); //xmlResolver);
         } catch(ConfigInitializationException cie) {
             /*
               sometimes bad form to do this, but in the default case for testing,
@@ -50,9 +46,6 @@
              */
 
             throw new IllegalStateException("Caught exception initializing the default config file \"" + DEFAULT_CONFIG + "\"", cie);
-        }
-        finally {
-            try{if(is != null) is.close();}catch(IOException ignore) {}
         }
     }
 }

Added: beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/TestXmlInputStreamResolver.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/TestXmlInputStreamResolver.java?rev=289264&view=auto
==============================================================================
--- beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/TestXmlInputStreamResolver.java (added)
+++ beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/TestXmlInputStreamResolver.java Thu Sep 15 08:42:24 2005
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.test.util.config;
+
+import java.io.InputStream;
+
+import org.apache.beehive.netui.util.xml.XmlInputStreamResolver;
+
+public class TestXmlInputStreamResolver
+    extends XmlInputStreamResolver {
+
+    private String _resourcePath = null;
+
+    public TestXmlInputStreamResolver(String resourcePath) {
+        _resourcePath = resourcePath;
+    }
+
+    public String getResourcePath() {
+        return _resourcePath;
+    }
+
+    public InputStream getInputStream() {
+        return getClass().getClassLoader().getResourceAsStream(_resourcePath);
+    }
+}

Propchange: beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/TestXmlInputStreamResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/instances/beehive-netui-config-default.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/instances/beehive-netui-config-default.xml?rev=289264&view=auto
==============================================================================
--- beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/instances/beehive-netui-config-default.xml (added)
+++ beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/instances/beehive-netui-config-default.xml Thu Sep 15 08:42:24 2005
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<netui-config xmlns="http://beehive.apache.org/netui/2004/server/config">
+
+    <expression-languages>
+        <default-language>netuiel</default-language>
+        <expression-language>
+            <name>netuiel</name>
+            <factory-class>org.apache.beehive.netui.script.el.ExpressionEvaluatorImpl$NetUIELEngineFactory</factory-class>
+        </expression-language>
+    </expression-languages>
+
+    <type-converters>
+        <type-converter>
+            <type>org.foo.FooBean</type>
+            <converter-class>org.foo.FooBeanConverter</converter-class>
+        </type-converter>
+    </type-converters>
+
+    <request-interceptors>
+        <global>
+            <request-interceptor>
+                <interceptor-class>org.apache.beehive.netui.tags.tree.TreeCRI</interceptor-class>
+            </request-interceptor>
+            <request-interceptor>
+                <interceptor-class>org.apache.beehive.netui.tags.divpanel.DivPanelCRI</interceptor-class>
+            </request-interceptor>
+        </global>
+    </request-interceptors>
+
+    <prefix-handlers>
+        <prefix-handler>
+            <name>checkbox_key</name>
+            <handler-class>org.apache.beehive.netui.tags.html.CheckBox$CheckBoxPrefixHandler</handler-class>
+        </prefix-handler>
+        <prefix-handler>
+            <name>checkbox_group_key</name>
+            <handler-class>org.apache.beehive.netui.tags.html.CheckBoxGroup$CheckboxGroupPrefixHandler</handler-class>
+        </prefix-handler>
+        <prefix-handler>
+            <name>radio_button_group_key</name>
+            <handler-class>org.apache.beehive.netui.tags.html.RadioButtonGroup$RadioButtonGroupPrefixHandler</handler-class>
+        </prefix-handler>
+        <prefix-handler>
+            <name>select_key</name>
+            <handler-class>org.apache.beehive.netui.tags.html.Select$SelectPrefixHandler</handler-class>
+        </prefix-handler>
+    </prefix-handlers>
+
+</netui-config>
+

Propchange: beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/instances/beehive-netui-config-default.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/instances/beehive-netui-config-pageflowConfig.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/instances/beehive-netui-config-pageflowConfig.xml?rev=289264&view=auto
==============================================================================
--- beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/instances/beehive-netui-config-pageflowConfig.xml (added)
+++ beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/instances/beehive-netui-config-pageflowConfig.xml Thu Sep 15 08:42:24 2005
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<netui-config xmlns="http://beehive.apache.org/netui/2004/server/config">
+
+    <expression-languages>
+        <default-language>netuiel</default-language>
+        <expression-language>
+            <name>netuiel</name>
+            <factory-class>org.apache.beehive.netui.script.el.ExpressionEvaluatorImpl$NetUIELEngineFactory</factory-class>
+        </expression-language>
+    </expression-languages>
+    
+    <pageflow-config>
+        <max-forwards-per-request>314</max-forwards-per-request>
+    </pageflow-config>
+
+</netui-config>
+

Propchange: beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/instances/beehive-netui-config-pageflowConfig.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/instances/invalid-beehive-netui-config-default.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/instances/invalid-beehive-netui-config-default.xml?rev=289264&view=auto
==============================================================================
--- beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/instances/invalid-beehive-netui-config-default.xml (added)
+++ beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/instances/invalid-beehive-netui-config-default.xml Thu Sep 15 08:42:24 2005
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<netui-config xmlns="http://beehive.apache.org/netui/2004/server/config">
+
+    <expression-languages>
+        <default-language>netuiel</default-language>
+        <expression-language>
+            <name>netuiel</name>
+            <name>netuiel</name>
+            <factory-class>org.apache.beehive.netui.script.el.ExpressionEvaluatorImpl$NetUIELEngineFactory</factory-class>
+        </expression-language>
+    </expression-languages>
+
+    <request-interceptors>
+        <global>
+            <request-interceptor>
+                <interceptor-class>org.apache.beehive.netui.tags.tree.TreeCRI</interceptor-class>
+            </request-interceptor>
+            <request-interceptor>
+                <interceptor-class>org.apache.beehive.netui.tags.divpanel.DivPanelCRI</interceptor-class>
+            </request-interceptor>
+        </global>
+    </request-interceptors>
+
+    <prefix-handlers>
+        <prefix-handler>
+            <name>checkbox_key</name>
+            <handler-class>org.apache.beehive.netui.tags.html.CheckBox$CheckBoxPrefixHandler</handler-class>
+        </prefix-handler>
+        <prefix-handler>
+            <name>checkbox_group_key</name>
+            <handler-class>org.apache.beehive.netui.tags.html.CheckBoxGroup$CheckboxGroupPrefixHandler</handler-class>
+        </prefix-handler>
+        <prefix-handler>
+            <name>radio_button_group_key</name>
+            <handler-class>org.apache.beehive.netui.tags.html.RadioButtonGroup$RadioButtonGroupPrefixHandler</handler-class>
+        </prefix-handler>
+        <prefix-handler>
+            <name>select_key</name>
+            <handler-class>org.apache.beehive.netui.tags.html.Select$SelectPrefixHandler</handler-class>
+        </prefix-handler>
+    </prefix-handlers>
+
+</netui-config>
+

Propchange: beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/instances/invalid-beehive-netui-config-default.xml
------------------------------------------------------------------------------
    svn:eol-style = native