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 2006/03/14 18:17:37 UTC

svn commit: r385838 [1/2] - in /beehive/trunk/netui: ./ src/core/ src/core/org/apache/beehive/netui/core/chain/ src/core/org/apache/beehive/netui/core/chain/impl/ src/core/org/apache/beehive/netui/core/chain/web/ src/core/org/apache/beehive/netui/core/...

Author: ekoneil
Date: Tue Mar 14 09:17:31 2006
New Revision: 385838

URL: http://svn.apache.org/viewcvs?rev=385838&view=rev
Log:
Add both a command pattern and chain of responsibility pattern to NetUI.  These patterns define commands and chains of commands that can be executed at various extension points in the framework to support adding arbitrary user code / extensions.  The included source isn't used anywhere yet (that's coming), but it does include the ability to define a catalog of chains / commands inside of the beehive-netui-config.xml file.  

This <catalog> element is parsed with the CatalogParser which is invoked from the NetUIConfigParser.  Once the <catalog> has been parsed, a CatalogConfig object is available from the NetUIConfig object and can be converted into a Catalog object using the CatalogFactory.  The CatalogFactory stores Catalogs of commands / chains as objects cached by the ClassLoader.  

Arbitrary properties can be set on a Command by defining <custom-property> elements in the XML file; the framework uses commons-beanutils to map these property names onto JavaBean properties defined by the Command itself.

This change includes a set of JUnit tests for manually configuring commands / chains and for parsing them from an XML definition.  

BB: self
Test: dist test pass


Added:
    beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/
    beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Catalog.java
    beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/CatalogFactory.java
    beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Chain.java
    beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Command.java
    beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Context.java
    beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/
    beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/CatalogBase.java
    beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/CatalogFactoryBase.java
    beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/ChainBase.java
    beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/ContextBase.java
    beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/web/
    beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/web/WebChainContext.java
    beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/bean/CatalogConfig.java
    beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/bean/ChainConfig.java
    beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/bean/CommandConfig.java
    beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/internal/catalog/
    beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/internal/catalog/CatalogParser.java
    beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/internal/catalog/catalog-config.xsd
    beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/chain/
    beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/chain/CatalogParserTest.java
    beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/chain/SimpleCatalogFactoryTest.java
    beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/chain/SimpleChainTest.java
    beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/chain/commands/
    beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/chain/commands/ConfigurableCommand.java
    beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/chain/commands/EchoCommand.java
    beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/chain/xmls/
    beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/chain/xmls/simple-chain.xml
    beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/xmls/
      - copied from r384116, beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/instances/
    beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/xmls/beehive-netui-config-with-chain.xml
Removed:
    beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/ParserTest.java
    beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/instances/
Modified:
    beehive/trunk/netui/build.xml
    beehive/trunk/netui/netui-imports.xml
    beehive/trunk/netui/src/core/build.xml
    beehive/trunk/netui/src/core/org/apache/beehive/netui/core/urls/AjaxUrlInfo.java
    beehive/trunk/netui/src/util/build.xml
    beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/bean/NetUIConfig.java
    beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/internal/beehive-netui-config-default.xml
    beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/parser/NetUIConfigParser.java
    beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/schema/beehive-netui-config.xsd
    beehive/trunk/netui/test/ant/build.xml
    beehive/trunk/netui/test/dist-test/build.xml
    beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/tools/AssertHelper.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/SchemaValidationTest.java
    beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/util/config/TestConfigUtil.java

Modified: beehive/trunk/netui/build.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/build.xml?rev=385838&r1=385837&r2=385838&view=diff
==============================================================================
--- beehive/trunk/netui/build.xml (original)
+++ beehive/trunk/netui/build.xml Tue Mar 14 09:17:31 2006
@@ -94,20 +94,37 @@
     <!-- Test targets                                                  -->
     <!--                                                               -->
     <!-- ============================================================= -->
-    <target name="drt" description="Runs the NetUI DRTs">
-        <echo message="--------------------------------------------------"/>
-        <echo message="|      NetUI DRT starting                        |"/>
-        <echo message="--------------------------------------------------"/>
-
-        <!-- run the JUnit DRTs -->
+    <target name="drt.junit" description="Run the JUnit DRTs">
         <ant dir="${basedir}/test/ant/" target="drt" inheritAll="false">
             <property name="drt.cc.mode" value="true"/>
         </ant>
+    </target>
+
+    <target name="bvt.junit" description="Run the JUnit BVTs">
+        <ant dir="${basedir}/test/ant/" target="bvt" inheritAll="false">
+            <property name="drt.cc.mode" value="true"/>
+        </ant>
+    </target>
 
-        <!-- run the server DRTs -->
+    <target name="drt.server" description="Run the NetUI server tests">
         <ant dir="${beehive.home}/netui/test/webapps/drt" antfile="build.xml" target="drt" inheritAll="false">
             <property name="drt.cc.mode" value="true"/>
         </ant>
+    </target>
+
+    <target name="bvt.server" description="Run the NetUI server tests">
+        <ant dir="${beehive.home}/netui/test/webapps/drt" antfile="build.xml" target="bvt" inheritAll="false">
+            <property name="drt.cc.mode" value="true"/>
+        </ant>
+    </target>
+
+    <target name="drt" description="Runs the NetUI DRTs">
+        <echo message="--------------------------------------------------"/>
+        <echo message="|      NetUI DRT starting                        |"/>
+        <echo message="--------------------------------------------------"/>
+
+        <antcall target="drt.junit"/>
+        <antcall target="drt.server"/>
 
         <echo message="--------------------------------------------------"/>
         <echo message="|      NetUI DRT ending                          |"/>
@@ -119,15 +136,8 @@
         <echo message="|      NetUI BVT starting                        |"/>
         <echo message="--------------------------------------------------"/>
 
-        <!-- run the JUnit BVTs -->
-        <ant dir="test/ant" target="bvt" inheritAll="false">
-            <property name="drt.cc.mode" value="true"/>
-        </ant>
-
-        <!-- run the server BVTs -->
-        <ant dir="${beehive.home}/netui/test/webapps/drt" antfile="build.xml" target="bvt" inheritAll="false">
-            <property name="drt.cc.mode" value="true"/>
-        </ant>
+        <antcall target="bvt.junit"/>
+        <antcall target="bvt.server"/>
 
         <echo message="--------------------------------------------------"/>
         <echo message="|      NetUI BVT ending                          |"/>
@@ -217,7 +227,6 @@
             </fileset>
         </copy>
         <filter token="beehive.version" value="${beehive.version}"/>
-        <copy todir="${build.m2.dir}/beehive-netui-compiler/${beehive.version}" file="src/compiler-apt/maven-metadata.xml" filtering="true"/>
         <copy todir="${build.m2.dir}/beehive-netui-compiler/${beehive.version}" filtering="true">
             <mapper type="glob" from="*.pom" to="*-${beehive.version}.pom"/>
             <fileset dir="src/compiler-apt" includes="beehive-netui-compiler.pom"/>
@@ -234,7 +243,6 @@
             </fileset>
         </copy>
         <filter token="beehive.version" value="${beehive.version}"/>
-        <copy todir="${build.m2.dir}/beehive-netui-core/${beehive.version}" file="src/pageflow/maven-metadata.xml" filtering="true"/>
         <copy todir="${build.m2.dir}/beehive-netui-core/${beehive.version}" filtering="true">
             <mapper type="glob" from="*.pom" to="*-${beehive.version}.pom"/>
             <fileset dir="src/pageflow" includes="beehive-netui-core.pom"/>
@@ -253,7 +261,6 @@
             </fileset>
         </copy>
         <filter token="beehive.version" value="${beehive.version}"/>
-        <copy todir="${build.m2.dir}/beehive-netui-tags/${beehive.version}" file="src/tags-html/maven-metadata.xml" filtering="true"/>
         <copy todir="${build.m2.dir}/beehive-netui-tags/${beehive.version}" filtering="true">
             <mapper type="glob" from="*.pom" to="*-${beehive.version}.pom"/>
             <fileset dir="src/tags-html" includes="beehive-netui-tags.pom"/>

Modified: beehive/trunk/netui/netui-imports.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/netui-imports.xml?rev=385838&r1=385837&r2=385838&view=diff
==============================================================================
--- beehive/trunk/netui/netui-imports.xml (original)
+++ beehive/trunk/netui/netui-imports.xml Tue Mar 14 09:17:31 2006
@@ -48,6 +48,10 @@
 
     <property name="struts.dependency.path.ref" value="struts12.dependency.path"/>
 
+    <path id="commons-beanutils.dependency.path">
+        <fileset file="${beehive.home}/netui/external/struts/commons-beanutils.jar"/>
+    </path>
+
     <!-- <path> structures used by clients needing to reference sets of related JARs -->
     <path id="struts11.dependency.path">
         <fileset dir="${struts11.dir}">

Modified: beehive/trunk/netui/src/core/build.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/core/build.xml?rev=385838&r1=385837&r2=385838&view=diff
==============================================================================
--- beehive/trunk/netui/src/core/build.xml (original)
+++ beehive/trunk/netui/src/core/build.xml Tue Mar 14 09:17:31 2006
@@ -11,6 +11,7 @@
         <path refid="servlet.dependency.path"/>
         <path refid="commons-codec.dependency.path"/>
         <path refid="commons-logging.dependency.path"/>
+        <path refid="commons-beanutils.dependency.path"/>
         <pathelement path="${classes.dir}/util"/>
         <pathelement path="${classes.dir}/scoping"/>
     </path>

Added: beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Catalog.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Catalog.java?rev=385838&view=auto
==============================================================================
--- beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Catalog.java (added)
+++ beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Catalog.java Tue Mar 14 09:17:31 2006
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2006 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.core.chain;
+
+import java.util.Iterator;
+
+/**
+ * <p>
+ * A Catalog is a collection of {@link Command}s or {@link Chain}s.  It is used as a convenience
+ * for organizing sets of {@link Command}s together.
+ * </p>
+ */
+public interface Catalog {
+
+    void addCommand(String name, Command command);
+
+    Command getCommand(String name);
+
+    Iterator getNames();
+}

Added: beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/CatalogFactory.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/CatalogFactory.java?rev=385838&view=auto
==============================================================================
--- beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/CatalogFactory.java (added)
+++ beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/CatalogFactory.java Tue Mar 14 09:17:31 2006
@@ -0,0 +1,141 @@
+/*
+ * Copyright 2006 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.core.chain;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.List;
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.beehive.netui.core.chain.impl.CatalogFactoryBase;
+import org.apache.beehive.netui.core.chain.impl.CatalogBase;
+import org.apache.beehive.netui.core.chain.impl.ChainBase;
+import org.apache.beehive.netui.util.config.bean.CatalogConfig;
+import org.apache.beehive.netui.util.config.bean.ChainConfig;
+import org.apache.beehive.netui.util.config.bean.CommandConfig;
+import org.apache.beehive.netui.util.config.bean.CustomPropertyConfig;
+import org.apache.commons.beanutils.BeanUtils;
+
+/**
+ * Abstract factory class for configuring a {@link Catalog} of {@link Command}s in a chain.
+ */
+public abstract class CatalogFactory {
+
+    private static Map FACTORIES = new HashMap();
+
+    public abstract void setCatalog(Catalog catalog);
+
+    public abstract Catalog getCatalog();
+
+    public abstract Catalog getCatalog(String name);
+
+    public abstract void addCatalog(String name, Catalog catalog);
+
+    public static CatalogFactory getInstance() {
+        CatalogFactory catalogFactory = null;
+        ClassLoader classLoader = getClassLoader();
+        synchronized(FACTORIES) {
+            catalogFactory = (CatalogFactory)FACTORIES.get(classLoader);
+            if(catalogFactory == null) {
+                catalogFactory = new CatalogFactoryBase();
+                FACTORIES.put(classLoader, catalogFactory);
+            }
+        }
+        return catalogFactory;
+    }
+
+    public static CatalogFactory getInstance(CatalogConfig catalogConfig) {
+
+        if(catalogConfig == null)
+            return null;
+
+        CatalogFactory catalogFactory = getInstance();
+        assert catalogFactory != null;
+        Catalog catalog = new CatalogBase();
+        List chainConfigs = catalogConfig.getCommands();
+        for(int i = 0; i < chainConfigs.size(); i++) {
+            CommandConfig commandConfig = (CommandConfig)chainConfigs.get(i);
+            assert commandConfig != null;
+
+            if(commandConfig instanceof ChainConfig) {
+                ChainConfig chainConfig = (ChainConfig)commandConfig;
+                Chain chain = new ChainBase();
+
+                List commandConfigs = chainConfig.getCommands();
+                for(int j = 0; j < commandConfigs.size(); j++) {
+                    CommandConfig chainCommandConfig = (CommandConfig)commandConfigs.get(j);
+                    Command command = createCommand(chainCommandConfig);
+                    chain.addCommand(command);
+                }
+                catalog.addCommand(chainConfig.getName(), chain);
+            }
+            else {
+                Command command = createCommand(commandConfig);
+                catalog.addCommand(commandConfig.getName(), command);
+            }
+        }
+        catalogFactory.setCatalog(catalog);
+        return catalogFactory;
+    }
+
+    private static Command createCommand(CommandConfig commandConfig) {
+        Command command = null;
+        try {
+            Class commandClass = Class.forName(commandConfig.getClassname(), true, getClassLoader());
+            if (!Command.class.isAssignableFrom(commandClass))
+                throw new RuntimeException("Created command that is not a command class");
+
+            command = (Command) commandClass.newInstance();
+        }
+        catch (IllegalAccessException e) {
+            throw new RuntimeException("Problem occurred creating Chain.  Cause: " + e, e);
+        }
+        catch (InstantiationException e) {
+            throw new RuntimeException("Problem occurred creating Chain.  Cause: " + e, e);
+        }
+        catch (ClassNotFoundException e) {
+            throw new RuntimeException("Problem occurred creating Chain.  Cause: " + e, e);
+        }
+
+        List propertyConfigs = commandConfig.getParameters();
+        for(int k = 0; k < propertyConfigs.size(); k++) {
+            CustomPropertyConfig customPropertyConfig = (CustomPropertyConfig)propertyConfigs.get(k);
+            assert customPropertyConfig.getName() != null;
+            assert customPropertyConfig.getValue() != null;
+
+            try {
+                BeanUtils.setProperty(command,  customPropertyConfig.getName(), customPropertyConfig.getValue());
+            }
+            catch (IllegalAccessException e) {
+                throw new RuntimeException("Problem occurred setting property on Command.  Cause: " + e, e);
+            }
+            catch (InvocationTargetException e) {
+                throw new RuntimeException("Problem occurred setting property on Command.  Cause: " + e, e);
+            }
+
+        }
+        return command;
+    }
+
+    private static ClassLoader getClassLoader() {
+        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+        if(classLoader == null)
+             classLoader = CatalogFactory.class.getClassLoader();
+        return classLoader;
+    }
+}

Added: beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Chain.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Chain.java?rev=385838&view=auto
==============================================================================
--- beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Chain.java (added)
+++ beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Chain.java Tue Mar 14 09:17:31 2006
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2006 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.core.chain;
+
+/**
+ * <p>
+ * An implementation of the Chain of Responsibility pattern that chains {@link Command}s together.
+ * </p>
+ */
+public interface Chain
+    extends Command {
+
+    void addCommand(Command command);
+
+    Command[] getCommands();
+}

Added: beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Command.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Command.java?rev=385838&view=auto
==============================================================================
--- beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Command.java (added)
+++ beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Command.java Tue Mar 14 09:17:31 2006
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2006 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.core.chain;
+
+/**
+ * <p>
+ * An encapsulation for a unit of work that needs to performed to accomplish a task.
+ * A Command chooses whether to execute based on the information available to it in
+ * the {@link Context}.
+ * </p> 
+ */
+public interface Command {
+
+    boolean execute(Context context) throws Exception;
+}

Added: beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Context.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Context.java?rev=385838&view=auto
==============================================================================
--- beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Context.java (added)
+++ beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/Context.java Tue Mar 14 09:17:31 2006
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2006 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.core.chain;
+
+import java.util.Map;
+
+/**
+ * <p>
+ * Marker interface that extends {@link Map} to provide key / value pairs of contextual
+ * information when executing a chain of commands.
+ * </p>
+ */
+public interface Context
+    extends Map {
+}

Added: beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/CatalogBase.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/CatalogBase.java?rev=385838&view=auto
==============================================================================
--- beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/CatalogBase.java (added)
+++ beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/CatalogBase.java Tue Mar 14 09:17:31 2006
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2006 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.core.chain.impl;
+
+import java.util.Iterator;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.beehive.netui.core.chain.Catalog;
+import org.apache.beehive.netui.core.chain.Command;
+
+/**
+ * 
+ */
+public class CatalogBase
+    implements Catalog {
+
+    private ConcurrentHashMap _commands = new ConcurrentHashMap();
+
+    public void addCommand(String name, Command command) {
+        _commands.put(name, command);
+    }
+
+    public Command getCommand(String name) {
+        return (Command)_commands.get(name);
+    }
+
+    public Iterator getNames() {
+        return _commands.keySet().iterator();
+    }
+
+    public String toString() {
+        StringBuilder stringBuilder = new StringBuilder();
+        stringBuilder.append("[").append(getClass().getName()).append(": ");
+        Iterator names = _commands.keySet().iterator();
+        while(names.hasNext()) {
+            stringBuilder.append(names.next());
+            if(names.hasNext())
+                stringBuilder.append(",");
+        }
+        stringBuilder.append("]");
+        return stringBuilder.toString();
+    }
+}

Added: beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/CatalogFactoryBase.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/CatalogFactoryBase.java?rev=385838&view=auto
==============================================================================
--- beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/CatalogFactoryBase.java (added)
+++ beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/CatalogFactoryBase.java Tue Mar 14 09:17:31 2006
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2006 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.core.chain.impl;
+
+import java.util.HashMap;
+
+import org.apache.beehive.netui.core.chain.CatalogFactory;
+import org.apache.beehive.netui.core.chain.Catalog;
+
+/**
+ * <p>
+ * This is a simple {@link CatalogFactory} implementation that supports a two step lifecycle
+ * where {@link Catalog}s are added and can then be retrieved.  Once reading of catalogs starts,
+ * no more catalogs can be added.  This avoids an unnecessary synchronization point
+ * for every catalog access and makes Catalog lookups fast.
+ * </p>
+ */
+public class CatalogFactoryBase
+    extends CatalogFactory {
+
+    private boolean _locked = false;
+    private Catalog _defaultCatalog;
+    private HashMap _catalogs = new HashMap();
+
+    public void setCatalog(Catalog catalog) {
+        _defaultCatalog = catalog;
+    }
+
+    public Catalog getCatalog() {
+        return _defaultCatalog;
+    }
+
+    public void addCatalog(String name, Catalog catalog) {
+        if(_locked)
+            throw new IllegalStateException();
+
+        synchronized(_catalogs) {
+            _catalogs.put(name, catalog);
+        }
+    }
+
+    public Catalog getCatalog(String name) {
+        _locked = true;
+        return (Catalog)_catalogs.get(name);
+    }
+}

Added: beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/ChainBase.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/ChainBase.java?rev=385838&view=auto
==============================================================================
--- beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/ChainBase.java (added)
+++ beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/ChainBase.java Tue Mar 14 09:17:31 2006
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2006 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.core.chain.impl;
+
+import org.apache.beehive.netui.core.chain.Chain;
+import org.apache.beehive.netui.core.chain.Command;
+import org.apache.beehive.netui.core.chain.Context;
+
+/**
+ *
+ */
+public class ChainBase
+    implements Chain {
+
+    private Command[] _commands = new Command[0];
+    private boolean _frozen;
+
+    public ChainBase() {
+    }
+
+    /**
+     * Add a command to the chian.
+     * @param command the new command
+     */
+    public void addCommand(Command command) {
+        if(command == null)
+            throw new IllegalArgumentException();
+
+        if(_frozen)
+            throw new IllegalStateException();
+
+        Command[] results = new Command[_commands.length + 1];
+        System.arraycopy(_commands, 0, results, 0, _commands.length);
+        results[_commands.length] = command;
+        _commands = results;
+    }
+
+    public Command[] getCommands() {
+        return _commands;
+    }
+
+    /**
+     * Execute the chain using the provided {@link Context}.
+     * 
+     * @param context
+     * @return
+     * @throws Exception
+     */
+    public boolean execute(Context context)
+     throws Exception {
+        if(context == null)
+            throw new IllegalArgumentException();
+
+        if(!_frozen)
+            _frozen = true;
+
+        boolean result = false;
+        Exception saveException = null;
+        for(int i = 0; i < _commands.length; i++) {
+            try {
+                result = _commands[i].execute(context);
+                if(result)
+                    break;
+            }
+            catch(Exception e) {
+                saveException = e;
+            }
+        }
+
+        if(saveException != null)
+            throw saveException;
+        else return result;
+    }
+}

Added: beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/ContextBase.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/ContextBase.java?rev=385838&view=auto
==============================================================================
--- beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/ContextBase.java (added)
+++ beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/impl/ContextBase.java Tue Mar 14 09:17:31 2006
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2006 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.core.chain.impl;
+
+import java.util.Set;
+import java.util.HashMap;
+
+import org.apache.beehive.netui.core.chain.Context;
+
+/**
+ */
+public class ContextBase
+    extends HashMap
+    implements Context {
+
+    public Set entrySet() {
+        return super.entrySet();
+    }
+}

Added: beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/web/WebChainContext.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/web/WebChainContext.java?rev=385838&view=auto
==============================================================================
--- beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/web/WebChainContext.java (added)
+++ beehive/trunk/netui/src/core/org/apache/beehive/netui/core/chain/web/WebChainContext.java Tue Mar 14 09:17:31 2006
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2006 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.core.chain.web;
+
+import java.util.HashMap;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletResponse;
+import javax.servlet.ServletRequest;
+
+import org.apache.beehive.netui.core.chain.Context;
+
+/**
+ * 
+ */
+public class WebChainContext
+    extends HashMap
+    implements Context {
+
+    private ServletContext _servletContext;
+    private ServletRequest _servletRequest;
+    private ServletResponse _servletResponse;
+
+    public WebChainContext() {
+    }
+
+    public WebChainContext(ServletContext servletContext,
+                           ServletRequest servletRequest,
+                           ServletResponse servletResponse)
+    {
+        _servletContext = servletContext;
+        _servletRequest = servletRequest;
+        _servletResponse = servletResponse;
+    }
+
+    public ServletContext getServletContext() {
+        return _servletContext;
+    }
+
+    public void setServletContext(ServletContext servletContext) {
+        _servletContext = servletContext;
+    }
+
+    public ServletRequest getServletRequest() {
+        return _servletRequest;
+    }
+
+    public void setServletRequest(ServletRequest servletRequest) {
+        _servletRequest = servletRequest;
+    }
+
+    public ServletResponse getServletResponse() {
+        return _servletResponse;
+    }
+
+    public void setServletResponse(ServletResponse servletResponse) {
+        _servletResponse = servletResponse;
+    }
+}

Modified: beehive/trunk/netui/src/core/org/apache/beehive/netui/core/urls/AjaxUrlInfo.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/core/org/apache/beehive/netui/core/urls/AjaxUrlInfo.java?rev=385838&r1=385837&r2=385838&view=diff
==============================================================================
--- beehive/trunk/netui/src/core/org/apache/beehive/netui/core/urls/AjaxUrlInfo.java (original)
+++ beehive/trunk/netui/src/core/org/apache/beehive/netui/core/urls/AjaxUrlInfo.java Tue Mar 14 09:17:31 2006
@@ -1,3 +1,20 @@
+/*
+ * 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.core.urls;
 
 /**

Modified: beehive/trunk/netui/src/util/build.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/util/build.xml?rev=385838&r1=385837&r2=385838&view=diff
==============================================================================
--- beehive/trunk/netui/src/util/build.xml (original)
+++ beehive/trunk/netui/src/util/build.xml Tue Mar 14 09:17:31 2006
@@ -12,7 +12,6 @@
         <path refid="log4j.dependency.path"/>
         <path refid="commons-codec.dependency.path"/>
         <path refid="commons-logging.dependency.path"/>
-        <pathelement path="${classes.dir}/scoping"/>
     </path>
 
     <target name="build">
@@ -34,7 +33,7 @@
 
         <copy todir="${classes.dir}/${module.name}">
             <fileset dir="${module.dir}" includes="**/*.properties"/>
-            <fileset dir="${module.dir}" includes="**/config/schema/*.xsd"/>
+            <fileset dir="${module.dir}" includes="**/*.xsd"/>
             <fileset dir="${module.dir}" includes="**/config/internal/*.xml"/>
         </copy>
     </target>

Added: beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/bean/CatalogConfig.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/bean/CatalogConfig.java?rev=385838&view=auto
==============================================================================
--- beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/bean/CatalogConfig.java (added)
+++ beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/bean/CatalogConfig.java Tue Mar 14 09:17:31 2006
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2006 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.bean;
+
+import java.util.List;
+import java.util.LinkedList;
+
+/**
+ *
+ */
+public class CatalogConfig {
+
+    private String _name = null;
+    private LinkedList _chains;
+
+    public CatalogConfig() {
+        _chains = new LinkedList();
+    }
+
+    public void addCommand(CommandConfig commandConfig) {
+        _chains.add(commandConfig);
+    }
+
+    public List getCommands() {
+        return _chains;
+    }
+
+    public String getName() {
+        return _name;
+    }
+
+    public void setName(String name) {
+        _name = name;
+    }
+}

Added: beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/bean/ChainConfig.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/bean/ChainConfig.java?rev=385838&view=auto
==============================================================================
--- beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/bean/ChainConfig.java (added)
+++ beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/bean/ChainConfig.java Tue Mar 14 09:17:31 2006
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2006 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.bean;
+
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ *
+ */
+public class ChainConfig
+    extends CommandConfig {
+
+    private String _name = null;
+    private LinkedList _commands = null;
+
+    public ChainConfig() {
+        _commands = new LinkedList();
+    }
+
+    public void addCommand(CommandConfig commandConfig) {
+        _commands.add(commandConfig);
+    }
+
+    public List getCommands() {
+        return _commands;
+    }
+
+    public void setCommands(List commands) {
+        _commands.clear();
+        _commands.addAll(commands);
+    }
+
+    public String getName() {
+        return _name;
+    }
+
+    public void setName(String name) {
+        _name = name;
+    }
+}

Added: beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/bean/CommandConfig.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/bean/CommandConfig.java?rev=385838&view=auto
==============================================================================
--- beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/bean/CommandConfig.java (added)
+++ beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/bean/CommandConfig.java Tue Mar 14 09:17:31 2006
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2006 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.bean;
+
+import java.util.LinkedList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ *
+ */
+public class CommandConfig {
+
+    private String _name;
+    private String _id;
+    private String _classname;
+    private LinkedList _parameters;
+
+    public CommandConfig() {
+        _parameters = new LinkedList();
+    }
+
+    public void addParameter(CustomPropertyConfig customParameterConfig) {
+        _parameters.add(customParameterConfig);
+    }
+
+    public String getId() {
+        return _id;
+    }
+
+    public void setId(String id) {
+        _id = id;
+    }
+
+    public String getName() {
+        return _name;
+    }
+
+    public void setName(String name) {
+        _name = name;
+    }
+
+    public String getClassname() {
+        return _classname;
+    }
+
+    public void setClassname(String classname) {
+        _classname = classname;
+    }
+
+    public List getParameters() {
+        return _parameters != null ? _parameters : Collections.EMPTY_LIST;
+    }
+
+    public void setParameters(List parameters) {
+        _parameters.clear();
+        _parameters.addAll(parameters);
+    }
+}
\ No newline at end of file

Modified: beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/bean/NetUIConfig.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/bean/NetUIConfig.java?rev=385838&r1=385837&r2=385838&view=diff
==============================================================================
--- beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/bean/NetUIConfig.java (original)
+++ beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/bean/NetUIConfig.java Tue Mar 14 09:17:31 2006
@@ -34,6 +34,9 @@
     private IteratorFactoryConfig[] _iteratorFactories;
     private TypeConverterConfig[] _typeConverters;
     private UrlConfig _urlConfig;
+    private CatalogConfig _catalogConfig;
+
+    private boolean _locked = false;
 
     public NetUIConfig(PageFlowActionInterceptorsConfig pageFlowActionInterceptors,
                        PageFlowHandlersConfig pageFlowHandlers,
@@ -61,6 +64,10 @@
         _urlConfig = urlConfig;
     }
 
+    public void lock() {
+        _locked = true;
+    }
+
     public PageFlowActionInterceptorsConfig getPageFlowActionInterceptors() {
         return _pageFlowActionInterceptors;
     }
@@ -107,5 +114,20 @@
 
     public UrlConfig getUrlConfig() {
         return _urlConfig;
+    }
+
+    public CatalogConfig getCatalogConfig() {
+        return _catalogConfig;
+    }
+
+    public void setCatalogConfig(CatalogConfig catalogConfig) {
+        ensureUnlocked();
+
+        _catalogConfig = catalogConfig;
+    }
+
+    private void ensureUnlocked() {
+        if(_locked)
+            throw new IllegalStateException("Unable to modify locked NetUI framework configuration.");
     }
 }

Modified: beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/internal/beehive-netui-config-default.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/internal/beehive-netui-config-default.xml?rev=385838&r1=385837&r2=385838&view=diff
==============================================================================
--- beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/internal/beehive-netui-config-default.xml (original)
+++ beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/internal/beehive-netui-config-default.xml Tue Mar 14 09:17:31 2006
@@ -1,7 +1,27 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
-<netui-config xmlns="http://beehive.apache.org/netui/2004/server/config">
+<!--
+   Copyright 2004-2006 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:$
+ -->
+
+<!--
+  This file defines the default, OOTB required runtime configuration for the NetUI framework
+-->
+<netui-config xmlns="http://beehive.apache.org/netui/2004/server/config">
     <expression-languages>
         <default-language>netuiel</default-language>
         <expression-language>
@@ -10,17 +30,6 @@
         </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>
@@ -40,5 +49,10 @@
         </prefix-handler>
     </prefix-handlers>
 
-</netui-config>
-
+    <catalog>
+        <chain name="xhr-servlet">
+            <command classname="org.apache.beehive.netui.tags.tree.TreeCRI"/>
+            <command classname="org.apache.beehive.netui.tags.divpanel.DivPanelCRI"/>
+        </chain>
+    </catalog>
+</netui-config>
\ No newline at end of file

Added: beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/internal/catalog/CatalogParser.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/internal/catalog/CatalogParser.java?rev=385838&view=auto
==============================================================================
--- beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/internal/catalog/CatalogParser.java (added)
+++ beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/internal/catalog/CatalogParser.java Tue Mar 14 09:17:31 2006
@@ -0,0 +1,176 @@
+package org.apache.beehive.netui.util.config.internal.catalog;
+
+import java.io.InputStream;
+import java.io.IOException;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.beehive.netui.util.config.bean.CatalogConfig;
+import org.apache.beehive.netui.util.config.bean.CommandConfig;
+import org.apache.beehive.netui.util.config.bean.ChainConfig;
+import org.apache.beehive.netui.util.config.bean.CustomPropertyConfig;
+import org.apache.beehive.netui.util.xml.DomUtils;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.logging.Log;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Node;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.InputSource;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.SAXException;
+
+/**
+ *
+ */
+public class CatalogParser {
+
+    private static final Log LOG = LogFactory.getLog(CatalogParser.class);
+    private static final String CONFIG_SCHEMA = "org/apache/beehive/netui/util/config/internal/catalog/catalog-config.xsd";
+    private static final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
+    private static final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
+    private static final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
+
+    public static CatalogParser getInstance() {
+        return new CatalogParser();
+    }
+
+    private CatalogParser() {
+    }
+
+    public CatalogConfig parse(Element catalogElement) {
+        return parseCatalog(catalogElement);
+    }
+
+    public CatalogConfig parse(final String resourcePath, final InputStream inputStream) {
+        CatalogConfig catalogConfig = null;
+        InputStream xmlInputStream = null;
+        InputStream xsdInputStream = null;
+        try {
+            xmlInputStream = inputStream;
+            xsdInputStream = getClass().getClassLoader().getResourceAsStream(CONFIG_SCHEMA);
+
+            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+            dbf.setValidating(true);
+            dbf.setNamespaceAware(true);
+            dbf.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
+            dbf.setAttribute(JAXP_SCHEMA_SOURCE, xsdInputStream);
+
+            DocumentBuilder db = dbf.newDocumentBuilder();
+            db.setErrorHandler(new ErrorHandler() {
+                public void warning(SAXParseException exception) {
+                    LOG.info("Validation warning validating config file \"" + resourcePath +
+                            "\" against XML Schema \"" + CONFIG_SCHEMA);
+                }
+
+                public void error(SAXParseException exception) {
+                        throw new RuntimeException("Validation errors occurred parsing the config file \"" +
+                            resourcePath + "\".  Cause: " + exception, exception);
+                }
+
+                public void fatalError(SAXParseException exception) {
+                    throw new RuntimeException("Validation errors occurred parsing the config file \"" +
+                        resourcePath + "\".  Cause: " + exception, exception);
+                }
+            });
+
+            db.setEntityResolver(new EntityResolver() {
+                public InputSource resolveEntity(String publicId, String systemId) {
+                    if(systemId.endsWith("/chain-config.xsd")) {
+                        InputStream inputStream = getClass().getClassLoader().getResourceAsStream(CONFIG_SCHEMA);
+                        return new InputSource(inputStream);
+                    }
+                    else return null;
+                }
+            });
+
+            Document document = db.parse(xmlInputStream);
+            Element catalogElement = document.getDocumentElement();
+            catalogConfig = parse(catalogElement);
+
+        }
+        catch(ParserConfigurationException e) {
+            throw new RuntimeException("Error occurred parsing the config file \"" + resourcePath + "\"", e);
+        }
+        catch(IOException e) {
+            throw new RuntimeException("Error occurred parsing the config file \"" + resourcePath + "\"", e);
+        }
+        catch(SAXException e) {
+            throw new RuntimeException("Error occurred parsing the config file \"" + resourcePath + "\"", e);
+        }
+        finally {
+            try{if(xsdInputStream != null) xsdInputStream.close();}
+            catch(IOException e) {}
+        }
+
+        return catalogConfig;
+    }
+
+    private static CatalogConfig parseCatalog(Element catalogElement) {
+        CatalogConfig catalogConfig = null;
+        if(catalogElement != null && catalogElement.hasChildNodes()) {
+            catalogConfig = new CatalogConfig();
+            NodeList nodeList = catalogElement.getChildNodes();
+            if(nodeList != null) {
+                for(int i = 0; i < nodeList.getLength(); i++) {
+                    Node node = nodeList.item(i);
+                    if(!(node.getNodeType() == Node.ELEMENT_NODE))
+                        continue;
+
+                    if(node.getNodeName().equals("chain")) {
+                        Element element = (Element)node;
+                        String name = element.getAttribute("name");
+                        ChainConfig chainConfig = new ChainConfig();
+                        chainConfig.setName(name);
+
+                        NodeList commandList = element.getElementsByTagName("command");
+                        if(commandList != null) {
+                            for(int j = 0; j < commandList.getLength(); j++) {
+                                Element commandElement = (Element)commandList.item(j);
+                                CommandConfig commandConfig = parseCommand(commandElement);
+                                chainConfig.addCommand(commandConfig);
+                            }
+                        }
+                        catalogConfig.addCommand(chainConfig);
+                    }
+                    else if(node.getNodeName().equals("command")) {
+                        Element element = (Element)node;
+                        String name = element.getAttribute("name");
+                        CommandConfig commandConfig = parseCommand(element);
+                        commandConfig.setName(name);
+                        catalogConfig.addCommand(commandConfig);
+                    }
+                }
+            }
+        }
+
+        return catalogConfig;
+    }
+
+    private static CommandConfig parseCommand(Element element) {
+        assert element != null;
+        assert element.getNodeName().equals("command");
+
+        CommandConfig commandConfig = new CommandConfig();
+        String id = element.getAttribute("id");
+        String classname = element.getAttribute("classname");
+        commandConfig.setId(id);
+        commandConfig.setClassname(classname);
+
+        NodeList propertyList = element.getElementsByTagName("custom-property");
+        if(propertyList != null) {
+            for(int k = 0; k < propertyList.getLength(); k++) {
+                Element propertyElement = (Element)propertyList.item(k);
+                String propName = DomUtils.getChildElementText(propertyElement, "name");
+                String propValue = DomUtils.getChildElementText(propertyElement, "value");
+                CustomPropertyConfig propertyConfig = new CustomPropertyConfig(propName, propValue);
+                commandConfig.addParameter(propertyConfig);
+            }
+        }
+
+        return commandConfig;
+    }
+}

Added: beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/internal/catalog/catalog-config.xsd
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/internal/catalog/catalog-config.xsd?rev=385838&view=auto
==============================================================================
--- beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/internal/catalog/catalog-config.xsd (added)
+++ beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/internal/catalog/catalog-config.xsd Tue Mar 14 09:17:31 2006
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Copyright 2006 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:$
+-->
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+            targetNamespace="http://beehive.apache.org/netui/2004/server/config"
+            xmlns:netui="http://beehive.apache.org/netui/2004/server/config"
+            elementFormDefault="qualified">
+
+    <xsd:element name="catalog">
+        <xsd:complexType>
+            <xsd:sequence>
+                <xsd:element name="chain" type="netui:chain" minOccurs="0" maxOccurs="unbounded"/>
+                <xsd:element name="command" type="netui:command" minOccurs="0" maxOccurs="unbounded"/>
+            </xsd:sequence>
+            <xsd:attribute name="name" type="xsd:string"/>
+        </xsd:complexType>
+    </xsd:element>
+
+    <xsd:complexType name="chain">
+        <xsd:sequence>
+            <xsd:element name="command" type="netui:command" minOccurs="0" maxOccurs="unbounded"/>
+        </xsd:sequence>
+        <xsd:attribute name="name" type="xsd:string"/>
+    </xsd:complexType>
+
+    <xsd:complexType name="command">
+        <xsd:sequence>
+            <xsd:element name="custom-property" type="netui:custom-property" minOccurs="0" maxOccurs="unbounded"/>
+        </xsd:sequence>
+        <xsd:attribute name="id" type="xsd:string"/>
+        <xsd:attribute name="name" type="xsd:string"/>
+        <xsd:attribute name="classname" type="xsd:string"/>
+    </xsd:complexType>
+
+    <xsd:complexType name="custom-property">
+        <xsd:sequence>
+            <xsd:element name="name" type="xsd:string" minOccurs="1" maxOccurs="1"/>
+            <xsd:element name="value" type="xsd:string" minOccurs="1" maxOccurs="1"/>
+        </xsd:sequence>
+    </xsd:complexType>
+    
+</xsd:schema>

Modified: 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=385838&r1=385837&r2=385838&view=diff
==============================================================================
--- beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/parser/NetUIConfigParser.java (original)
+++ beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/parser/NetUIConfigParser.java Tue Mar 14 09:17:31 2006
@@ -23,7 +23,11 @@
 import java.io.InputStream;
 import java.io.IOException;
 import java.util.List;
+import java.util.LinkedList;
 
+import org.apache.beehive.netui.util.config.bean.CatalogConfig;
+import org.apache.beehive.netui.util.config.bean.ChainConfig;
+import org.apache.beehive.netui.util.config.bean.CommandConfig;
 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;
@@ -56,6 +60,7 @@
 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.apache.beehive.netui.util.config.internal.catalog.CatalogParser;
 import org.w3c.dom.Document;
 import org.w3c.dom.NodeList;
 import org.w3c.dom.Element;
@@ -66,6 +71,11 @@
 import org.xml.sax.ErrorHandler;
 import org.xml.sax.SAXParseException;
 
+/**
+ * <p>
+ * Parser for converting an XML document into a NetUIConfig object.
+ * </p>
+ */
 public final class NetUIConfigParser {
 
     private static final Logger LOGGER = Logger.getInstance(NetUIConfigParser.class);
@@ -110,11 +120,9 @@
                 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.");
+                LOGGER.info("Loading the default NetUI config file.  The runtime will be configured " +
+                    "with a set of minimum parameters.");
 
-                /* 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.");
@@ -195,6 +203,9 @@
             IteratorFactoryConfig[] iteratorFactories = parseIteratorFactoryConfig(document);
             PrefixHandlerConfig[] prefixHandlers = parsePrefixHandlerConfig(document);
 
+            Element catalogElement = DomUtils.getChildElementByName(document.getDocumentElement(), "catalog");
+            CatalogConfig catalogConfig = parseCatalogs(catalogElement);
+
             netuiConfig = new NetUIConfig(
                 pfActionInterceptorsConfig,
                 pfHandlersConfig,
@@ -209,6 +220,7 @@
                 typeConvertersConfig,
                 urlConfig
                 );
+            netuiConfig.setCatalogConfig(catalogConfig);
         }
         catch(ParserConfigurationException e) {
             throw new ConfigInitializationException("Error occurred parsing the config file \"" + resourcePath + "\"", e);
@@ -678,5 +690,14 @@
             );
         }
         else return null;
+    }
+
+    /*
+    -----------------------------------------------------------------------------------
+        Parsing support: <catalogs>
+    ----------------------------------------------------------------------------------
+     */
+    private static CatalogConfig parseCatalogs(Element catalogElement) {
+        return CatalogParser.getInstance().parse(catalogElement);
     }
 }

Modified: beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/schema/beehive-netui-config.xsd
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/schema/beehive-netui-config.xsd?rev=385838&r1=385837&r2=385838&view=diff
==============================================================================
--- beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/schema/beehive-netui-config.xsd (original)
+++ beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/schema/beehive-netui-config.xsd Tue Mar 14 09:17:31 2006
@@ -1,5 +1,27 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
+<!--
+   Copyright 2004-2006 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:$
+ -->
+
+<!--
+  This file defines the shape of the NetUI framework XML configuration file.  If defined, this file should
+  be placed in a web application's WEB-INF/beehive-netui-config.xml file.
+-->
 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             targetNamespace="http://beehive.apache.org/netui/2004/server/config"
             xmlns:netui="http://beehive.apache.org/netui/2004/server/config"
@@ -20,6 +42,7 @@
                 <xsd:element name="iterator-factories" type="netui:iterator-factories" minOccurs="0" maxOccurs="1"/>
                 <xsd:element name="request-interceptors" type="netui:request-interceptors" minOccurs="0" maxOccurs="1"/>
                 <xsd:element name="prefix-handlers" type="netui:prefix-handlers" minOccurs="0" maxOccurs="1" />
+                <xsd:element name="catalog" type="netui:catalog" minOccurs="0" maxOccurs="1"/>
             </xsd:sequence>
         </xsd:complexType>
     </xsd:element>
@@ -190,11 +213,15 @@
                 <xsd:simpleType>
                     <xsd:restriction base="xsd:string">
                         <xsd:enumeration value="default"/>
-                        <!-- This flag will turn on Legacy JavaScript support for id and name attributes.  When this is
-                        set the default tag JavaScript will also be output. -->
+                        <!--
+                        This flag will turn on Legacy JavaScript support for id and name attributes.
+                        When this is set the default tag JavaScript will also be output.
+                        -->
                         <xsd:enumeration value="legacy"/>
-                        <!-- This flag will make Legacy JavaScript support the only type of JavaScript output for id
-                        and name attributes. -->
+                        <!--
+                        This flag will make Legacy JavaScript support the only type of JavaScript
+                        output for id and name attributes.
+                        -->
                         <xsd:enumeration value="legacyOnly"/>
                     </xsd:restriction>
                 </xsd:simpleType>
@@ -278,4 +305,33 @@
             </xsd:element>
         </xsd:sequence>
     </xsd:complexType>
+
+    <!--
+    Definition of a chain implementation for NetUI.  Chains and commands are defined as part
+    of a "catalog" of such items.
+     -->
+    <xsd:complexType name="catalog">
+        <xsd:sequence>
+            <xsd:element name="chain" type="netui:chain" minOccurs="0" maxOccurs="unbounded"/>
+            <xsd:element name="command" type="netui:command" minOccurs="0" maxOccurs="unbounded"/>
+        </xsd:sequence>
+        <xsd:attribute name="name" type="xsd:string"/>
+    </xsd:complexType>
+
+    <xsd:complexType name="chain">
+        <xsd:sequence>
+            <xsd:element name="command" type="netui:command" minOccurs="0" maxOccurs="unbounded"/>
+        </xsd:sequence>
+        <xsd:attribute name="name" type="xsd:string"/>
+    </xsd:complexType>
+
+    <xsd:complexType name="command">
+        <xsd:sequence>
+            <xsd:element name="custom-property" type="netui:custom-property" minOccurs="0" maxOccurs="unbounded"/>
+        </xsd:sequence>
+        <xsd:attribute name="id" type="xsd:string"/>
+        <xsd:attribute name="name" type="xsd:string"/>
+        <xsd:attribute name="classname" type="xsd:string"/>
+    </xsd:complexType>
+
 </xsd:schema>

Modified: beehive/trunk/netui/test/ant/build.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/test/ant/build.xml?rev=385838&r1=385837&r2=385838&view=diff
==============================================================================
--- beehive/trunk/netui/test/ant/build.xml (original)
+++ beehive/trunk/netui/test/ant/build.xml Tue Mar 14 09:17:31 2006
@@ -15,14 +15,14 @@
     <!-- ============================================= -->
     <!-- Build Targets                                 -->
     <!-- ============================================= -->
-    <target name="test.build" depends="prepare" description="Build the QA modules">
-        <antcall target="test.do.subant">
+    <target name="build" depends="prepare" description="Build the QA modules">
+        <antcall target="do.subant">
             <param name="target.name" value="build"/>
         </antcall>
     </target>
 
-    <target name="test.clean" description="Clean the QA modules">
-        <antcall target="test.do.subant">
+    <target name="clean" description="Clean the QA modules">
+        <antcall target="do.subant">
             <param name="target.name" value="clean"/>
         </antcall>
 
@@ -31,11 +31,10 @@
     	<delete dir="${compiler.testResults.dir}"/>
     </target>
 
-    <target name="test.do.subant">
+    <target name="do.subant">
         <subant target="${target.name}">
             <filelist dir="${test.src.dir}">
                 <file name="junitTests"/>
-<!--                <file name="testRecorderQA"/> -->
                 <file name="compilerTests"/>
             </filelist>
         </subant>
@@ -44,8 +43,8 @@
     <!-- ============================================= -->
     <!-- DRT Targets                                   -->
     <!-- ============================================= -->
-    <target name="drt" depends="test.clean,test.build,junit.drt" description="Run the NetUI JUnit DRTs"/>
-    <target name="bvt" depends="test.clean,test.build,junit.bvt,compiler.bvt" description="Run the NetUI JUnit BVTs"/>
+    <target name="drt" depends="clean,build,junit.drt" description="Run the NetUI JUnit DRTs"/>
+    <target name="bvt" depends="clean,build,junit.bvt,compiler.bvt" description="Run the NetUI JUnit BVTs"/>
 
     <target name="junit.drt">
         <ant antfile="junitCore.xml" target="run.tests" inheritAll="false">

Modified: beehive/trunk/netui/test/dist-test/build.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/test/dist-test/build.xml?rev=385838&r1=385837&r2=385838&view=diff
==============================================================================
--- beehive/trunk/netui/test/dist-test/build.xml (original)
+++ beehive/trunk/netui/test/dist-test/build.xml Tue Mar 14 09:17:31 2006
@@ -25,7 +25,7 @@
         <property name="test.dist.base.dir" location="${build.dir}/test-dist"/>
 
         <!-- Build the JUnit tests -->
-        <ant antfile="${test.dir}/ant/build.xml" target="test.build" inheritAll="false"/>
+        <ant antfile="${test.dir}/ant/build.xml" target="build" inheritAll="false"/>
     </target>    
 
     <target name="assemble.tests" description="Assemble all netui tests for test distribution">

Added: beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/chain/CatalogParserTest.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/chain/CatalogParserTest.java?rev=385838&view=auto
==============================================================================
--- beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/chain/CatalogParserTest.java (added)
+++ beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/chain/CatalogParserTest.java Tue Mar 14 09:17:31 2006
@@ -0,0 +1,92 @@
+/*
+ * 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.core.chain;
+
+import java.io.InputStream;
+
+import junit.framework.TestCase;
+import org.apache.beehive.netui.core.chain.Catalog;
+import org.apache.beehive.netui.core.chain.CatalogFactory;
+import org.apache.beehive.netui.core.chain.Command;
+import org.apache.beehive.netui.core.chain.Context;
+import org.apache.beehive.netui.util.config.bean.CatalogConfig;
+import org.apache.beehive.netui.util.config.internal.catalog.CatalogParser;
+import org.apache.beehive.netui.core.chain.impl.ContextBase;
+import org.apache.beehive.netui.test.core.chain.commands.ConfigurableCommand;
+
+/**
+ *
+ */
+public class CatalogParserTest
+    extends TestCase {
+
+    private String _resourcePath = "org/apache/beehive/netui/test/core/chain/xmls/simple-chain.xml";
+
+    public void testSimple()
+        throws Exception {
+
+        load(_resourcePath);
+        CatalogFactory catalogFactory = CatalogFactory.getInstance();
+
+        /* execute a command */
+        Catalog catalog = catalogFactory.getCatalog();
+
+        Context context = new ContextBase();
+        Command command = catalog.getCommand("echo-1234");
+        command.execute(context);
+    }
+
+    public void testConfigurable()
+        throws Exception {
+        load(_resourcePath);
+        CatalogFactory catalogFactory = CatalogFactory.getInstance();
+
+        Catalog catalog = catalogFactory.getCatalog();
+        Command command = catalog.getCommand("configurable");
+        ConfigurableCommand configurableCommand = (ConfigurableCommand)command;
+        assertEquals(54321, configurableCommand.getBar());
+        assertEquals("Homer", configurableCommand.getFoo());
+
+        command.execute(new ContextBase());
+    }
+
+    private void load(String resourcePath)
+        throws Exception {
+
+        InputStream inputStream = null;
+        try {
+            /* parse an XML file that defines a catalog */
+            inputStream = getClass().getClassLoader().getResourceAsStream(resourcePath);
+            CatalogParser catalogParser = CatalogParser.getInstance();
+            CatalogConfig catalogConfig = catalogParser.parse(resourcePath, inputStream);
+
+            /* create a real catalog instance */
+            CatalogFactory catalogFactory = CatalogFactory.getInstance(catalogConfig);
+            assertNotNull(catalogFactory);
+        }
+        catch(Exception e) {
+            throw e;
+        }
+        finally {
+            if(inputStream != null) inputStream.close();
+        }
+    }
+}
+
+
+

Added: beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/chain/SimpleCatalogFactoryTest.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/chain/SimpleCatalogFactoryTest.java?rev=385838&view=auto
==============================================================================
--- beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/chain/SimpleCatalogFactoryTest.java (added)
+++ beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/chain/SimpleCatalogFactoryTest.java Tue Mar 14 09:17:31 2006
@@ -0,0 +1,62 @@
+/*
+ * 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.core.chain;
+
+import junit.framework.TestCase;
+import org.apache.beehive.netui.core.chain.CatalogFactory;
+import org.apache.beehive.netui.core.chain.Catalog;
+import org.apache.beehive.netui.core.chain.Chain;
+import org.apache.beehive.netui.core.chain.Command;
+import org.apache.beehive.netui.core.chain.Context;
+import org.apache.beehive.netui.core.chain.impl.CatalogBase;
+import org.apache.beehive.netui.core.chain.impl.ChainBase;
+import org.apache.beehive.netui.core.chain.impl.ContextBase;
+import org.apache.beehive.netui.test.core.chain.commands.EchoCommand;
+
+/**
+ * 
+ */
+public class SimpleCatalogFactoryTest
+    extends TestCase {
+
+    public void testSimple()
+        throws Exception {
+        Chain chain = new ChainBase();
+        for(int i = 0; i < 3; i++) {
+            EchoCommand echoCommand = new EchoCommand();
+            echoCommand.setMessage("echo me " + i);
+            chain.addCommand(echoCommand);
+        }
+
+        Catalog catalog = new CatalogBase();
+        catalog.addCommand("echo", chain);
+
+        CatalogFactory catalogFactory = CatalogFactory.getInstance();
+        catalogFactory.addCatalog("simple", catalog);
+
+        Context context = new ContextBase();
+        Catalog theCatalog = catalogFactory.getCatalog("simple");
+        Command theCommand = theCatalog.getCommand("echo");
+        try {
+            theCommand.execute(context);
+        }
+        catch(Exception e) {
+            throw e;
+        }
+    }
+}

Added: beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/chain/SimpleChainTest.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/chain/SimpleChainTest.java?rev=385838&view=auto
==============================================================================
--- beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/chain/SimpleChainTest.java (added)
+++ beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/chain/SimpleChainTest.java Tue Mar 14 09:17:31 2006
@@ -0,0 +1,73 @@
+/*
+ * 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.core.chain;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.apache.beehive.netui.core.chain.Context;
+import org.apache.beehive.netui.core.chain.Chain;
+import org.apache.beehive.netui.core.chain.impl.ChainBase;
+import org.apache.beehive.netui.core.chain.impl.ContextBase;
+import org.apache.beehive.netui.test.core.chain.commands.EchoCommand;
+
+/**
+ *
+ */
+public class SimpleChainTest
+    extends TestCase {
+
+    public void testSimple()
+        throws Exception {
+
+        Context context = new ContextBase();
+        Chain chain = new ChainBase();
+        for(int i = 0; i < 3; i++) {
+            EchoCommand echoCommand = new EchoCommand();
+            echoCommand.setMessage("echo me " + i);
+            chain.addCommand(echoCommand);
+        }
+
+        boolean result = false;
+        try {
+            chain.execute(context);
+        }
+        catch(Exception e) {
+            throw e;
+        }
+
+        assertFalse(result);
+    }
+
+    /**
+     * Create the test case
+     *
+     * @param testName name of the test case
+     */
+    public SimpleChainTest(String testName) {
+        super(testName);
+    }
+
+    /**
+     * @return the suite of tests being tested
+     */
+    public static Test suite() {
+        return new TestSuite(SimpleChainTest.class);
+    }
+}
+

Added: beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/chain/commands/ConfigurableCommand.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/chain/commands/ConfigurableCommand.java?rev=385838&view=auto
==============================================================================
--- beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/chain/commands/ConfigurableCommand.java (added)
+++ beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/chain/commands/ConfigurableCommand.java Tue Mar 14 09:17:31 2006
@@ -0,0 +1,52 @@
+/*
+ * 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.core.chain.commands;
+
+import org.apache.beehive.netui.core.chain.Command;
+import org.apache.beehive.netui.core.chain.Context;
+
+/**
+ * 
+ */
+public class ConfigurableCommand
+    implements Command {
+
+    private String _foo;
+    private int _bar;
+
+    public String getFoo() {
+        return _foo;
+    }
+
+    public void setFoo(String foo) {
+        _foo = foo;
+    }
+
+    public int getBar() {
+        return _bar;
+    }
+
+    public void setBar(int bar) {
+        _bar = bar;
+    }
+
+    public boolean execute(Context context) throws Exception {
+        System.out.println("foo: " + _foo + " bar: " + _bar);
+        return false;
+    }
+}

Added: beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/chain/commands/EchoCommand.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/chain/commands/EchoCommand.java?rev=385838&view=auto
==============================================================================
--- beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/chain/commands/EchoCommand.java (added)
+++ beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/chain/commands/EchoCommand.java Tue Mar 14 09:17:31 2006
@@ -0,0 +1,44 @@
+/*
+ * 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.core.chain.commands;
+
+import org.apache.beehive.netui.core.chain.Command;
+import org.apache.beehive.netui.core.chain.Context;
+
+/**
+ *
+ */
+public class EchoCommand
+    implements Command {
+
+    private String _message;
+
+    public String getMessage() {
+        return _message;
+    }
+
+    public void setMessage(String message) {
+        _message = message;
+    }
+
+    public boolean execute(Context context)
+        throws Exception {
+        System.out.println(getMessage());
+        return false;
+    }
+}