[teiid-commits] teiid SVN: r1038 - in trunk: connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base and 7 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Wed Jun 10 16:15:21 EDT 2009


Author: shawkins
Date: 2009-06-10 16:15:20 -0400 (Wed, 10 Jun 2009)
New Revision: 1038

Added:
   trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/cache/CachingOutputStream.java
Modified:
   trunk/build/kit-embedded/deploy.properties
   trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/ExecutionInfo.java
   trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/cache/CachingInputStreamFilter.java
   trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPDocBuilder.java
   trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPExecutor.java
   trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/streaming/ElementProcessor.java
   trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/streaming/StreamingMultiPathFilter.java
   trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/streaming/StreamingResultsProducer.java
   trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/TestElementCollector.java
   trunk/documentation/quick-start-example/src/main/docbook/en-US/content/download.xml
   trunk/documentation/quick-start-example/src/main/docbook/en-US/content/preface.xml
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
   trunk/engine/src/main/resources/com/metamatrix/dqp/i18n.properties
Log:
forward merging 6.1 changes

Modified: trunk/build/kit-embedded/deploy.properties
===================================================================
--- trunk/build/kit-embedded/deploy.properties	2009-06-10 17:06:09 UTC (rev 1037)
+++ trunk/build/kit-embedded/deploy.properties	2009-06-10 20:15:20 UTC (rev 1038)
@@ -1,20 +1,82 @@
-# This is properties file used for bootstrap Teiid embedded for loading
-
-#Path to the Teiid Configuration file (legacy, use deploy.properties)
-dqp.configFile=./deploy/configuration.xml
-
-# Path to the directory where the VDBs are located, or list of VDBS separated by ";"
-vdb.definition=./deploy/
-
-#Log file (optional) - will be modified to include the instance name, i.e. teiid_1.log 
-dqp.logFile=./log/teiid.log
-
-#Logging level (CRITICAL=1,ERROR=2,WARNING=3,INFO=4,DETAIL=5) (optional: default 3) 
-dqp.logLevel=3
-
-#Extensions directory - where the Connector Binding's classpath jar files are loaded.
-#Use of this property is an implicit declaration that each Connector Binding has its own Class Loader.
-dqp.extensions=./extensions/
-
-#Path to instance specific temporary information for caching, buffering, and transactions
+#
+# This is properties file used for bootstrap Teiid embedded for loading
+#
+
+#Path to the Teiid Configuration file
+dqp.configFile=./deploy/configuration.xml
+
+# Path to the directory where the VDBs are located, or list of VDBS separated by ";"
+vdb.definition=./deploy/
+
+#Log file (optional) - will be modified to include the instance name, i.e. teiid_1.log 
+dqp.logFile=./log/teiid.log
+
+#Logging level (CRITICAL=1,ERROR=2,WARNING=3,INFO=4,DETAIL=5) (optional: default 3) 
+dqp.logLevel=3
+
+#Extensions directory - where the Connector Binding's classpath jar files are loaded.
+#Use of this property is an implicit declaration that each Connector Binding has its own Class Loader.
+dqp.extensions=./extensions/
+
+#Path to instance specific temporary information for caching, buffering, and transactions
 dqp.workdir=./work
+
+#Jars to load, which will be available to all services: UDFs, command logging, etc.
+#dqp.extension.CommonClasspath=extensionjar:x.jar,extensionjar:y.jar
+
+#Location of the UDF model
+#dqp.userDefinedFunctionsFile=extensionjar:FunctionDefinition.xmi
+
+#
+# Processor settings
+# 
+
+#Process pool maximum thread count. (default 64)
+#ProcessPoolMaxThreads=64
+
+#Query processor time slice, in milliseconds. (default 2000)
+#ProcessorTimeslice=2000
+
+#Maximum allowed fetch size, set via JDBC. User requested value ignored above this value. (default 20000)
+#MaxFetchSize=20000
+
+#The maximum number of query plans that are cached. Note: this is a memory based cache. (default 250) 
+#MaxPlanCacheSize=250
+
+#
+# BufferManager Settings
+#
+
+#The max size of a batch sent between connector and query service. Should be even multiple of processorBatchSize. (default 2000)
+#dqp.buffer.connectorBatchSize=2000
+
+#The max size of a batch sent internally within the query processor. Should be <= the connectorBatchSize. (default 2000)
+#dqp.buffer.processorBatchSize=2000
+
+#Defines whether to use disk buffering or not. (default 64)
+#dqp.buffer.useDisk=true
+
+#The numeric memory size in MB, to be used before disk buffering kicks in (default 64)
+#dqp.buffer.memory=64
+
+#
+# Cache Settings
+#
+
+#Maximum number of cached lookup tables. Note: this is a memory based cache. (default 20)
+#MaxCodeTables=50
+
+#Maximum number of records in a single lookup table (default 10000)
+#MaxCodeTableRecords=10000
+
+#Denotes whether or not result set caching is enabled. (default false)
+#ResultSetCacheEnabled=false
+
+#The maximum size in MB the result set cache will be allowed to grow to before objects are removed. 0 indicates no limit. (default 50)
+#ResultSetCacheSize=50
+
+#The maximum time a result set will be kept in cache before being automatically cleared. 0 indicates no limit. (default 3600000)
+#ResultSetCacheMaxAge=3600000
+
+#Defines whether caching is restricted to a specific session ('session') or a specific VDB version ('vdb'). (default vdb)	
+#ResultSetCacheScope=vdb
\ No newline at end of file

Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/ExecutionInfo.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/ExecutionInfo.java	2009-06-10 17:06:09 UTC (rev 1037)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/ExecutionInfo.java	2009-06-10 20:15:20 UTC (rev 1038)
@@ -57,6 +57,8 @@
     private Properties m_schemaProps;
     private String m_tablePath;
     private String m_location;
+	private Map<String, String> m_prefixToNamespace;
+	private Map<String, String> m_namespaceToPrefix;
     
     public ExecutionInfo() { 
         m_columnCount = 0;
@@ -159,42 +161,58 @@
 		return result;
 	}
 
-	public Map<String, String> getNamespaces() throws ConnectorException {
-		Map<String, String> result = new HashMap<String, String>();
-		String namespacePrefixes = getOtherProperties().getProperty(
-                Constants.NAMESPACE_PREFIX_PROPERTY_NAME);
-		if (namespacePrefixes == null || namespacePrefixes.trim().length() == 0) {
-            return null;
-        }
-        String prefix = null;
-        String uri = null;
-        try {
-            String xml = "<e " + namespacePrefixes + "/>"; //$NON-NLS-1$ //$NON-NLS-2$
-            Reader reader = new StringReader(xml);
-            SAXBuilder builder = new SAXBuilder();
-            Document domDoc = builder.build(reader);
-            Element elem = domDoc.getRootElement();
-            List namespaces = elem.getAdditionalNamespaces();
-            for (Iterator iter = namespaces.iterator(); iter.hasNext();) {
-                Object o = iter.next();
-                Namespace namespace = (Namespace) o;
-                prefix = namespace.getPrefix();
-                uri = namespace.getURI();
-                result.put(prefix, uri);
-            }
-        } catch (JDOMException e) {
-            String rawMsg = Messages
-                    .getString("Executor.jaxen.error.on.namespace.pairs"); //$NON-NLS-1$
-            Object[] objs = new Object[2];
-            objs[0] = prefix;
-            objs[1] = uri;
-            String msg = MessageFormat.format(rawMsg, objs);
-            throw new ConnectorException(e, msg);
-        } catch (IOException e) {
-            throw new ConnectorException(e, e.getMessage());
-        }
-        return result;
+	public Map<String, String> getNamespaceToPrefixMap() throws ConnectorException {
+		if(null != m_namespaceToPrefix) {
+			return m_namespaceToPrefix;
+		} else {
+			getPrefixToNamespacesMap();
+			return m_namespaceToPrefix;
+		}
 	}
+	
+	public Map<String, String> getPrefixToNamespacesMap() throws ConnectorException {
+		if (null != m_prefixToNamespace) {
+			return m_prefixToNamespace;
+		} else {
+			m_prefixToNamespace = new HashMap<String, String>();
+			m_namespaceToPrefix = new HashMap<String, String>();
+			String namespacePrefixes = getOtherProperties().getProperty(
+					Constants.NAMESPACE_PREFIX_PROPERTY_NAME);
+			if (namespacePrefixes == null
+					|| namespacePrefixes.trim().length() == 0) {
+				return null;
+			}
+			String prefix = null;
+			String uri = null;
+			try {
+				String xml = "<e " + namespacePrefixes + "/>"; //$NON-NLS-1$ //$NON-NLS-2$
+				Reader reader = new StringReader(xml);
+				SAXBuilder builder = new SAXBuilder();
+				Document domDoc = builder.build(reader);
+				Element elem = domDoc.getRootElement();
+				List namespaces = elem.getAdditionalNamespaces();
+				for (Iterator iter = namespaces.iterator(); iter.hasNext();) {
+					Object o = iter.next();
+					Namespace namespace = (Namespace) o;
+					prefix = namespace.getPrefix();
+					uri = namespace.getURI();
+					m_prefixToNamespace.put(prefix, uri);
+					m_namespaceToPrefix.put(uri, prefix);
+				}
+			} catch (JDOMException e) {
+				String rawMsg = Messages
+						.getString("Executor.jaxen.error.on.namespace.pairs"); //$NON-NLS-1$
+				Object[] objs = new Object[2];
+				objs[0] = prefix;
+				objs[1] = uri;
+				String msg = MessageFormat.format(rawMsg, objs);
+				throw new ConnectorException(e, msg);
+			} catch (IOException e) {
+				throw new ConnectorException(e, e.getMessage());
+			}
+			return m_prefixToNamespace;
+		}
+	}
 
 	public void setSchemaProperties(Properties schemaProperties) {
 		m_schemaProps = schemaProperties;

Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/cache/CachingInputStreamFilter.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/cache/CachingInputStreamFilter.java	2009-06-10 17:06:09 UTC (rev 1037)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/cache/CachingInputStreamFilter.java	2009-06-10 20:15:20 UTC (rev 1038)
@@ -65,6 +65,7 @@
 	private void chunk() {
 		if(!idCached) {
 			context.put(requestId, Boolean.TRUE);
+			idCached = true;
 		}
 		
 		if(buff.length() >= 2560) {

Copied: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/cache/CachingOutputStream.java (from rev 1034, branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/cache/CachingOutputStream.java)
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/cache/CachingOutputStream.java	                        (rev 0)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/cache/CachingOutputStream.java	2009-06-10 20:15:20 UTC (rev 1038)
@@ -0,0 +1,67 @@
+package com.metamatrix.connector.xml.cache;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.teiid.connector.api.ExecutionContext;
+
+public class CachingOutputStream extends OutputStream {
+
+	private ExecutionContext context;
+	private String requestId;
+	private Integer chunkIndex;
+	private boolean idCached = false;
+	private StringBuffer buff;
+	
+	public CachingOutputStream(ExecutionContext context, String requestId) {
+		super();
+		this.context = context;
+		this.requestId = requestId;
+		chunkIndex = Integer.valueOf(0);
+		buff = new StringBuffer();
+	}
+	
+	@Override
+	public void write(int b) throws IOException {
+		buff.append((char)b);
+		chunk();
+	}
+	
+	
+    @Override
+	public void flush() throws IOException {
+		super.flush();
+		if(buff.length()!= 0) {
+			context.put(requestId + chunkIndex.toString(), buff.toString());
+			chunkIndex++;
+			buff = new StringBuffer();
+		}
+	}
+
+	@Override
+	public void close() throws IOException {
+		flush();
+		super.close();
+	}
+
+	/**
+     * 8192 * 5 / 16
+     * 1kb * 5 / 16 bit chars = 2560 chars
+     */
+	private void chunk() {
+		if(!idCached) {
+			context.put(requestId, Boolean.TRUE);
+			idCached = true;
+		}
+		
+		if(buff.length() >= 2560) {
+			context.put(requestId + chunkIndex.toString(), buff.toString());
+			chunkIndex++;
+			buff = new StringBuffer();
+		}	
+	}
+	
+	public CachedXMLStream getCachedXMLStream() {
+		return new CachedXMLStream(context, requestId);
+	}
+}

Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPDocBuilder.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPDocBuilder.java	2009-06-10 17:06:09 UTC (rev 1037)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPDocBuilder.java	2009-06-10 20:15:20 UTC (rev 1038)
@@ -258,18 +258,32 @@
 		return builder.buildDocument(params, "SOAP-ENV:Header", namespacePrefixes);
 	}
 
-	public Document createXMLRequestDoc(List params, SOAPConnectorState state, String namespacePrefixes, String inputParmsXPath) throws ConnectorException {
-		DocumentBuilder builder = new DocumentBuilder();
-		builder.setUseTypeAttributes(state.isEncoded());
-		//use dummy root if there is none
-		final String slash = "/";
-		final String dotSlash = "./";
-		if(inputParmsXPath.equals(dotSlash) || inputParmsXPath.equals(slash) || inputParmsXPath.equals("")) {
-			inputParmsXPath = SOAPDocBuilder.DUMMY_NS_PREFIX + ":dummy";
-			namespacePrefixes = namespacePrefixes + " xmlns:" + SOAPDocBuilder.DUMMY_NS_PREFIX + "=\"" + SOAPDocBuilder.DUMMY_NS_NAME + "\"";
-		}
-		return builder.buildDocument(params, inputParmsXPath, namespacePrefixes);
-    }
+	public Document createXMLRequestDoc(List params, SOAPConnectorState state,
+			String namespacePrefixes, String inputParmsXPath)
+			throws ConnectorException {
+		Document doc;
+		DocumentBuilder builder = new DocumentBuilder();
+		builder.setUseTypeAttributes(state.isEncoded());
+		final String slash = "/";
+		final String dotSlash = "./";
+		boolean hasDummy = false;
+		if (inputParmsXPath.equals(dotSlash) || inputParmsXPath.equals(slash)
+				|| inputParmsXPath.equals("")) {
+			inputParmsXPath = SOAPDocBuilder.DUMMY_NS_PREFIX + ":dummy";
+			namespacePrefixes = namespacePrefixes + " xmlns:"
+					+ SOAPDocBuilder.DUMMY_NS_PREFIX + "=\""
+					+ SOAPDocBuilder.DUMMY_NS_NAME + "\"";
+			hasDummy = true;
+		}
+		doc = builder.buildDocument(params, inputParmsXPath, namespacePrefixes);
+		if (hasDummy) {
+			// Since there is no real root - these should all be elements
+			Element element = (Element) doc.getRootElement().getChildren().get(0);
+			element.detach();
+			doc = new Document(element);
+		}
+		return doc;
+	}
 
     private static void handleSoapFault(Element soapFault, SOAPConnectorState state) throws ConnectorException {
         String strMessage = soapFault.getChildTextTrim("faultstring"); //$NON-NLS-1$

Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPExecutor.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPExecutor.java	2009-06-10 17:06:09 UTC (rev 1037)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPExecutor.java	2009-06-10 20:15:20 UTC (rev 1038)
@@ -24,13 +24,11 @@
 package com.metamatrix.connector.xml.soap;
 
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
+import java.io.StringReader;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Properties;
 
 import javax.xml.namespace.QName;
 import javax.xml.transform.Source;
@@ -43,11 +41,9 @@
 import javax.xml.ws.soap.SOAPBinding;
 
 import org.jdom.Document;
-import org.jdom.Element;
-import org.jdom.output.DOMOutputter;
+import org.jdom.output.XMLOutputter;
 import org.teiid.connector.api.ConnectorEnvironment;
 import org.teiid.connector.api.ConnectorException;
-import org.w3c.dom.NodeList;
 
 import com.metamatrix.connector.xml.Constants;
 import com.metamatrix.connector.xml.SOAPConnectorState;
@@ -58,13 +54,15 @@
 import com.metamatrix.connector.xml.base.DocumentBuilder;
 import com.metamatrix.connector.xml.base.ExecutionInfo;
 import com.metamatrix.connector.xml.base.RequestGenerator;
+import com.metamatrix.connector.xml.cache.CachingOutputStream;
 import com.metamatrix.connector.xml.http.HTTPExecutor;
 import com.metamatrix.connector.xmlsource.soap.SecurityToken;
 
 public class SOAPExecutor extends HTTPExecutor {
 	
 	SecurityToken secToken;
-	NodeList requestNodes;
+	XMLOutputter xmlOutputter = new XMLOutputter();
+	Document doc;
 	
 	public SOAPExecutor(SOAPConnectorState state, XMLExecution execution, ExecutionInfo exeInfo) throws ConnectorException {
         super((XMLConnectorState)state, execution, exeInfo);
@@ -74,16 +72,10 @@
 		try {
 			TrustedPayloadHandler handler = execution.getConnection().getTrustedPayloadHandler();
 			ConnectorEnvironment env = execution.getConnection().getConnectorEnv();
-			Properties schemaProperties = getExeInfo().getSchemaProperties();
 			secToken = SecurityToken.getSecurityToken(env, handler);
 			
-			
-            QName svcQname = new QName(
-            		schemaProperties.getProperty(Constants.SERVICE_NAMESPACE),
-            		schemaProperties.getProperty(Constants.SERVICE_NAME));
-            QName portQName = new QName(
-            		schemaProperties.getProperty(Constants.PORT_NAMESPACE),
-            		schemaProperties.getProperty(Constants.PORT_NAME));
+            QName svcQname = new QName("http://org.apache.cxf", "foo");
+            QName portQName = new QName("http://org.apache.cxf", "bar");
             Service svc = Service.create(svcQname);
             svc.addPort(
                     portQName, 
@@ -94,35 +86,24 @@
                     portQName, 
                     Source.class, 
                     Service.Mode.PAYLOAD);
-
-            StringBuffer buffer = new StringBuffer();
-            for (int j = 0; j < requestNodes.getLength(); j++) {
-    			org.w3c.dom.Element child = (org.w3c.dom.Element) requestNodes.item(j);
-    			buffer.append(child.getNodeValue());
-    		}
             
-            ByteArrayInputStream bais = new ByteArrayInputStream(buffer.toString().getBytes());
-            Source input = new StreamSource(bais);
+            StringReader reader = new StringReader(xmlOutputter.outputString(doc));
+            Source input = new StreamSource(reader);
             // Invoke the operation.
             Source output = dispatch.invoke(input);
-
+            
             // Process the response.
-            StreamResult result = new StreamResult(new ByteArrayOutputStream());
+            CachingOutputStream out = new CachingOutputStream(execution.getExeContext(), getCacheKey());
+            StreamResult result = new StreamResult(out);
             Transformer trans = TransformerFactory.newInstance().newTransformer();
             trans.transform(output, result);
-            ByteArrayOutputStream baos = (ByteArrayOutputStream) result.getOutputStream();
-
-            // Write out the response content.
-            String responseContent = new String(baos.toByteArray());
-            System.out.println(responseContent);
-
-			return null;
+            return out.getCachedXMLStream();
 		} catch (Exception e) {
 			throw new ConnectorException(e);
 		}
 	}
 
-	protected void createRequest(List params)
+	protected void setRequests(List params, String uriString)
 			throws ConnectorException {
 		
 		SOAPConnectorState state = (SOAPConnectorState) getState();
@@ -139,24 +120,10 @@
 		String namespacePrefixes = getExeInfo().getOtherProperties().getProperty(Constants.NAMESPACE_PREFIX_PROPERTY_NAME);
 		String inputParmsXPath = getExeInfo().getOtherProperties().getProperty(DocumentBuilder.PARM_INPUT_XPATH_TABLE_PROPERTY_NAME); 
 		SOAPDocBuilder builder = new SOAPDocBuilder();
-		Document doc = builder.createXMLRequestDoc(bodyParams, (SOAPConnectorState)getState(), namespacePrefixes, inputParmsXPath);
-		Element docRoot = doc.getRootElement();
-		DOMOutputter domOutputter = new DOMOutputter();
-		try {
-			if (docRoot.getNamespaceURI().equals(SOAPDocBuilder.DUMMY_NS_NAME)) {
-				// Since there is no real root - these should all be elements
-				org.w3c.dom.Document dummyNode = domOutputter.output(doc);
-				requestNodes = dummyNode.getChildNodes().item(0).getChildNodes();
-			} else {
-				org.w3c.dom.Document document = domOutputter.output(doc);
-				requestNodes = document.getChildNodes();
-			}
-		} catch (Exception e) {
-			throw new ConnectorException(e);
-		}
+		doc = builder.createXMLRequestDoc(bodyParams, (SOAPConnectorState)getState(), namespacePrefixes, inputParmsXPath);
 	}
 
-	protected String getCacheKey(int i) throws ConnectorException {
+	protected String getCacheKey() throws ConnectorException {
         StringBuffer cacheKey = new StringBuffer();
         cacheKey.append("|"); //$NON-NLS-1$
         cacheKey.append(execution.getConnection().getUser());
@@ -164,11 +131,8 @@
         cacheKey.append(execution.getConnection().getQueryId());
         cacheKey.append("|");
         cacheKey.append(buildUriString());
-        cacheKey.append("|"); //$NON-NLS-1$
-		for (int j = 0; j < requestNodes.getLength(); j++) {
-			org.w3c.dom.Element child = (org.w3c.dom.Element) requestNodes.item(j);
-			cacheKey.append(child.toString());
-		}
+        //cacheKey.append("|"); //$NON-NLS-1$
+		//cacheKey.append(xmlOutputter.outputString(doc));
         return cacheKey.toString();
 	}
 

Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/streaming/ElementProcessor.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/streaming/ElementProcessor.java	2009-06-10 17:06:09 UTC (rev 1037)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/streaming/ElementProcessor.java	2009-06-10 20:15:20 UTC (rev 1038)
@@ -31,10 +31,12 @@
 	private Object[] row;
 	private Map<String, OutputXPathDesc> resultPaths;
 	private OutputXPathDesc cacheKeyColumn;
+	private Map<String, String> namespacesToPrefixMap;
     
 	public ElementProcessor(ExecutionInfo info) throws ConnectorException {
 		this.info = info;
 		resultPaths = generateXPaths();
+		namespacesToPrefixMap = info.getNamespaceToPrefixMap();
 	}
 	
 	/**
@@ -76,12 +78,16 @@
 	 * @param path
 	 */
 	private void listChildren(Node current, String path) {
-		   
+		
+		if(current.getDocument().equals(current.getParent())) {
+			path = getLocalQName(current);
+		}
+		
 	    if (current instanceof Element) {
 	        Element temp = (Element) current;
 	        for (int i = 0; i < temp.getAttributeCount(); i++) {
 	          Attribute attribute = temp.getAttribute(i);
-	          String attrPath = path + '@' + attribute.getQualifiedName();
+	          String attrPath = path + "/@" + getLocalQName(attribute);
 	          if(resultPaths.containsKey(attrPath)) {
 	        	  getColumn(attribute, attrPath);
 	          }
@@ -108,15 +114,45 @@
 	    	if (next instanceof Element) {
 		        Element temp = (Element) next;
 		        if(path.isEmpty()) {
-		        	childPath = temp.getQualifiedName();
+		        	childPath = getLocalQName(temp);
 		        } else {
-		        	childPath= path + '/' + temp.getQualifiedName();
+		        	childPath= path + '/' + getLocalQName(temp);
 		        }
 	    	}
 	    	listChildren(next, childPath);
 	    }
 	  }
 
+	/**
+	 * Get the qualified name for the Element, but replace the prefixes
+	 * from the actual doc with the matching prefix from the model.  Without
+	 * this prefix we can't do a proper path comparison.
+	 * @throws ConnectorException 
+	 */
+	private String getLocalQName(Node node) {
+		String namespaceURI = null;
+		String localName = null;
+		if(node instanceof Element) {
+			Element element = (Element)node;
+			namespaceURI = element.getNamespaceURI();
+			localName = element.getLocalName();
+		} else if (node instanceof Attribute) {
+			Attribute attribute = (Attribute)node;
+			namespaceURI = attribute.getNamespaceURI();
+			localName = attribute.getLocalName();
+		}
+		if(null == namespaceURI) {
+			throw new Error("namespce URI not found in model namespaces");
+		}
+		String prefix = namespacesToPrefixMap.get(namespaceURI);
+		String result;
+		if(null == prefix) {
+			result = localName;
+		} else {
+			result = prefix + ':' + localName;
+		}
+		return result;
+	}
 	
     private void getColumn(Node node, String path) {
 		OutputXPathDesc columnMetadata = resultPaths.get(path);

Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/streaming/StreamingMultiPathFilter.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/streaming/StreamingMultiPathFilter.java	2009-06-10 17:06:09 UTC (rev 1037)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/streaming/StreamingMultiPathFilter.java	2009-06-10 20:15:20 UTC (rev 1038)
@@ -29,7 +29,6 @@
 	}
 	
 	private PathPackage getPathPackage(String locationPath, Map<String, String> prefixes) throws InvalidPathException {
-		// copied from nux.xom.xquery.StreamingPathFilter
 		if (locationPath == null) 
 			throw new InvalidPathException("locationPath must not be null");
 		if (locationPath.indexOf("//") >= 0)
@@ -76,10 +75,10 @@
 			} // end if
 			
 			localNames[i] = localNames[i].substring(k + 1).trim();
-			if (localNames[i].equals("*")) {
+			//if (localNames[i].equals("*")) {
 				// localName is irrelevant (does not matter)
-				localNames[i] = null;
-			}
+			//	localNames[i] = null;
+			//}
 		}
 		return new PathPackage(localNames, namespaceURIs);
 	}
@@ -141,6 +140,10 @@
 		@Override
 		public Nodes finishMakingElement(Element elem) {
 			if (level == 0) {
+				// check for / match
+				if (pathPackages.isMatch(level,elem.getQualifiedName(), elem.getNamespaceURI())) {
+					return transformMatch(elem);
+				} //causes nu.xom.WellformednessException: Factory attempted to remove the root element on the request
 				mismatch = null;
 				level--;
 				return super.finishMakingElement(elem);
@@ -165,10 +168,14 @@
 			level--;
 			if (transform == null) return super.finishMakingElement(elem);
 			Nodes results = transform.transform(elem);
-
-			for (int i = results.size(); --i >= 0; ) {
-				Node node = results.get(i);
-				if (node != elem) node.detach();
+			
+			if(results.size() == 0) {
+				results = new Nodes(elem);
+			} else {
+				for (int i = results.size(); --i >= 0; ) {
+					Node node = results.get(i);
+					if (node != elem) node.detach();
+				}
 			}
 			return results;
 		}
@@ -269,9 +276,13 @@
 		public boolean isRequired(int level, String localName, String namespaceURI) {
 			String name = localNames[level];
 			String uri = namespaceURIs[level];
+			if(level == 0 && name.equals("*")) {
+				return true;
+			} else {
 			return
 				(name == null || name.equals(localName)) && 
 				(uri == null || uri.equals(namespaceURI));
+			}
 		}
 
 		public boolean hasLevelMatch(int level) {
@@ -279,8 +290,10 @@
 		}
 
 		public boolean isMatch(int level, String localName, String namespaceURI) {
-			if(level == localNames.length -1) {
-				return isRequired(level, localName, namespaceURI);
+			if(level < getPathLength()) {
+				if(level == localNames.length -1) {
+					return isRequired(level, localName, namespaceURI);
+				}
 			}
 			return false;
 		}
@@ -303,7 +316,7 @@
 			Iterator<PathPackage> iter = packages.iterator();
 			while (iter.hasNext()) {
 				PathPackage pack = iter.next();
-				if(level < pack.getPathLength() && pack.isMatch(level, localName, namespaceURI)) {
+				if(pack.isMatch(level, localName, namespaceURI)) {
 					return true;
 				}
 			}

Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/streaming/StreamingResultsProducer.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/streaming/StreamingResultsProducer.java	2009-06-10 17:06:09 UTC (rev 1037)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/streaming/StreamingResultsProducer.java	2009-06-10 20:15:20 UTC (rev 1038)
@@ -48,7 +48,7 @@
     public StreamingResultsProducer(ExecutionInfo info, XMLConnectorState state) throws ConnectorException {
         this.info = info;
     	
-		Map<String, String> namespace = info.getNamespaces();
+		Map<String, String> namespace = info.getPrefixToNamespacesMap();
 		XMLReader reader;
 		try {
 			reader = ReaderFactory.getXMLReader(state);

Modified: trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/TestElementCollector.java
===================================================================
--- trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/TestElementCollector.java	2009-06-10 17:06:09 UTC (rev 1037)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/TestElementCollector.java	2009-06-10 20:15:20 UTC (rev 1038)
@@ -70,4 +70,16 @@
 			fail(e.getMessage());
 		}
 	}
+	
+	public void testGetRoot() {
+		String path = "/";
+		int itemCount = 1;
+		try {
+			Document doc = new DocumentImpl(new FileInputStream(filename), "foo");
+			List result = builder.getElements(doc, Arrays.asList(path));
+			assertEquals(itemCount, result.size());
+		} catch (Exception e) {
+			fail(e.getMessage());
+		}
+	}
 }

Modified: trunk/documentation/quick-start-example/src/main/docbook/en-US/content/download.xml
===================================================================
--- trunk/documentation/quick-start-example/src/main/docbook/en-US/content/download.xml	2009-06-10 17:06:09 UTC (rev 1037)
+++ trunk/documentation/quick-start-example/src/main/docbook/en-US/content/download.xml	2009-06-10 20:15:20 UTC (rev 1038)
@@ -28,7 +28,9 @@
     file for Teiid Embedded, and the "lib" and "extension" directories containing binaries either directly or indirectly
     required to execute Teiid Embedded. Later sections describe installing these artifacts.</para>
   <note>
-    <para>
+    <para>Teiid Embedded requires <ulink url="http://java.sun.com/javase/downloads">Java 6</ulink> to run.
+    </para>
+  	<para>
       Access to physical data sources such as Oracle, MS-SQL Server, DB2, and Sybase through Teiid relies upon
       the user supplying their own JDBC drivers in the deployment. Teiid Embedded
       has been tested extensively with

Modified: trunk/documentation/quick-start-example/src/main/docbook/en-US/content/preface.xml
===================================================================
--- trunk/documentation/quick-start-example/src/main/docbook/en-US/content/preface.xml	2009-06-10 17:06:09 UTC (rev 1037)
+++ trunk/documentation/quick-start-example/src/main/docbook/en-US/content/preface.xml	2009-06-10 20:15:20 UTC (rev 1038)
@@ -29,7 +29,7 @@
   <note>
     <para>
       Please read 
-      <ulink url="http://teiid.org/Documentation.html">Federation Basics</ulink>
+      <ulink url="http://www.jboss.org/teiid/basics.html">Federation Basics</ulink>
       and understand different terminologies used, resources needed and artifacts that need to be generated before
       developing a successful application. This example takes advantage of only a minimal set of features from
       Teiid Embedded for the sake of simplicity and time.

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java	2009-06-10 17:06:09 UTC (rev 1037)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java	2009-06-10 20:15:20 UTC (rev 1038)
@@ -404,10 +404,13 @@
 				} else {
 					try {
 						Class legacyConnector = classloader.loadClass("com.metamatrix.data.api.Connector"); //$NON-NLS-1$
+						if (!legacyConnector.isAssignableFrom(o.getClass())) {
+							throw new ApplicationLifecycleException(DQPPlugin.Util.getString("failed_legacy", connectorClassName)); //$NON-NLS-1$
+						}
 						c = (Connector)ReflectionHelper.create("com.metamatrix.dqp.internal.datamgr.ConnectorWrapper", new Object[] {o}, new Class[] {legacyConnector}, classloader); //$NON-NLS-1$
 						this.isXa = classloader.loadClass("com.metamatrix.data.xa.api.XAConnector").isAssignableFrom(o.getClass()); //$NON-NLS-1$
 					} catch (ClassNotFoundException e) {
-						throw new ApplicationLifecycleException(e, DQPPlugin.Util.getString("failed_find_Connector_class", connectorClassName)); //$NON-NLS-1$
+						throw new ApplicationLifecycleException(e, DQPPlugin.Util.getString("failed_legacy", connectorClassName)); //$NON-NLS-1$
 					} 
 				}
 			} catch (MetaMatrixCoreException e) {

Modified: trunk/engine/src/main/resources/com/metamatrix/dqp/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/com/metamatrix/dqp/i18n.properties	2009-06-10 17:06:09 UTC (rev 1037)
+++ trunk/engine/src/main/resources/com/metamatrix/dqp/i18n.properties	2009-06-10 20:15:20 UTC (rev 1038)
@@ -37,7 +37,8 @@
 ConnectorManagerImpl.Initializing_connector=Initializing connector {0}
 ConnectorManagerImpl.Couldn__t_parse_property=Could not parse property: {0}
 Error_closing_client_connection=Error closing client connection in ConnectorManager
-failed_find_Connector_class=Could not find Connector class {0}
+failed_find_Connector_class=Could not find Connector class {0}
+failed_legacy=The specified connector class {0} is not an instance of a Teiid connector.  This may be due to an inappropriate classpath entry.  An attempt was also made to treat the class as a legacy MetaMatrix connector, however this was not successful either.
 failed_instantiate_Connector_class=Could not instantiate Connector class {0}
 failed_start_Connector=Could not start Connector {0}. {1}
 ConnectorManagerImpl.request_inactive_for_cancel=RequestID {0} is not active and the cancel request will not be processed.




More information about the teiid-commits mailing list