You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by cs...@apache.org on 2006/11/08 22:48:23 UTC

svn commit: r472654 - in /beehive/trunk/system-controls: ./ src/jdbc/org/apache/beehive/controls/system/jdbc/ test/ant/ test/jdbc/controls/org/apache/beehive/controls/system/jdbc/test/results/ test/jdbc/controls/schemas/customer/ test/jdbc/junitTests/o...

Author: cschoett
Date: Wed Nov  8 13:48:22 2006
New Revision: 472654

URL: http://svn.apache.org/viewvc?view=rev&rev=472654
Log:
Fix for BEEHIVE-1153, created an XMLStreamReader implementation for ResultSets, this allows for the proper processing of XMLBean document types.

Also added new set of DRTs for testing XMLBean document type support.


Added:
    beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/ResultSetXMLStreamReader.java
    beehive/trunk/system-controls/test/jdbc/controls/schemas/customer/
    beehive/trunk/system-controls/test/jdbc/controls/schemas/customer/XCustomer.xsd
    beehive/trunk/system-controls/test/jdbc/junitTests/org/apache/beehive/controls/system/jdbc/units/results/XmlBeanDocResultsTest.java
Modified:
    beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/RowToXmlObjectMapper.java
    beehive/trunk/system-controls/systemcontrols-imports.xml
    beehive/trunk/system-controls/test/ant/junitCore.xml
    beehive/trunk/system-controls/test/jdbc/controls/org/apache/beehive/controls/system/jdbc/test/results/ResultsTestCtrl.jcx

Added: beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/ResultSetXMLStreamReader.java
URL: http://svn.apache.org/viewvc/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/ResultSetXMLStreamReader.java?view=auto&rev=472654
==============================================================================
--- beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/ResultSetXMLStreamReader.java (added)
+++ beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/ResultSetXMLStreamReader.java Wed Nov  8 13:48:22 2006
@@ -0,0 +1,740 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.controls.system.jdbc;
+
+import org.apache.xmlbeans.SchemaProperty;
+import org.apache.xmlbeans.SchemaType;
+import org.apache.xmlbeans.SchemaTypeSystem;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.util.LinkedList;
+import java.util.NoSuchElementException;
+
+/**
+ * XMLStreamReader implemenation for mapping a java.sql.ResultSet into
+ * a XML Beans schema document type. For each column in the ResultSet
+ * a START_ELEMENT, CHARACTERS and END_ELEMENT event is created, these
+ * are surrounded by the row tag defined in the SchemaType which is in
+ * turn enclosed in the outer schema type tags.
+ * <p/>
+ * This implementation only generates START_DOCUMENT, END_DOCUEMENT,
+ * START_ELEMENT, END_ELEMENT and CHARACTERS events.  Elements never have
+ * attributes and no processing instructions are generated.  Also there
+ * is very little of the EVENT state checking (as specified in the XMLStreamReader
+ * javadoc) done in this implementation.
+ */
+public final class ResultSetXMLStreamReader implements XMLStreamReader
+{
+    private ResultSet _resultSet;
+    private LinkedList<SimpleEvent> _eventQueue;
+    private ElementPair _columnElements[];
+    private ElementPair _resultSetEvents;
+    private SimpleEvent _currentEvent;
+    private boolean _isFirstRow;
+
+    private ResultSetXMLStreamReader()
+    {
+        // private no-arg constructor
+    }
+
+    /**
+     * Initialize this instance with the ResultSet to map from and the SchemaType to map the ResultSet into.
+     *
+     * @param resultSet  ResultSet to map from.
+     * @param schemaType The SchemaType to map the ResultSet into.
+     * @throws XMLStreamException On Error.
+     */
+    protected ResultSetXMLStreamReader(ResultSet resultSet, SchemaType schemaType) throws XMLStreamException
+    {
+        QName rowSetElementQName = schemaType.getDocumentElementName();
+        SchemaTypeSystem schemaTypeSystem = schemaType.getTypeSystem();
+        SchemaType rowSetSchemaType = schemaTypeSystem.findElement(rowSetElementQName).getType();
+
+        SchemaProperty[] schemaProperties = rowSetSchemaType.getElementProperties();
+        String rowName = (schemaProperties != null && schemaProperties.length > 0) ? schemaProperties[0].getName().getLocalPart() : "Row";
+
+        init(resultSet, rowSetElementQName.getNamespaceURI(), rowSetElementQName.getLocalPart(), rowName);
+    }
+
+    /**
+     * Get the next event from the Queue. In this implementation this is the
+     * equivalent of nextTag() since there is no whitespace generated.
+     *
+     * @return The event type of the next event on the queue. See javax.xml.stream.XMLStreamConstants.
+     * @throws XMLStreamException If the queue is empty.
+     */
+    public int next() throws XMLStreamException
+    {
+        return nextTag();
+    }
+
+    /**
+     * Get the next START/END ELEMENT event from the queue.
+     *
+     * @return The event type of the next event on the queue. See javax.xml.stream.XMLStreamConstants.
+     * @throws XMLStreamException If the queue is empty.
+     */
+    public int nextTag() throws XMLStreamException
+    {
+        if (hasNext()) {
+            _currentEvent = _eventQueue.removeFirst();
+            return _currentEvent.eventType;
+        }
+        throw new NoSuchElementException();
+    }
+
+    /**
+     * True if the event queue is not empty.
+     *
+     * @return false if event queue is empty.
+     * @throws XMLStreamException if a fatal error occures.
+     */
+    public boolean hasNext() throws XMLStreamException
+    {
+        if (!_eventQueue.isEmpty())
+            return true;
+
+        populateFromNextRow();
+        return !_eventQueue.isEmpty();
+    }
+
+    /**
+     * Close the ResultSet.
+     *
+     * @throws XMLStreamException On error.
+     */
+    public void close() throws XMLStreamException
+    {
+        try {
+            _resultSet.close();
+        } catch (SQLException e) {
+            throw new XMLStreamException(e);
+        }
+    }
+
+    /**
+     * Get the current events type.
+     * See javax.xml.stream.XMLStreamConstants for type information.
+     *
+     * @return integer event type.
+     */
+    public int getEventType()
+    {
+        return _currentEvent.eventType;
+    }
+
+    /**
+     * Get the text characters for the current event.
+     *
+     * @return character array, empty array if no text.
+     */
+    public char[] getTextCharacters()
+    {
+        if (_currentEvent.data != null) {
+            return _currentEvent.data.toCharArray();
+        } else {
+            return new char[0];
+        }
+    }
+
+    /**
+     * Always zero for this implementation.
+     *
+     * @return 0
+     */
+    public int getTextStart()
+    {
+        return 0;
+    }
+
+    /**
+     * Get the length of the current event's text.
+     *
+     * @return int
+     */
+    public int getTextLength()
+    {
+        if (_currentEvent.data != null) {
+            return _currentEvent.data.length();
+        }
+        return 0;
+    }
+
+    /**
+     * Get the name of the current start/end element event tag.
+     *
+     * @return QName
+     */
+    public QName getName()
+    {
+        return _currentEvent.tagName;
+    }
+
+    ////////////////////////////////////////////////////////////////////////////////////////////////////////
+    //  XMLStreamReader METHODS WHICH RETURN A FIXED VALUE, ONLY INVOKED WHEN ON START_DOCUMENT EVENT
+    ////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * Always returns null.
+     *
+     * @return null
+     */
+    public String getEncoding()
+    {
+        if (_currentEvent.eventType != XMLStreamReader.START_DOCUMENT)
+            throw new IllegalStateException();
+        return null;
+    }
+
+    /**
+     * Always returns 1.0
+     *
+     * @return 1.0
+     */
+    public String getVersion()
+    {
+        if (_currentEvent.eventType != XMLStreamReader.START_DOCUMENT)
+            throw new IllegalStateException();
+        return "1.0";
+    }
+
+    /**
+     * Always returns true.
+     *
+     * @return true
+     */
+    public boolean isStandalone()
+    {
+        if (_currentEvent.eventType != XMLStreamReader.START_DOCUMENT)
+            throw new IllegalStateException();
+        return true;
+    }
+
+    /**
+     * Always returns true.
+     *
+     * @return true
+     */
+    public boolean standaloneSet()
+    {
+        if (_currentEvent.eventType != XMLStreamReader.START_DOCUMENT)
+            throw new IllegalStateException();
+        return true;
+    }
+
+    /**
+     * Always returns "UTF-8"
+     *
+     * @return "UTF-8"
+     */
+    public String getCharacterEncodingScheme()
+    {
+        if (_currentEvent.eventType != XMLStreamReader.START_DOCUMENT)
+            throw new IllegalStateException();
+        return "UTF-8";
+    }
+
+    ////////////////////////////////////////////////////////////////////////////////////////////////////////
+    //  XMLStreamReader METHODS WHICH SHOULD NEVER BE INVOKED
+    ////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * Not implemented.
+     *
+     * @param string
+     * @return null
+     * @throws IllegalArgumentException
+     */
+    public Object getProperty(String string) throws IllegalArgumentException
+    {
+        return null;
+    }
+
+    /**
+     * Not implemented.
+     *
+     * @param i
+     * @param string
+     * @param string1
+     * @throws XMLStreamException
+     */
+    public void require(int i, String string, String string1) throws XMLStreamException
+    {
+    }
+
+    /**
+     * Not implemented.
+     *
+     * @return null
+     * @throws XMLStreamException
+     */
+    public String getElementText() throws XMLStreamException
+    {
+        return null;
+    }
+
+    /**
+     * Not implemented.
+     *
+     * @param string
+     * @return null
+     */
+    public String getNamespaceURI(String string)
+    {
+        return null;
+    }
+
+    /**
+     * Is the current event of type START_ELEMENT?
+     *
+     * @return true if current event is start element.
+     */
+    public boolean isStartElement()
+    {
+        return _currentEvent.eventType == XMLStreamReader.START_ELEMENT;
+    }
+
+    /**
+     * Is the current event of type END_ELEMENT?
+     *
+     * @return true if current event is end element.
+     */
+    public boolean isEndElement()
+    {
+        return _currentEvent.eventType == XMLStreamReader.END_ELEMENT;
+    }
+
+    /**
+     * Is the current event of type CHARACTERS?
+     *
+     * @return true if current event is characters event
+     */
+    public boolean isCharacters()
+    {
+        return _currentEvent.eventType == XMLStreamReader.CHARACTERS;
+    }
+
+    /**
+     * Is the current event of type WHITESPACE?
+     *
+     * @return Always false.
+     */
+    public boolean isWhiteSpace()
+    {
+        return false;
+    }
+
+    /**
+     * Not implemented, attributes are never generated by this reader.
+     *
+     * @param string
+     * @param string1
+     * @return Always null
+     */
+    public String getAttributeValue(String string, String string1)
+    {
+        return null;
+    }
+
+    /**
+     * Not implemented, attributes are never generated by this reader.
+     *
+     * @return 0 (zero)
+     */
+    public int getAttributeCount()
+    {
+        return 0;
+    }
+
+    /**
+     * Not implemented, attributes are never generated by this reader.
+     *
+     * @param i
+     * @return null
+     */
+    public QName getAttributeName(int i)
+    {
+        return null;
+    }
+
+    /**
+     * Not implemented, attributes are never generated by this reader.
+     *
+     * @param i
+     * @return null
+     */
+    public String getAttributeNamespace(int i)
+    {
+        return null;
+    }
+
+    /**
+     * Not implemented, attributes are never generated by this reader.
+     *
+     * @param i
+     * @return null
+     */
+    public String getAttributeLocalName(int i)
+    {
+        return null;
+    }
+
+    /**
+     * Not implemented, attributes are never generated by this reader.
+     *
+     * @param i
+     * @return null
+     */
+    public String getAttributePrefix(int i)
+    {
+        return null;
+    }
+
+    /**
+     * Not implemented, attributes are never generated by this reader.
+     *
+     * @param i
+     * @return null
+     */
+    public String getAttributeType(int i)
+    {
+        return null;
+    }
+
+    /**
+     * Not implemented, attributes are never generated by this reader.
+     *
+     * @param i
+     * @return null
+     */
+    public String getAttributeValue(int i)
+    {
+        return null;
+    }
+
+    /**
+     * Not implemented, attributes are never generated by this reader.
+     *
+     * @param i
+     * @return false
+     */
+    public boolean isAttributeSpecified(int i)
+    {
+        return false;
+    }
+
+    /**
+     * Not implemented.
+     *
+     * @return 0 (zero)
+     */
+    public int getNamespaceCount()
+    {
+        return 0;
+    }
+
+    /**
+     * Not implemented.
+     *
+     * @param i
+     * @return null
+     */
+    public String getNamespacePrefix(int i)
+    {
+        return null;
+    }
+
+    /**
+     * Not implemented.
+     *
+     * @param i
+     * @return null
+     */
+    public String getNamespaceURI(int i)
+    {
+        return null;
+    }
+
+    /**
+     * Not impemented.
+     *
+     * @return null
+     */
+    public NamespaceContext getNamespaceContext()
+    {
+        return null;
+    }
+
+    /**
+     * Not implemented.
+     *
+     * @return null
+     */
+    public String getText()
+    {
+        return null;
+    }
+
+    /**
+     * Not implemented.
+     *
+     * @param i
+     * @param chars
+     * @param i1
+     * @param i2
+     * @return 0 (zero)
+     * @throws XMLStreamException
+     */
+    public int getTextCharacters(int i, char[] chars, int i1, int i2) throws XMLStreamException
+    {
+        return 0;
+    }
+
+    /**
+     * Does the current event have text associated with it?
+     *
+     * @return true if CHARACTERS type event.
+     */
+    public boolean hasText()
+    {
+        return _currentEvent.data != null;
+    }
+
+    /**
+     * Not implemented.
+     *
+     * @return null
+     */
+    public Location getLocation()
+    {
+        return null;
+    }
+
+    /**
+     * Get the localName of a start/end element.
+     *
+     * @return Local part of the element QName.
+     */
+    public String getLocalName()
+    {
+        if (_currentEvent.tagName != null) {
+            return _currentEvent.tagName.getLocalPart();
+        }
+        return null;
+    }
+
+    /**
+     * Does the current event have a name associated.
+     *
+     * @return true if start or end element event.
+     */
+    public boolean hasName()
+    {
+        return _currentEvent.eventType == XMLStreamReader.START_ELEMENT
+                || _currentEvent.eventType == XMLStreamReader.END_ELEMENT;
+    }
+
+    /**
+     * Get the namespace URI for the current event name.
+     *
+     * @return namespace part of element QName.
+     */
+    public String getNamespaceURI()
+    {
+        if (_currentEvent.tagName != null) {
+            return _currentEvent.tagName.getNamespaceURI();
+        }
+        return null;
+    }
+
+    /**
+     * Not implemented.
+     *
+     * @return null
+     */
+    public String getPrefix()
+    {
+        return null;
+    }
+
+    /**
+     * Processing instructions are never generated by this reader.
+     *
+     * @return null
+     */
+    public String getPITarget()
+    {
+        return null;
+    }
+
+    /**
+     * Processing instructions are never generated by this reader.
+     *
+     * @return null
+     */
+    public String getPIData()
+    {
+        return null;
+    }
+
+    ////////////////////////////////////////////////////////////////////////////////////////////////////////
+    //  PRIVATE METHODS
+    ////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * Initialize data structures before the parsing starts.
+     *
+     * @param rs              ResultSet to 'parse'
+     * @param targetNamespace target namespace from the schema type.
+     * @param rowsetName      Name of the schema docuement type's row collection element.
+     * @param rowName         Name of the row tags within the row collection.
+     * @throws XMLStreamException On error.
+     */
+    private void init(ResultSet rs, String targetNamespace, String rowsetName, String rowName)
+            throws XMLStreamException
+    {
+        try {
+            _resultSet = rs;
+            _eventQueue = new LinkedList<SimpleEvent>();
+            _isFirstRow = true;
+            ResultSetMetaData metaData = _resultSet.getMetaData();
+
+            // create an array of start/end events for each column and the row.
+            int count = metaData.getColumnCount();
+            _columnElements = new ElementPair[count + 1];
+            _columnElements[0] = new ElementPair(targetNamespace, rowName);
+            for (int i = 1; i <= count; i++) {
+                _columnElements[i] = new ElementPair(targetNamespace, metaData.getColumnName(i));
+            }
+
+            // create the outer event pair for the ResultSet
+            _resultSetEvents = new ElementPair(targetNamespace, rowsetName);
+
+            _currentEvent = new SimpleEvent(XMLStreamReader.START_DOCUMENT, "");
+            _eventQueue.addLast(_resultSetEvents.start);
+        }
+        catch (SQLException sqe) {
+            throw new XMLStreamException("Error while initializing XMLStreamReader.", sqe);
+        }
+    }
+
+    /**
+     * Generate the next set of parser events for the next row
+     * of the ResultSet.  If at last row in ResultSet, generate an
+     * XMLStreamReader.END_DOCUMENT event.
+     *
+     * @throws XMLStreamException
+     */
+    private void populateFromNextRow() throws XMLStreamException
+    {
+        try {
+            if (_isFirstRow) {
+                _isFirstRow = false;
+            } else if (!_resultSet.next()) {
+                _eventQueue.addLast(_resultSetEvents.end);
+                _eventQueue.addLast(new SimpleEvent(XMLStreamReader.END_DOCUMENT, ""));
+                return;
+            }
+        } catch (SQLException e) {
+            throw new XMLStreamException(e);
+        }
+
+        _eventQueue.addLast(_columnElements[0].start);
+        for (int i = 1; i < _columnElements.length; i++) {
+
+            Object v;
+            String s = null;
+            try {
+                v = _resultSet.getObject(i);
+            } catch (SQLException e) {
+                throw new XMLStreamException(e);
+            }
+
+            _eventQueue.addLast(_columnElements[i].start);
+            if (v != null) {
+                s = v.toString();
+            }
+            _eventQueue.addLast(new SimpleEvent(XMLStreamReader.CHARACTERS, s));
+            _eventQueue.addLast(_columnElements[i].end);
+        }
+        _eventQueue.addLast(_columnElements[0].end);
+    }
+
+    ////////////////////////////////////////////////////////////////////////////////////////////////////////
+    // INNER CLASSES
+    ////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * Private inner class used for representing 'parser' events, something of
+     * an XMLEvent equivalent, or at least all that is necessary for this XMLStreamReader
+     * implementation.
+     */
+    private final class SimpleEvent
+    {
+        // event type, XMLStreamConstants
+        final int eventType;
+
+        final QName tagName;
+        final String data;
+
+        SimpleEvent(int type, String data)
+        {
+            eventType = type;
+            this.data = data;
+            tagName = null;
+        }
+
+        SimpleEvent(int type, QName tagName)
+        {
+            eventType = type;
+            data = null;
+            this.tagName = tagName;
+        }
+    }
+
+    /**
+     * Private inner class used to store start/end tag element pairs used for
+     * the ResultSet.  There is one element pair for each column in the ResultSet
+     * and one for the ResultSet.
+     */
+    private final class ElementPair
+    {
+        final SimpleEvent start;
+        final SimpleEvent end;
+
+        ElementPair(String targetNamespace, String tag)
+        {
+            QName qn = new QName(targetNamespace, tag);
+            start = new SimpleEvent(XMLStreamReader.START_ELEMENT, qn);
+            end = new SimpleEvent(XMLStreamReader.END_ELEMENT, qn);
+        }
+    }
+}

Modified: beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/RowToXmlObjectMapper.java
URL: http://svn.apache.org/viewvc/beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/RowToXmlObjectMapper.java?view=diff&rev=472654&r1=472653&r2=472654
==============================================================================
--- beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/RowToXmlObjectMapper.java (original)
+++ beehive/trunk/system-controls/src/jdbc/org/apache/beehive/controls/system/jdbc/RowToXmlObjectMapper.java Wed Nov  8 13:48:22 2006
@@ -24,7 +24,9 @@
 import org.apache.xmlbeans.SchemaType;
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlOptions;
+import org.apache.xmlbeans.XmlException;
 
+import javax.xml.stream.XMLStreamException;
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
@@ -64,13 +66,16 @@
     }
 
     /**
-     * map a row from the ResultSet to an XmlObject instance
+     * Map a row from the ResultSet to an XmlObject instance.
      *
      * @return An XmlObject instance.
      */
     public Object mapRowToReturnType() {
 
-        Object resultObject = null;
+        if (_schemaType.isDocumentType()) {
+            return mapDocumentTypeSchema();
+        }
+
         if (_columnCount == 1) {
 
             final int typeId = _tmf.getTypeId(_returnTypeClass);
@@ -98,7 +103,7 @@
             }
         }
 
-        resultObject = XmlObject.Factory.newInstance(new XmlOptions().setDocumentType(_schemaType));
+        Object resultObject = XmlObject.Factory.newInstance(new XmlOptions().setDocumentType(_schemaType));
 
         for (int i = 1; i < _setterMethods.length; i++) {
             Method setterMethod = _setterMethods[i].getSetter();
@@ -131,8 +136,8 @@
                     ResultSetMetaData md = _resultSet.getMetaData();
                     throw new ControlException("The declared Java type for method " + setterMethod.getName()
                                                + setterMethod.getParameterTypes()[0].toString()
-                                               + " is incompatible with the SQL format of column " + md.getColumnName(i).toString()
-                                               + md.getColumnTypeName(i).toString()
+                                               + " is incompatible with the SQL format of column " + md.getColumnName(i)
+                                               + md.getColumnTypeName(i)
                                                + " which returns objects of type " + resultValue.getClass().getName());
                 } catch (SQLException e) {
                     throw new ControlException(e.getMessage(), e);
@@ -158,13 +163,6 @@
      */
     private void getResultSetMappings() throws SQLException {
 
-        //
-        // special case for XmlObject, find factory class
-        //
-        if (_schemaType.isDocumentType()) {
-            return;
-        }
-
         final String[] keys = getKeysFromResultSet();
 
         //
@@ -222,6 +220,7 @@
             try {
                 col = _resultSet.findColumn(props[i].getName().getLocalPart());
             } catch (SQLException x) {
+                // noop
             }
 
             if (col > 0) {
@@ -246,10 +245,31 @@
                     schemaType = (SchemaType) f.get(null);
                 }
             } catch (NoSuchFieldException x) {
+                // noop
             } catch (IllegalAccessException x) {
+                // noop
             }
         }
         return schemaType;
+    }
+
+    /**
+     * Maps the ResultSet to a schema whose type is 'document'.
+     *
+     * @return Instance of schema type.
+     */
+    private Object mapDocumentTypeSchema() {
+
+        assert _schemaType.isDocumentType() : "Invalid schema type!";
+
+        try {
+            ResultSetXMLStreamReader rsxsr = new ResultSetXMLStreamReader(_resultSet, _schemaType);
+            return XmlObject.Factory.parse(rsxsr);
+        } catch (XMLStreamException e) {
+            throw new ControlException("Could not map ResultSet to schema, XmlStreamException occurred.", e);
+        } catch (XmlException e) {
+            throw new ControlException("Could not map ResultSet to schema, XmlException occurred.", e);
+        }
     }
 
     // /////////////////////////////////////////////INNER CLASSES/////////////////////////////////////////////////

Modified: beehive/trunk/system-controls/systemcontrols-imports.xml
URL: http://svn.apache.org/viewvc/beehive/trunk/system-controls/systemcontrols-imports.xml?view=diff&rev=472654&r1=472653&r2=472654
==============================================================================
--- beehive/trunk/system-controls/systemcontrols-imports.xml (original)
+++ beehive/trunk/system-controls/systemcontrols-imports.xml Wed Nov  8 13:48:22 2006
@@ -60,6 +60,7 @@
 
     <path id="ejb.dependency.path">
         <fileset file="${sc.home}/external/ejb/geronimo-j2ee_1.4_spec-1.0.jar"/>
+        <fileset file="/apps/jboss-4.0.4.GA/server/default/deploy/ejb3.deployer/jboss-ejb3x.jar"/>
     </path>
 
 </project>

Modified: beehive/trunk/system-controls/test/ant/junitCore.xml
URL: http://svn.apache.org/viewvc/beehive/trunk/system-controls/test/ant/junitCore.xml?view=diff&rev=472654&r1=472653&r2=472654
==============================================================================
--- beehive/trunk/system-controls/test/ant/junitCore.xml (original)
+++ beehive/trunk/system-controls/test/ant/junitCore.xml Wed Nov  8 13:48:22 2006
@@ -47,6 +47,7 @@
             <test name="org.apache.beehive.controls.system.jdbc.units.results.StoredProcsDBResultsTest" todir="${testout.dir}"/>
             <test name="org.apache.beehive.controls.system.jdbc.units.results.TxResultsTest" todir="${testout.dir}"/>
             <test name="org.apache.beehive.controls.system.jdbc.units.results.XmlBeanResultsTest" todir="${testout.dir}"/>
+            <test name="org.apache.beehive.controls.system.jdbc.units.results.XmlBeanDocResultsTest" todir="${testout.dir}"/>
             <test name="org.apache.beehive.controls.system.jdbc.units.results.JdbcTypesTest" todir="${testout.dir}"/>
             <test name="org.apache.beehive.controls.system.jdbc.units.errors.ErrorPathsTest" todir="${testout.dir}"/>
             <test name="org.apache.beehive.controls.system.jdbc.units.JdbcControlSerializationTest" todir="${testout.dir}"/>

Modified: beehive/trunk/system-controls/test/jdbc/controls/org/apache/beehive/controls/system/jdbc/test/results/ResultsTestCtrl.jcx
URL: http://svn.apache.org/viewvc/beehive/trunk/system-controls/test/jdbc/controls/org/apache/beehive/controls/system/jdbc/test/results/ResultsTestCtrl.jcx?view=diff&rev=472654&r1=472653&r2=472654
==============================================================================
--- beehive/trunk/system-controls/test/jdbc/controls/org/apache/beehive/controls/system/jdbc/test/results/ResultsTestCtrl.jcx (original)
+++ beehive/trunk/system-controls/test/jdbc/controls/org/apache/beehive/controls/system/jdbc/test/results/ResultsTestCtrl.jcx Wed Nov  8 13:48:22 2006
@@ -19,61 +19,87 @@
 
 package org.apache.beehive.controls.system.jdbc.test.results;
 
-import java.sql.SQLException;
-import java.sql.ResultSet;
+import databaseCustomerDb.XCustomerDocument;
+import org.apache.beehive.controls.system.jdbc.DefaultRowSetResultSetMapper;
+import org.apache.beehive.controls.system.jdbc.JdbcControl;
+import test.customerDb.XStoogeRowDocument;
+
+import javax.sql.RowSet;
+import java.math.BigDecimal;
 import java.sql.Blob;
 import java.sql.Clob;
+import java.sql.ResultSet;
+import java.sql.SQLException;
 import java.sql.Time;
-import java.util.Iterator;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Map;
-import java.math.BigDecimal;
-
-import org.apache.beehive.controls.system.jdbc.JdbcControl;
-import org.apache.beehive.controls.system.jdbc.DefaultRowSetResultSetMapper;
-
-import javax.sql.RowSet;
-
-import test.customerDb.XStoogeRowDocument;
 
 /**
  * This control is used for unit tests for results returned from the db control.
  */
 @org.apache.beehive.controls.api.bean.ControlExtension
-@JdbcControl.ConnectionDriver(databaseDriverClass="org.apache.derby.jdbc.EmbeddedDriver", databaseURL="jdbc:derby:MyDB;create=true")
-public interface ResultsTestCtrl extends JdbcControl {
+@JdbcControl.ConnectionDriver(databaseDriverClass = "org.apache.derby.jdbc.EmbeddedDriver", databaseURL = "jdbc:derby:MyDB;create=true")
+public interface ResultsTestCtrl extends JdbcControl
+{
 
-    public static class Customer {
+    public static class Customer
+    {
         private String fname;
         public int userid;
 
-        public void setFname(String fname) { this.fname = fname; }
-        public String getFname() { return fname; }
+        public void setFname(String fname)
+        {
+            this.fname = fname;
+        }
+
+        public String getFname()
+        {
+            return fname;
+        }
     }
 
-    public static class CustomerInput1 {
+
+    public static class CustomerInput1
+    {
         private int _userid;
 
-        public int getUserid() {return _userid;}
-        public void setUserid(int userid) {_userid = userid;}
+        public int getUserid()
+        {
+            return _userid;
+        }
+
+        public void setUserid(int userid)
+        {
+            _userid = userid;
+        }
     }
 
-    public static class CustomerInput2 {
+
+    public static class CustomerInput2
+    {
         public int userid;
     }
 
-    public static class CustomerWrapper {
+
+    public static class CustomerWrapper
+    {
         public CustomerInput2 c;
     }
 
-    public static class CustomerInput3 extends CustomerInput1 {
+
+    public static class CustomerInput3 extends CustomerInput1
+    {
         private int foo;
     }
 
-    public static class CustomerInput4 extends CustomerInput2 {
+
+    public static class CustomerInput4 extends CustomerInput2
+    {
         private int foo;
     }
 
+
     public static class ComplexWhereClause
     {
         public JdbcControl.ComplexSqlFragment getWhereClause()
@@ -84,464 +110,739 @@
         }
     }
 
-    public static class BlobInfo {
+
+    public static class BlobInfo
+    {
         private Blob blb;
 
-        public void setBlb(Blob blb) { this.blb = blb; }
-        public Blob getBlb() { return blb; }
+        public void setBlb(Blob blb)
+        {
+            this.blb = blb;
+        }
+
+        public Blob getBlb()
+        {
+            return blb;
+        }
 
     }
 
-    public static class Binary {
+
+    public static class Binary
+    {
         private byte[] _bytes;
         private byte[] _varbytes;
         private byte[] _lvarbytes;
 
-        public void setBin(byte[] bytes) { _bytes = bytes; }
-        public byte[] getBin() { return _bytes; }
+        public void setBin(byte[] bytes)
+        {
+            _bytes = bytes;
+        }
+
+        public byte[] getBin()
+        {
+            return _bytes;
+        }
 
-        public void setVarbin(byte[] varbytes) { _varbytes = varbytes; }
-        public byte[] getVarbin() { return _varbytes; }
+        public void setVarbin(byte[] varbytes)
+        {
+            _varbytes = varbytes;
+        }
 
-        public void setLvarbin(byte[] lvarbytes) { _lvarbytes = lvarbytes; }
-        public byte[] getLvarbin() { return _lvarbytes; }
+        public byte[] getVarbin()
+        {
+            return _varbytes;
+        }
+
+        public void setLvarbin(byte[] lvarbytes)
+        {
+            _lvarbytes = lvarbytes;
+        }
+
+        public byte[] getLvarbin()
+        {
+            return _lvarbytes;
+        }
     }
 
-    //
-    // simple query
-    //
-    @SQL(statement="SELECT fname FROM USERS")
+    /**
+     * Simple query.
+     *
+     * @return ResultSet
+     * @throws SQLException
+     */
+    @SQL(statement = "SELECT fname FROM USERS")
     public ResultSet getAllUsers() throws SQLException;
 
-    //
-    // simple query with param substitution
-    //
-    @SQL(statement="SELECT * FROM USERS WHERE fname={someUser}")
+    /**
+     * Simple query with param substitution.
+     *
+     * @param someUser
+     * @return ResultSet
+     * @throws SQLException
+     */
+    @SQL(statement = "SELECT * FROM USERS WHERE fname={someUser}")
     public ResultSet getSomeUser(String someUser) throws SQLException;
 
-    //
-    // from a object getMethod
-    //
-    @SQL(statement="SELECT fname FROM USERS WHERE userid={customer.userid}")
+    /**
+     * From a object getMethod.
+     *
+     * @param customer
+     * @return String
+     * @throws SQLException
+     */
+    @SQL(statement = "SELECT fname FROM USERS WHERE userid={customer.userid}")
     public String getSomeUser(CustomerInput1 customer) throws SQLException;
 
-    //
-    // from a object getField
-    //
-    @SQL(statement="SELECT fname FROM USERS WHERE userid={customer.userid}")
+    /**
+     * From a object getField.
+     *
+     * @param customer
+     * @return String
+     * @throws SQLException
+     */
+    @SQL(statement = "SELECT fname FROM USERS WHERE userid={customer.userid}")
     public String getSomeUser(CustomerInput2 customer) throws SQLException;
 
-    //
-    // from a object getField
-    //
-    @SQL(statement="SELECT fname FROM USERS WHERE userid={customer.userid}")
+    /**
+     * From a object getField.
+     *
+     * @param customer
+     * @return String
+     * @throws SQLException
+     */
+    @SQL(statement = "SELECT fname FROM USERS WHERE userid={customer.userid}")
     public String getSomeUser(CustomerInput3 customer) throws SQLException;
 
-    //
-    // from a object getField
-    //
-    @SQL(statement="SELECT fname FROM USERS WHERE userid={customer.userid}")
+    /**
+     * From a object getField.
+     *
+     * @param customer
+     * @return String
+     * @throws SQLException
+     */
+    @SQL(statement = "SELECT fname FROM USERS WHERE userid={customer.userid}")
     public String getSomeUser(CustomerInput4 customer) throws SQLException;
 
-    //
-    // from a object getField
-    //
-    @SQL(statement="SELECT fname FROM USERS WHERE userid={customer.userid}")
+    /**
+     * From a object getField.
+     *
+     * @param customer
+     * @return String
+     * @throws SQLException
+     */
+    @SQL(statement = "SELECT fname FROM USERS WHERE userid={customer.userid}")
     public String getSomeUser(Map customer) throws SQLException;
 
-    //
-    // from a object nested getField
-    //
-    @SQL(statement="SELECT fname FROM USERS WHERE userid={customer.c.userid}")
+    /**
+     * From a object nested getField.
+     *
+     * @param customer
+     * @return String
+     * @throws SQLException
+     */
+    @SQL(statement = "SELECT fname FROM USERS WHERE userid={customer.c.userid}")
     public String getSomeUser(CustomerWrapper customer) throws SQLException;
 
-    //
-    // simple query with param substitution
-    //
-    @SQL(statement="SELECT * FROM USERS WHERE userid={someUserId}")
+    /**
+     * Simple query with param substitution.
+     *
+     * @param someUserId
+     * @return ResultSet
+     * @throws SQLException
+     */
+    @SQL(statement = "SELECT * FROM USERS WHERE userid={someUserId}")
     public ResultSet getSomeUser(int someUserId) throws SQLException;
 
-    //
-    // query with sql substitution
-    //
-    @SQL(statement="SELECT * FROM USERS WHERE {sql: where}")
+    /**
+     * Query with sql substitution.
+     *
+     * @param where
+     * @return ResultSet
+     * @throws SQLException
+     */
+    @SQL(statement = "SELECT * FROM USERS WHERE {sql: where}")
     public ResultSet getJustOneUser(String where) throws SQLException;
 
-    // query using ComplexSqlFragments in a sql: substitution
-    @SQL(statement="SELECT * FROM USERS {sql: cwc.whereClause}")
+    /**
+     * Query using ComplexSqlFragments in a sql: substitution.
+     *
+     * @param cwc
+     * @return ResultSEt
+     */
+    @SQL(statement = "SELECT * FROM USERS {sql: cwc.whereClause}")
     public ResultSet whereClauseSql(ComplexWhereClause cwc);
 
-    // query using ComplexSqlFragments in a parameter substitution
-    @SQL(statement="SELECT * FROM USERS {cwc.whereClause}")
+    /**
+     * Query using ComplexSqlFragments in a parameter substitution.
+     *
+     * @param cwc
+     * @return ResultSet
+     */
+    @SQL(statement = "SELECT * FROM USERS {cwc.whereClause}")
     public ResultSet whereClauseSub(ComplexWhereClause cwc);
 
-    //
-    // query returning an array of Object
-    //
-    @SQL(statement="SELECT * FROM USERS")
+    /**
+     * Query returning an array of Object
+     *
+     * @return Customer[]
+     * @throws SQLException
+     */
+    @SQL(statement = "SELECT * FROM USERS")
     public Customer[] getCustomerArray() throws SQLException;
 
-    //
-    // query returning an array of Object / array size is limited in annotation
-    //
-    @SQL(statement="SELECT * FROM USERS", arrayMaxLength=2)
+    /**
+     * Query returning an array of Object / array size is limited in annotation.
+     *
+     * @return Customer[]
+     * @throws SQLException
+     */
+    @SQL(statement = "SELECT * FROM USERS", arrayMaxLength = 2)
     public Customer[] getCustomerArrayLimitedSize() throws SQLException;
 
-    //
-    // query returning an array of Object / array size is limited in annotation
-    //
-    @SQL(statement="SELECT * FROM USERS", arrayMaxLength=2, maxRows=1)
+    /**
+     * Query returning an array of Object / array size is limited in annotation.
+     *
+     * @return Customer[]
+     * @throws SQLException
+     */
+    @SQL(statement = "SELECT * FROM USERS", arrayMaxLength = 2, maxRows = 1)
     public Customer[] getCustomerArrayLimitedSize2() throws SQLException;
 
-    //
-    // query returning an array of Object / array size is limited in annotation
-    //
-    @SQL(statement="SELECT * FROM USERS", arrayMaxLength=2, maxRows=4)
+    /**
+     * Query returning an array of Object / array size is limited in annotation.
+     *
+     * @return Customer[]
+     * @throws SQLException
+     */
+    @SQL(statement = "SELECT * FROM USERS", arrayMaxLength = 2, maxRows = 4)
     public Customer[] getCustomerArrayLimitedSize3() throws SQLException;
 
-    //
-    // query returning an array of Object / array size is limited in annotation by maxRows
-    //
-    @SQL(statement="SELECT * FROM USERS", maxRows=1)
+    /**
+     * Query returning an array of Object / array size is limited in annotation by maxRows.
+     *
+     * @return Customer[]
+     * @throws SQLException
+     */
+    @SQL(statement = "SELECT * FROM USERS", maxRows = 1)
     public Customer[] getCustomerArrayLimitedSize4() throws SQLException;
 
-    //
-    // query returning an array of Object / array size is limited in annotation by maxRows
-    //
-    @SQL(statement="SELECT * FROM USERS", maxRows=JdbcControl.MAXROWS_ALL, arrayMaxLength=JdbcControl.MAXROWS_ALL)
+    /**
+     * Query returning an array of Object / array size is limited in annotation by maxRows.
+     *
+     * @return Customer[]
+     * @throws SQLException
+     */
+    @SQL(statement = "SELECT * FROM USERS", maxRows = JdbcControl.MAXROWS_ALL, arrayMaxLength = JdbcControl.MAXROWS_ALL)
     public Customer[] getCustomerArrayLimitedSize5() throws SQLException;
 
-    //
-    // query returning an array of Object / array size is limited in annotation by maxArrayLength
-    //
-    @SQL(statement="SELECT * FROM USERS", arrayMaxLength=JdbcControl.MAXROWS_ALL)
+    /**
+     * Query returning an array of Object / array size is limited in annotation by maxArrayLength.
+     *
+     * @return Customer[]
+     * @throws SQLException
+     */
+    @SQL(statement = "SELECT * FROM USERS", arrayMaxLength = JdbcControl.MAXROWS_ALL)
     public Customer[] getCustomerArrayLimitedSize6() throws SQLException;
 
-    //
-    // query returning a HashMap
-    //
-    @SQL(statement="SELECT * FROM USERS WHERE userid={someUserId}")
+    /**
+     * Query returning a HashMap.
+     *
+     * @param someUserId
+     * @return HashMap
+     * @throws SQLException
+     */
+    @SQL(statement = "SELECT * FROM USERS WHERE userid={someUserId}")
     public HashMap getCustomerHashMap(int someUserId) throws SQLException;
 
-    //
-    // query returning an array of HashMap
-    //
-    @SQL(statement="SELECT * FROM USERS WHERE userid={someUserId}")
+    /**
+     * Query returning an array of HashMap.
+     *
+     * @param someUserId
+     * @return HashMap[]
+     * @throws SQLException
+     */
+    @SQL(statement = "SELECT * FROM USERS WHERE userid={someUserId}")
     public HashMap[] getCustomerHashMapArray(int someUserId) throws SQLException;
 
-    //
-    // query returning a Map
-    //
-    @SQL(statement="SELECT * FROM USERS WHERE userid={someUserId}")
+    /**
+     * Query returning a Map.
+     *
+     * @param someUserId
+     * @return Map
+     * @throws SQLException
+     */
+    @SQL(statement = "SELECT * FROM USERS WHERE userid={someUserId}")
     public Map getCustomerMap(int someUserId) throws SQLException;
 
-    //
-    // query returning an iterator
-    //
-    @SQL(statement="SELECT * FROM USERS", iteratorElementType=Customer.class)
+    /**
+     * Query returning an iterator.
+     *
+     * @return Iterator
+     * @throws SQLException
+     */
+    @SQL(statement = "SELECT * FROM USERS", iteratorElementType = Customer.class)
     public Iterator getCustomerIterator() throws SQLException;
 
-    //
-    // query returning an empty value
-    //
-    @SQL(statement="SELECT * FROM USERS WHERE userid={someUserId}")
+    /**
+     * Query returning an empty value.
+     *
+     * @param someUserId
+     * @return int
+     * @throws SQLException
+     */
+    @SQL(statement = "SELECT * FROM USERS WHERE userid={someUserId}")
     public int getNoUsers(int someUserId) throws SQLException;
 
-    //
-    // query returning an object
-    //
-    @SQL(statement="SELECT * FROM USERS WHERE userid={someUserId}")
+    /**
+     * Query returning an object.
+     *
+     * @param someUserId
+     * @return Customer
+     * @throws SQLException
+     */
+    @SQL(statement = "SELECT * FROM USERS WHERE userid={someUserId}")
     public Customer getACustomer(int someUserId) throws SQLException;
 
-    //
-    // query returning a RowSet -- NOTE: uses default row set mapper
-    //
-    @SQL(statement="SELECT * FROM USERS", resultSetMapper=DefaultRowSetResultSetMapper.class)
+    /**
+     * Query returning a RowSet -- NOTE: uses default row set mapper.
+     *
+     * @return RowSet
+     * @throws SQLException
+     */
+    @SQL(statement = "SELECT * FROM USERS", resultSetMapper = DefaultRowSetResultSetMapper.class)
     public RowSet getAllUsersINRS() throws SQLException;
 
-    //
-    // query returning an XmlObject
-    //
-    @SQL(statement="SELECT * FROM XBEAN_USERS WHERE stooge_name={someStooge}")
+    /**
+     * Query returning an XmlObject.
+     *
+     * @param someStooge
+     * @return XStoogeRowDocument.XStoogeRow
+     * @throws SQLException
+     */
+    @SQL(statement = "SELECT * FROM XBEAN_USERS WHERE stooge_name={someStooge}")
     public XStoogeRowDocument.XStoogeRow getAUserXmlBean(String someStooge) throws SQLException;
 
-    //
-    // query returning an array of XmlObjects
-    //
-    @SQL(statement="SELECT * FROM XBEAN_USERS")
+    /**
+     * Query returning an array of XmlObjects.
+     *
+     * @return XStoogeRowDocument.XStoogeRow[]
+     * @throws SQLException
+     */
+    @SQL(statement = "SELECT * FROM XBEAN_USERS")
     public XStoogeRowDocument.XStoogeRow[] getAllUserXmlBean() throws SQLException;
 
-    //
-    // set a db row with a XmlObject
-    //
-    @SQL(statement="insert into XBEAN_USERS VALUES ({stooge.STOOGENAME}, {stooge.STOOGEPECKINGORDER}, {stooge.STOOGEPANTSIZE})")
+    /**
+     * Set a db row with a XmlObject.
+     *
+     * @param stooge
+     * @throws SQLException
+     */
+    @SQL(statement = "insert into XBEAN_USERS VALUES ({stooge.STOOGENAME}, {stooge.STOOGEPECKINGORDER}, {stooge.STOOGEPANTSIZE})")
     public void insertAXmlBean(XStoogeRowDocument.XStoogeRow stooge) throws SQLException;
 
-    //
-    // query which invokes a stored procedure
-    //
-    @SQL(statement="{CALL getExpensiveProductSP(?)}")
+    //todo: more doc tests
+
+    /**
+     * Query returning Document type element.
+     *
+     * @param key
+     * @return XCustomerDocument
+     */
+    @JdbcControl.SQL(statement = "SELECT custid, name, address, city, state, zip, area_code, phone FROM customer WHERE custid = {key}")
+    public XCustomerDocument getCustomerByID(int key);
+
+    /**
+     * Query returning all customers in an XCustomerDocument.
+     *
+     * @return XCustomerDocument
+     */
+    @JdbcControl.SQL(statement = "SELECT * FROM customer")
+    public XCustomerDocument findAllCustomersDoc();
+
+    /**
+     * Query returning all customer names.
+     * @return XCustomerDocument
+     */
+    @JdbcControl.SQL(statement = "SELECT name FROM customer", arrayMaxLength = 100)
+    public XCustomerDocument getAllCustomerNames();
+
+    /**
+     * Query returning a customer's city.
+     * @param key
+     * @return XCustomerDocument
+     */
+    @JdbcControl.SQL(statement = "SELECT city FROM customer WHERE custid = {key}")
+    public XCustomerDocument getCustomerCityByID(int key);
+
+    /**
+     * Query which invokes a stored procedure.
+     *
+     * @param results
+     * @throws SQLException
+     */
+    @SQL(statement = "{CALL getExpensiveProductSP(?)}")
     public void getExpensiveProduct(SQLParameter[] results) throws SQLException;
 
-    //
-    // query which invokes a stored procedure
-    //
-    @SQL(statement="{call getExpensiveProductsSP(?)}")
+    /**
+     * Query which invokes a stored procedure.
+     *
+     * @param results
+     * @throws SQLException
+     */
+    @SQL(statement = "{call getExpensiveProductsSP(?)}")
     public void getExpensiveProducts(SQLParameter[] results) throws SQLException;
 
-    //
-    // query which invokes a stored procedure
-    //
-    @SQL(statement="{call getProductsByColorSP(?,?)}")
+    /**
+     * Query which invokes a stored procedure.
+     *
+     * @param results
+     * @throws SQLException
+     */
+    @SQL(statement = "{call getProductsByColorSP(?,?)}")
     public void getProductsByColor(SQLParameter[] results) throws SQLException;
 
-    //
-    // creates a stored procedure
-    //
-    @SQL(statement="CREATE PROCEDURE getProductSP(IN color VARCHAR(64), IN sku INT) " +
-                    "PARAMETER STYLE JAVA " +
-                    "READS SQL DATA " +
-                    "LANGUAGE JAVA " +
-                    "EXTERNAL NAME 'org.apache.beehive.controls.system.jdbc.units.utils.StoredProcedures.getProductSP'")
+    /**
+     * Creates a stored procedure.
+     *
+     * @throws SQLException
+     */
+    @SQL(statement = "CREATE PROCEDURE getProductSP(IN color VARCHAR(64), IN sku INT) " +
+            "PARAMETER STYLE JAVA " +
+            "READS SQL DATA " +
+            "LANGUAGE JAVA " +
+            "EXTERNAL NAME 'org.apache.beehive.controls.system.jdbc.units.utils.StoredProcedures.getProductSP'")
     public void createStoredProc() throws SQLException;
 
-    //
-    // invokes the stored proc -- with 2 IN params
-    //
-    @SQL(statement="{call getProductSP({inColor},{inSKU})}")
+    /**
+     * Invokes the stored proc -- with 2 IN params.
+     *
+     * @param inColor
+     * @param inSKU
+     * @throws SQLException
+     */
+    @SQL(statement = "{call getProductSP({inColor},{inSKU})}")
     public void getProduct(String inColor, int inSKU) throws SQLException;
 
-    //
-    // batch updates
-    //
-    @SQL(statement="INSERT INTO users VALUES ({fname}, {userid})",  batchUpdate=true)
+    /**
+     * Batch updates.
+     *
+     * @param fname
+     * @param userid
+     * @return int[]
+     */
+    @SQL(statement = "INSERT INTO users VALUES ({fname}, {userid})", batchUpdate = true)
     public int[] doABatchUpdate(String[] fname, int[] userid);
 
-    //
-    // a basic usage of the getGeneratedKeys annotation member
-    //
-    @SQL(statement="INSERT INTO usergen (person) VALUES ({aValue})", getGeneratedKeys=true)
+    /**
+     * A basic usage of the getGeneratedKeys annotation member.
+     *
+     * @param aValue
+     * @return ResultSet
+     */
+    @SQL(statement = "INSERT INTO usergen (person) VALUES ({aValue})", getGeneratedKeys = true)
     public ResultSet getGenKeys(String aValue);
 
-    //
-    // a basic usage of the getGeneratedKeys and generatedKeyColumnNames members
-    //
-    @SQL(statement="INSERT INTO usergen (person) VALUES ({aValue})", getGeneratedKeys=true, generatedKeyColumnNames = {"user_id"})
+    /**
+     * A basic usage of the getGeneratedKeys and generatedKeyColumnNames members.
+     *
+     * @param aValue
+     * @return ResultSet
+     */
+    @SQL(statement = "INSERT INTO usergen (person) VALUES ({aValue})", getGeneratedKeys = true, generatedKeyColumnNames = {"user_id"})
     public ResultSet getGenKeys2(String aValue);
 
-    //
-    // a basic usage of the getGeneratedKeys annotation member with return type mapping
-    //
-    @SQL(statement="INSERT INTO usergen (person) VALUES ({aValue})", getGeneratedKeys=true)
+    /**
+     * A basic usage of the getGeneratedKeys annotation member with return type mapping.
+     *
+     * @param aValue
+     * @return int
+     */
+    @SQL(statement = "INSERT INTO usergen (person) VALUES ({aValue})", getGeneratedKeys = true)
     public int getGenKeys3(String aValue);
 
-    //
-    // a basic usage of the getGeneratedKeys annotation member with return type mapping
-    //
-    @SQL(statement="INSERT INTO usergen (person) VALUES ({aValue})", getGeneratedKeys=true)
+    /**
+     * A basic usage of the getGeneratedKeys annotation member with return type mapping.
+     *
+     * @param aValue
+     * @return String
+     */
+    @SQL(statement = "INSERT INTO usergen (person) VALUES ({aValue})", getGeneratedKeys = true)
     public String getGenKeys4(String aValue);
 
-    //
-    // a basic usage of the getGeneratedKeys annotation member with return type mapping
-    //
-    @SQL(statement="INSERT INTO usergen (person) VALUES ({aValue})", getGeneratedKeys=true)
+    /**
+     * A basic usage of the getGeneratedKeys annotation member with return type mapping.
+     *
+     * @param aValue
+     * @return int[]
+     */
+    @SQL(statement = "INSERT INTO usergen (person) VALUES ({aValue})", getGeneratedKeys = true)
     public int[] getGenKeys5(String aValue);
 
-    //
-    // a basic usage of the getGeneratedKeys and generatedKeyColumnIndexes annotation members
-    //
-    @SQL(statement="INSERT INTO usergen (person) VALUES ({aValue})", getGeneratedKeys=true, generatedKeyColumnIndexes = {1})
+    /**
+     * A basic usage of the getGeneratedKeys and generatedKeyColumnIndexes annotation members.
+     *
+     * @param aValue
+     * @return ResultSet
+     */
+    @SQL(statement = "INSERT INTO usergen (person) VALUES ({aValue})", getGeneratedKeys = true, generatedKeyColumnIndexes = {1})
     public ResultSet getGenKeys6(String aValue);
 
-    //
-    // a basic usage of the scrollableResultSet element
-    //
-    @SQL(statement="SELECT * FROM USERS", scrollableResultSet=ScrollType.SCROLL_INSENSITIVE_UPDATABLE)
+    /**
+     * A basic usage of the scrollableResultSet element.
+     *
+     * @return ResultSet
+     */
+    @SQL(statement = "SELECT * FROM USERS", scrollableResultSet = ScrollType.SCROLL_INSENSITIVE_UPDATABLE)
     public ResultSet getScrollableResultSet_IU();
 
-    //
-    // a basic usage of the scrollableResultSet element
-    //
-    @SQL(statement="SELECT * FROM USERS", scrollableResultSet=ScrollType.SCROLL_SENSITIVE)
+    /**
+     * A basic usage of the scrollableResultSet element.
+     *
+     * @return ResultSet
+     */
+    @SQL(statement = "SELECT * FROM USERS", scrollableResultSet = ScrollType.SCROLL_SENSITIVE)
     public ResultSet getScrollableResultSet_SR();
 
-    //
-    // a basic usage of the fetchSize/fetchDirection elements
-    //
-    @SQL(statement="SELECT * FROM USERS", fetchDirection=FetchDirection.REVERSE, fetchSize=10)
+    /**
+     * A basic usage of the fetchSize/fetchDirection elements.
+     *
+     * @return ResultSet
+     */
+    @SQL(statement = "SELECT * FROM USERS", fetchDirection = FetchDirection.REVERSE, fetchSize = 10)
     public ResultSet getFetchOptmizedResultSet();
 
-    //
-    // query with non-default holdability specified
-    //
-    @SQL(statement="SELECT * FROM USERS", resultSetHoldabilityOverride=HoldabilityType.HOLD_CURSORS)
+    /**
+     * Query with non-default holdability specified.
+     *
+     * @return ResultSet
+     */
+    @SQL(statement = "SELECT * FROM USERS", resultSetHoldabilityOverride = HoldabilityType.HOLD_CURSORS)
     public ResultSet getResultSetHoldablity();
 
-    //
-    // select a single column of values from the users table,
-    // specifically tests mapping single column result set values to return type
-    //
-    @SQL(statement="SELECT fname FROM users")
+    /**
+     * Select a single column of values from the users table,
+     * specifically tests mapping single column result set values to return type.
+     *
+     * @return String[]
+     */
+    @SQL(statement = "SELECT fname FROM users")
     public String[] getFnameColumn();
 
     //
     // /////////////////////////////// methods for JDBC types tests ////////////////////////////////////////
     //
 
-    //
-    // insert a blob
-    //
-    @SQL(statement="INSERT INTO blob_table VALUES ({id}, {blob})")
+    /**
+     * Insert a blob.
+     *
+     * @param id
+     * @param blob
+     * @return int
+     */
+    @SQL(statement = "INSERT INTO blob_table VALUES ({id}, {blob})")
     public int insertABlob(int id, Blob blob);
 
-    //
-    // select a blob
-    //
-    @SQL(statement="SELECT blb FROM blob_table WHERE id={id}")
+    /**
+     * Select a blob.
+     *
+     * @param id
+     * @return BlobInfo
+     */
+    @SQL(statement = "SELECT blb FROM blob_table WHERE id={id}")
     public BlobInfo getABlob(int id);
 
-    //
-    // select a clob
-    //
-    @SQL(statement="SELECT clb FROM clob_table WHERE id={id}")
+    /**
+     * Select a clob.
+     *
+     * @param id
+     * @return Clob
+     */
+    @SQL(statement = "SELECT clb FROM clob_table WHERE id={id}")
     public Clob getAClob(int id);
 
-    //
-    // get a char
-    //
-    @SQL(statement="SELECT c FROM basic_types")
+    /**
+     * Get a char.
+     *
+     * @return String
+     */
+    @SQL(statement = "SELECT c FROM basic_types")
     public String getChar();
 
-    //
-    // get a char string
-    //
-    @SQL(statement="SELECT ca FROM basic_types")
+    /**
+     * Get a char string.
+     *
+     * @return String
+     */
+    @SQL(statement = "SELECT ca FROM basic_types")
     public String getChar2();
 
-    //
-    // varchar test
-    //
-    @SQL(statement="SELECT vc FROM basic_types")
+    /**
+     * varchar test.
+     *
+     * @return String
+     */
+    @SQL(statement = "SELECT vc FROM basic_types")
     public String getVarchar();
 
-    //
-    // long varchar test
-    //
-    @SQL(statement="SELECT lvc FROM basic_types")
+    /**
+     * long varchar test.
+     *
+     * @return String
+     */
+    @SQL(statement = "SELECT lvc FROM basic_types")
     public String getLongvarchar();
 
-    //
-    // fixed length binary
-    //
-    @SQL(statement="SELECT bin FROM basic_types")
+    /**
+     * fixed length binary.
+     *
+     * @return Binary
+     */
+    @SQL(statement = "SELECT bin FROM basic_types")
     public Binary getFixedLengthBinary();
 
-    //
-    // var length binary
-    //
-    @SQL(statement="SELECT varbin FROM basic_types")
+    /**
+     * var length binary
+     *
+     * @return Binary
+     */
+    @SQL(statement = "SELECT varbin FROM basic_types")
     public Binary getVarLengthBinary();
 
-    //
-    // long binary
-    //
-    @SQL(statement="SELECT lvarbin FROM basic_types")
+    /**
+     * long binary
+     *
+     * @return Binary
+     */
+    @SQL(statement = "SELECT lvarbin FROM basic_types")
     public Binary getLongVarLengthBinary();
 
-    //
-    // small int
-    //
-    @SQL(statement="SELECT sint FROM basic_types")
+    /**
+     * small int
+     *
+     * @return short
+     */
+    @SQL(statement = "SELECT sint FROM basic_types")
     public short getSmallIntValue();
 
-    //
-    // small int
-    //
-    @SQL(statement="SELECT sint FROM basic_types")
+    /**
+     * small int
+     *
+     * @return Short
+     */
+    @SQL(statement = "SELECT sint FROM basic_types")
     public Short getSmallIntValue2();
 
-    //
-    // int
-    //
-    @SQL(statement="SELECT i FROM basic_types")
+    /**
+     * int
+     *
+     * @return Integer
+     */
+    @SQL(statement = "SELECT i FROM basic_types")
     public Integer getIntValue2();
 
-    //
-    // int
-    //
-    @SQL(statement="SELECT i FROM basic_types")
+    /**
+     * int
+     *
+     * @return int
+     */
+    @SQL(statement = "SELECT i FROM basic_types")
     public int getIntValue();
 
-    //
-    // bigint
-    //
-    @SQL(statement="SELECT bint FROM basic_types")
+    /**
+     * bigint
+     *
+     * @return long
+     */
+    @SQL(statement = "SELECT bint FROM basic_types")
     public long getBigIntValue();
 
-    //
-    // bigint
-    //
-    @SQL(statement="SELECT bint FROM basic_types")
+    /**
+     * binint
+     *
+     * @return Long
+     */
+    @SQL(statement = "SELECT bint FROM basic_types")
     public Long getBigIntValue2();
 
-    //
-    // real
-    //
-    @SQL(statement="SELECT r FROM basic_types")
+    /**
+     * real
+     *
+     * @return float
+     */
+    @SQL(statement = "SELECT r FROM basic_types")
     public float getRealValue();
 
-    //
-    // real
-    //
-    @SQL(statement="SELECT r FROM basic_types")
+    /**
+     * real
+     *
+     * @return Float
+     */
+    @SQL(statement = "SELECT r FROM basic_types")
     public Float getRealValue2();
 
-    //
-    // double precision
-    //
-    @SQL(statement="SELECT dp FROM basic_types")
+    /**
+     * double precision
+     *
+     * @return double
+     */
+    @SQL(statement = "SELECT dp FROM basic_types")
     public double getDoubleValue();
 
-    //
-    // double precision
-    //
-    @SQL(statement="SELECT dp FROM basic_types")
+    /**
+     * Double precision
+     *
+     * @return double
+     */
+    @SQL(statement = "SELECT dp FROM basic_types")
     public Double getDoubleValue2();
 
-    //
-    // decimal
-    //
-    @SQL(statement="SELECT d FROM basic_types")
+    /**
+     * decimal
+     *
+     * @return BigDecimal
+     */
+    @SQL(statement = "SELECT d FROM basic_types")
     public BigDecimal getDecimalValue();
 
-    //
-    // numeric
-    //
-    @SQL(statement="SELECT nu FROM basic_types")
+    /**
+     * numeric
+     *
+     * @return BigDecimal
+     */
+    @SQL(statement = "SELECT nu FROM basic_types")
     public BigDecimal getNumericValue();
 
-    //
-    // date
-    //
-    @SQL(statement="SELECT dt FROM basic_types")
+    /**
+     * date
+     *
+     * @return java.sql.Date
+     */
+    @SQL(statement = "SELECT dt FROM basic_types")
     public java.sql.Date getDateValue();
 
-    //
-    // time
-    //
-    @SQL(statement="SELECT t FROM basic_types")
+    /**
+     * time
+     *
+     * @return Time
+     */
+    @SQL(statement = "SELECT t FROM basic_types")
     public Time getTimeValue();
 
-    //
-    // timestamp
-    //
-    @SQL(statement="SELECT ts FROM basic_types")
+    /**
+     * timestamp
+     *
+     * @return java.sql.Timestamp
+     */
+    @SQL(statement = "SELECT ts FROM basic_types")
     public java.sql.Timestamp getTimestampValue();
 
-    //
-    // serialization - int
-    //
-    @SQL(statement="SELECT i FROM basic_types_ser")
+    /**
+     * serialization
+     *
+     * @return int
+     */
+    @SQL(statement = "SELECT i FROM basic_types_ser")
     public int getIntValueSer();
 
 }

Added: beehive/trunk/system-controls/test/jdbc/controls/schemas/customer/XCustomer.xsd
URL: http://svn.apache.org/viewvc/beehive/trunk/system-controls/test/jdbc/controls/schemas/customer/XCustomer.xsd?view=auto&rev=472654
==============================================================================
--- beehive/trunk/system-controls/test/jdbc/controls/schemas/customer/XCustomer.xsd (added)
+++ beehive/trunk/system-controls/test/jdbc/controls/schemas/customer/XCustomer.xsd Wed Nov  8 13:48:22 2006
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema targetNamespace="java:///database/customer_db" xmlns="java:///database/customer_db" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
+  <xsd:element name="XCustomer" wld:DefaultNamespace="java:///database/customer_db">
+    <xsd:complexType>
+      <xsd:choice maxOccurs="unbounded">
+        <xsd:element name="XCustomerRow">
+          <xsd:complexType>
+            <xsd:sequence>
+              <xsd:element name="CUSTID" type="xsd:int" minOccurs="0" nillable="true"></xsd:element>
+              <xsd:element name="NAME" type="xsd:string" minOccurs="0" nillable="true"></xsd:element>
+              <xsd:element name="ADDRESS" type="xsd:string" minOccurs="0" nillable="true"></xsd:element>
+              <xsd:element name="CITY" type="xsd:string" minOccurs="0" nillable="true"></xsd:element>
+              <xsd:element name="STATE" type="xsd:string" minOccurs="0" nillable="true"></xsd:element>
+              <xsd:element name="ZIP" type="xsd:string" minOccurs="0" nillable="true"></xsd:element>
+              <xsd:element name="AREA_CODE" type="xsd:string" minOccurs="0" nillable="true"></xsd:element>
+              <xsd:element name="PHONE" type="xsd:string" minOccurs="0" nillable="true"></xsd:element>
+            </xsd:sequence>
+          </xsd:complexType>
+        </xsd:element>
+      </xsd:choice>
+    </xsd:complexType>
+  </xsd:element>
+</xsd:schema>
\ No newline at end of file

Added: beehive/trunk/system-controls/test/jdbc/junitTests/org/apache/beehive/controls/system/jdbc/units/results/XmlBeanDocResultsTest.java
URL: http://svn.apache.org/viewvc/beehive/trunk/system-controls/test/jdbc/junitTests/org/apache/beehive/controls/system/jdbc/units/results/XmlBeanDocResultsTest.java?view=auto&rev=472654
==============================================================================
--- beehive/trunk/system-controls/test/jdbc/junitTests/org/apache/beehive/controls/system/jdbc/units/results/XmlBeanDocResultsTest.java (added)
+++ beehive/trunk/system-controls/test/jdbc/junitTests/org/apache/beehive/controls/system/jdbc/units/results/XmlBeanDocResultsTest.java Wed Nov  8 13:48:22 2006
@@ -0,0 +1,133 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.controls.system.jdbc.units.results;
+
+import org.apache.beehive.controls.test.junit.ControlTestCase;
+import org.apache.beehive.controls.api.bean.Control;
+import org.apache.beehive.controls.system.jdbc.test.results.ResultsTestCtrl;
+
+import java.sql.Connection;
+import java.sql.Statement;
+
+import test.customerDb.XStoogeRowDocument;
+import test.customerDb.SMLXSizeType;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import databaseCustomerDb.XCustomerDocument;
+
+/**
+ *
+ */
+public class XmlBeanDocResultsTest extends ControlTestCase {
+
+    @Control
+    public ResultsTestCtrl testCtrl;
+
+    public void setUp() throws Exception {
+        super.setUp();
+
+        Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
+        Connection conn = testCtrl.getConnection();
+        Statement s = conn.createStatement();
+        try {
+            s.executeUpdate("drop table CUSTOMER");
+        } catch (Exception e) {
+        }
+        s.executeUpdate("create table CUSTOMER (custid int, name varchar(30), address varchar(30), city varchar(30), state varchar(2), zip varchar(5), area_code varchar(3), phone varchar(8))");
+        s.executeUpdate("insert into CUSTOMER values (1, 'Fred', '123 Sl Cir','Brook', 'MA', '12345', '123', '111-2222' )");
+        s.executeUpdate("insert into CUSTOMER values (2, 'Marnie', '5 Hitch Ln', 'Philly', 'PA', '12345', '456', '333-4444')");
+        s.executeUpdate("insert into CUSTOMER values (3, 'Bill', '655 Tall Road', 'Port', 'OR', '12345', '789', '444-5555')");
+        conn = null;
+    }
+
+    /**
+     * Test a document return type.
+     */
+    public void testSingleCustomerRow() throws Exception {
+        XCustomerDocument customerDoc = testCtrl.getCustomerByID(2);
+        assertNotNull(customerDoc);
+
+        XCustomerDocument.XCustomer.XCustomerRow[] rowArray =
+                customerDoc.getXCustomer().getXCustomerRowArray();
+        assertNotNull(rowArray);
+        assertEquals(1, rowArray.length);
+
+        XCustomerDocument.XCustomer.XCustomerRow xcust = rowArray[0];
+        assertEquals(2, xcust.getCUSTID());
+        assertEquals("Marnie", xcust.getNAME());
+        assertEquals("5 Hitch Ln", xcust.getADDRESS());
+        assertEquals("Philly", xcust.getCITY());
+        assertEquals("PA", xcust.getSTATE());
+        assertEquals("12345", xcust.getZIP());
+        assertEquals("456", xcust.getAREACODE());
+        assertEquals("333-4444", xcust.getPHONE());
+    }
+
+    /**
+     * Test returning all customer rows inside of the document type.
+     */
+    public void testAllCustomerRows() throws Exception {
+        XCustomerDocument customerDoc = testCtrl.findAllCustomersDoc();
+        assertNotNull(customerDoc);
+
+        XCustomerDocument.XCustomer.XCustomerRow[] rowArray =
+                customerDoc.getXCustomer().getXCustomerRowArray();
+
+        assertNotNull(rowArray);
+        assertEquals(3, rowArray.length);
+    }
+
+    /**
+     * Get all the customer names in the db.
+     */
+    public void testGetAllCustomerNames() throws Exception {
+        XCustomerDocument customerDoc = testCtrl.getAllCustomerNames();
+        assertNotNull(customerDoc);
+
+        XCustomerDocument.XCustomer.XCustomerRow[] rowArray =
+                customerDoc.getXCustomer().getXCustomerRowArray();
+        assertNotNull(rowArray);
+        assertEquals(3, rowArray.length);
+
+        assertEquals("Fred", rowArray[0].getNAME());
+        assertEquals("Marnie", rowArray[1].getNAME());
+        assertEquals("Bill", rowArray[2].getNAME());
+    }
+
+    /**
+     * Get a customer's city by the customers id.
+     * @throws Exception
+     */
+    public void testGetCustomerCityByID() throws Exception {
+        XCustomerDocument customerDoc = testCtrl.getCustomerCityByID(3);
+        assertNotNull(customerDoc);
+
+        XCustomerDocument.XCustomer.XCustomerRow[] rowArray =
+                customerDoc.getXCustomer().getXCustomerRowArray();
+        assertNotNull(rowArray);
+        assertEquals(1, rowArray.length);
+        assertEquals("Port", rowArray[0].getCITY());
+    }
+
+    public static Test suite() { return new TestSuite(XmlBeanDocResultsTest.class); }
+    public static void main(String[] args) { junit.textui.TestRunner.run(XmlBeanDocResultsTest.suite()); }
+}