teiid SVN: r1671 - in branches/JCA: connectors and 14 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-12-15 18:28:12 -0500 (Tue, 15 Dec 2009)
New Revision: 1671
Added:
branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/SalesForceManagedConnectionFactory.java
branches/JCA/connectors/connector-salesforce/src/main/rar/
branches/JCA/connectors/connector-salesforce/src/main/rar/META-INF/
branches/JCA/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml
Removed:
branches/JCA/connectors/connector-salesforce/src/assembly/
branches/JCA/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/TestConnector.java
branches/JCA/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/test/util/ObjectFactory.java
Modified:
branches/JCA/build/assembly/jboss-container/connectors.xml
branches/JCA/connectors/connector-ldap/pom.xml
branches/JCA/connectors/connector-ldap/src/main/rar/META-INF/ra.xml
branches/JCA/connectors/connector-loopback/src/main/rar/META-INF/ra.xml
branches/JCA/connectors/connector-salesforce/pom.xml
branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Connector.java
branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/ConnectorState.java
branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/SalesforceConnection.java
branches/JCA/connectors/connector-text/pom.xml
branches/JCA/connectors/connector-text/src/main/rar/META-INF/ra.xml
branches/JCA/connectors/pom.xml
Log:
TEIID-861: Converted Sales Force connector to JCA connector. The credentail map based authentication needs to re-worked based on security profile
Modified: branches/JCA/build/assembly/jboss-container/connectors.xml
===================================================================
--- branches/JCA/build/assembly/jboss-container/connectors.xml 2009-12-15 20:07:33 UTC (rev 1670)
+++ branches/JCA/build/assembly/jboss-container/connectors.xml 2009-12-15 23:28:12 UTC (rev 1671)
@@ -19,6 +19,7 @@
<include>org.jboss.teiid.connectors:connector-loopback</include>
<include>org.jboss.teiid.connectors:connector-text</include>
<include>org.jboss.teiid.connectors:connector-ldap</include>
+ <include>org.jboss.teiid.connectors:connector-salesforce</include>
</includes>
<binaries>
Modified: branches/JCA/connectors/connector-ldap/pom.xml
===================================================================
--- branches/JCA/connectors/connector-ldap/pom.xml 2009-12-15 20:07:33 UTC (rev 1670)
+++ branches/JCA/connectors/connector-ldap/pom.xml 2009-12-15 23:28:12 UTC (rev 1671)
@@ -9,6 +9,7 @@
<groupId>org.jboss.teiid.connectors</groupId>
<name>LDAP Connector</name>
<description>LDAP Connector</description>
+ <packaging>rar</packaging>
<dependencies>
<dependency>
Modified: branches/JCA/connectors/connector-ldap/src/main/rar/META-INF/ra.xml
===================================================================
--- branches/JCA/connectors/connector-ldap/src/main/rar/META-INF/ra.xml 2009-12-15 20:07:33 UTC (rev 1670)
+++ branches/JCA/connectors/connector-ldap/src/main/rar/META-INF/ra.xml 2009-12-15 23:28:12 UTC (rev 1671)
@@ -7,7 +7,7 @@
version="1.5">
<vendor-name>Red Hat Middleware LLC</vendor-name>
- <eis-type>Teiid JDBC Connector</eis-type>
+ <eis-type>Teiid LDAP Connector</eis-type>
<resourceadapter-version>1.0</resourceadapter-version>
<license>
<description>
@@ -87,7 +87,7 @@
<config-property-value>10000</config-property-value>
</config-property>
- <!-- Loopback Specific properties -->
+ <!-- LDAP Specific properties -->
<config-property>
<description>Default Search Base DN</description>
Modified: branches/JCA/connectors/connector-loopback/src/main/rar/META-INF/ra.xml
===================================================================
--- branches/JCA/connectors/connector-loopback/src/main/rar/META-INF/ra.xml 2009-12-15 20:07:33 UTC (rev 1670)
+++ branches/JCA/connectors/connector-loopback/src/main/rar/META-INF/ra.xml 2009-12-15 23:28:12 UTC (rev 1671)
@@ -7,7 +7,7 @@
version="1.5">
<vendor-name>Red Hat Middleware LLC</vendor-name>
- <eis-type>Teiid JDBC Connector</eis-type>
+ <eis-type>Teiid Loopback Connector</eis-type>
<resourceadapter-version>1.0</resourceadapter-version>
<license>
<description>
Modified: branches/JCA/connectors/connector-salesforce/pom.xml
===================================================================
--- branches/JCA/connectors/connector-salesforce/pom.xml 2009-12-15 20:07:33 UTC (rev 1670)
+++ branches/JCA/connectors/connector-salesforce/pom.xml 2009-12-15 23:28:12 UTC (rev 1671)
@@ -11,6 +11,7 @@
<artifactId>connector-salesforce</artifactId>
<groupId>org.jboss.teiid.connectors</groupId>
<name>Salesforce Connector</name>
+ <packaging>rar</packaging>
<description>Integrates the query engine with Salesforce.com.</description>
<dependencies>
<dependency>
@@ -49,99 +50,27 @@
<artifactId>salesforce-api</artifactId>
<version>${project.version}</version>
</dependency>
- </dependencies>
-
- <!-- This build portion is identical for all the connectors that are deployed; so when making changes make sure
- it applies to all the connectors. This below block computes the classpath, writes to classpath.properties; it replaces
- classpath in the xml file, then bundles current project and its dependencies and xml file in a zip for deployment-->
+ <dependency>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
<build>
<plugins>
- <!-- build class path -->
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
+ <artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
- <id>build-classpath</id>
- <phase>generate-sources</phase>
+ <id>build_jar</id>
+ <phase>process-classes</phase>
<goals>
- <goal>build-classpath</goal>
+ <goal>jar</goal>
</goals>
- <configuration>
- <fileSeparator>:</fileSeparator>
- <pathSeparator>;</pathSeparator>
- <prefix>extensionjar</prefix>
- <excludeTransitive>false</excludeTransitive>
- <includeScope>runtime</includeScope>
- <excludeTypes>pom</excludeTypes>
- <outputFile>target/classpath.properties</outputFile>
- <regenerateFile>true</regenerateFile>
- <outputFilterFile>true</outputFilterFile>
- </configuration>
</execution>
</executions>
</plugin>
-
- <!-- bundles all its dependencies in a single zip file -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-dependencies</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- <configuration>
- <excludeTransitive>false</excludeTransitive>
- <includeScope>runtime</includeScope>
- <excludeTypes>pom</excludeTypes>
- <outputDirectory>target/dependency</outputDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>2.2-beta-2</version>
- <configuration>
- <descriptors>
- <descriptor>src/assembly/bundle.xml</descriptor>
- </descriptors>
- <outputDirectory>target/distribution</outputDirectory>
- <workDirectory>target/assembly/work</workDirectory>
- </configuration>
- <executions>
- <execution>
- <id>make-assembly</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
</plugins>
- <!-- replaces the classpath tokens in the xml file -->
- <filters>
- <filter>target/classpath.properties</filter>
- </filters>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>true</filtering>
- <includes>
- <include>**/*.xml</include>
- </includes>
- </resource>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>false</filtering>
- <excludes>
- <exclude>**/*.xml</exclude>
- </excludes>
- </resource>
- </resources>
- </build>
+ </build>
</project>
\ No newline at end of file
Modified: branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Connector.java
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Connector.java 2009-12-15 20:07:33 UTC (rev 1670)
+++ branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Connector.java 2009-12-15 23:28:12 UTC (rev 1671)
@@ -22,139 +22,81 @@
package com.metamatrix.connector.salesforce;
-import java.io.Serializable;
-import java.net.MalformedURLException;
-import java.net.URL;
+import javax.security.auth.Subject;
import org.teiid.connector.api.Connection;
+import org.teiid.connector.api.ConnectionContext;
import org.teiid.connector.api.ConnectorCapabilities;
import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.ConnectorLogger;
-import org.teiid.connector.api.CredentialMap;
-import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.api.ConnectorAnnotations.ConnectionPooling;
import com.metamatrix.connector.salesforce.connection.SalesforceConnection;
-@ConnectionPooling
public class Connector extends org.teiid.connector.basic.BasicConnector {
- private ConnectorLogger logger;
-
- private ConnectorEnvironment connectorEnv;
+ private SalesForceManagedConnectionFactory connectorEnv;
private ConnectorState state;
private boolean singleIdentity;
- private String username;
- private String password;
- private URL url;
- private SalesforceCapabilities salesforceCapabilites;
// ///////////////////////////////////////////////////////////
// Connector implementation
// ///////////////////////////////////////////////////////////
- public Connection getConnection(ExecutionContext secContext)
- throws ConnectorException {
- logger.logTrace("Enter SalesforceSourceConnection.getConnection()");
+ @Override
+ public Connection getConnection() throws ConnectorException {
+ getLogger().logTrace("Enter SalesforceSourceConnection.getConnection()");
Connection connection = null;
if (singleIdentity) {
- connection = new SalesforceConnection(username, password, url, connectorEnv);
+ connection = new SalesforceConnection(connectorEnv);
} else {
- Serializable trustedPayload = secContext.getTrustedPayload();
- if(trustedPayload instanceof CredentialMap) {
- CredentialMap map = (CredentialMap) trustedPayload;
- String username = map.getUser(secContext.getConnectorIdentifier());
- String password = map.getPassword(secContext.getConnectorIdentifier());
- connection = new SalesforceConnection(username, password, url, connectorEnv);
+ // if the security domain is enabled, then subject is not null.
+ Subject subject = ConnectionContext.getSubject();
+ if(subject != null) {
+ connection = new SalesforceConnection(subject, connectorEnv);
} else {
throw new ConnectorException("Unknown trusted payload type");
}
}
- logger.logTrace("Return SalesforceSourceConnection.getConnection()");
+ getLogger().logTrace("Return SalesforceSourceConnection.getConnection()");
return connection;
}
@Override
- public void start(ConnectorEnvironment env) throws ConnectorException {
- this.logger = env.getLogger();
- this.connectorEnv = env;
- getLogger().logInfo(getLogPreamble().append("Started").toString()); //$NON-NLS-1$
- this.state = new ConnectorState(env.getProperties(), getLogger());
- getLogger().logInfo(getLogPreamble().append("Initialized").toString()); //$NON-NLS-1$
- getLogger().logTrace(getLogPreamble()
- .append("Initialization Properties: " + env.getProperties()).toString()); //$NON-NLS-1$
- String urlString = env.getProperties().getProperty("URL");
- if(null != urlString && 0 != urlString.length()) {
- try {
- url = new URL(urlString);
- } catch (MalformedURLException e) {
- throw new ConnectorException(e, e.getMessage());
- }
- }
+ public void initialize(ConnectorEnvironment env) throws ConnectorException {
+ super.initialize(env);
- String username = env.getProperties().getProperty("username");
- String password = env.getProperties().getProperty("password");
+ this.connectorEnv = (SalesForceManagedConnectionFactory)env;
+ getLogger().logInfo("Started"); //$NON-NLS-1$
+ this.state = new ConnectorState(this.connectorEnv);
+
+ getLogger().logInfo("Initialized"); //$NON-NLS-1$
+ getLogger().logTrace("Initialization Properties: " + this.connectorEnv.toString()); //$NON-NLS-1$
+
//validate that both are empty or both have values
- if(null == username && null == password) {
-
- } else if ((null == username || username.equals("")) && (null != password && !password.equals("")) ||
- ((null == password || password.equals("")) && (null != username && !username.equals("")))) {
- String msg = Messages.getString("SalesforceSourceConnectionFactory.Invalid.username.password.pair");
- env.getLogger().logError(msg);
- throw new ConnectorException(msg);
- } else if(null != username && !username.equals("")) {
+ if(this.connectorEnv.getUsername() != null) {
singleIdentity = true;
- this.password = password;
- this.username = username;
- } else {
- this.setAdminConnectionsAllowed(false);
- this.setUseCredentialMap(true);
}
-
- String capabilitiesClass = env.getProperties().getProperty("ConnectorCapabilities", SalesforceCapabilities.class.getName());
- try {
- Class clazz = Thread.currentThread().getContextClassLoader().loadClass(capabilitiesClass);
- salesforceCapabilites = (SalesforceCapabilities) clazz.newInstance();
- } catch (Exception e) {
- throw new ConnectorException(e, "Unable to load Capabilities Class");
- }
- logger.logTrace("Return SalesforceSourceConnection.initialize()");
- }
- public void stop() {
- try {
- getLogger().logInfo(getLogPreamble().append("Stopped").toString());
- } catch (ConnectorException e) {
- // nothing to do here
- }
+ getLogger().logTrace("Return SalesforceSourceConnection.initialize()");
}
+
/////////////////////////////////////////////////////////////
//Utilities
/////////////////////////////////////////////////////////////
- public ConnectorLogger getLogger() throws ConnectorException {
- if(null == logger) {
- throw new ConnectorException("Error: Connector initialize not called");
- }
- return logger;
+ private ConnectorLogger getLogger(){
+ return this.config.getLogger();
}
- public StringBuffer getLogPreamble() {
- StringBuffer preamble = new StringBuffer();
- preamble.append("Salesforce Connector id = ");
- preamble.append(connectorEnv.getConnectorName());
- preamble.append(":");
- return preamble;
- }
public ConnectorState getState() {
return state;
}
@Override
- public ConnectorCapabilities getCapabilities() {
- return salesforceCapabilites;
- }
+ public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
+ return SalesforceCapabilities.class;
+ }
}
Modified: branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/ConnectorState.java
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/ConnectorState.java 2009-12-15 20:07:33 UTC (rev 1670)
+++ branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/ConnectorState.java 2009-12-15 23:28:12 UTC (rev 1671)
@@ -21,50 +21,26 @@
*/
package com.metamatrix.connector.salesforce;
-import java.net.MalformedURLException;
import java.net.URL;
-import java.util.Properties;
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorLogger;
-
public class ConnectorState {
- public static final String USERNAME = "username";
- public static final String PASSWORD = "password";
- public static final String URL = "URL";
+ private String username;
+ private String password;
+ private URL url;
- String username;
- String password;
- URL url;
-
-
- public ConnectorState(Properties props, ConnectorLogger logger) throws ConnectorException {
- if (logger == null) {
- throw new ConnectorException("Internal Exception: logger is null");
- }
-
- String username = props.getProperty(USERNAME);
+ public ConnectorState(SalesForceManagedConnectionFactory config) {
+ String username = config.getUsername();
if (username != null) {
setUsername(username);
}
- String password = props.getProperty(PASSWORD);
+ String password = config.getPassword();
if (password != null) {
setPassword(password);
}
-
- String url = props.getProperty(URL);
- if(null != url && url.length()!= 0) {
- URL salesforceURL;
- try {
- salesforceURL = new URL(url);
- } catch (MalformedURLException e) {
- throw new ConnectorException(e, e.getMessage());
- }
- setUrl(salesforceURL);
- }
+ setUrl(config.getURL());
}
private void setUrl(URL salesforceURL) {
Added: branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/SalesForceManagedConnectionFactory.java
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/SalesForceManagedConnectionFactory.java (rev 0)
+++ branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/SalesForceManagedConnectionFactory.java 2009-12-15 23:28:12 UTC (rev 1671)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package com.metamatrix.connector.salesforce;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.teiid.connector.basic.BasicManagedConnectionFactory;
+
+import com.metamatrix.core.MetaMatrixRuntimeException;
+
+public class SalesForceManagedConnectionFactory extends BasicManagedConnectionFactory {
+ private static final long serialVersionUID = 5298591275313314698L;
+
+ private String username;
+ private String connectorStateClass;
+ private String password;
+ private URL URL;
+ private long sourceConnectionTestInterval = -1;
+ private int sourceConnectionTimeout = -1;
+
+ public String getUsername() {
+ return username;
+ }
+ public void setUsername(String username) {
+ if (username.trim().length() == 0) {
+ throw new MetaMatrixRuntimeException("Name can not be null");
+ }
+ this.username = username;
+ }
+ public String getConnectorStateClass() {
+ return this.connectorStateClass;
+ }
+ public void setConnectorStateClass(String connectorStateClass) {
+ this.connectorStateClass = connectorStateClass;
+ }
+ public String getPassword() {
+ return this.password;
+ }
+ public void setPassword(String password) {
+ this.password = password;
+ }
+ public URL getURL() {
+ return this.URL;
+ }
+
+ public void setURL(String uRL) {
+ try {
+ this.URL = new URL(uRL);
+ } catch (MalformedURLException e) {
+ throw new MetaMatrixRuntimeException("URL Supplied is not valid URL"+ e.getMessage());
+ }
+ }
+
+ public long getSourceConnectionTestInterval() {
+ return sourceConnectionTestInterval;
+ }
+ public void setSourceConnectionTestInterval(Long sourceConnectionTestInterval) {
+ this.sourceConnectionTestInterval = sourceConnectionTestInterval.longValue();
+ }
+ public int getSourceConnectionTimeout() {
+ return sourceConnectionTimeout;
+ }
+ public void setSourceConnectionTimeout(Integer sourceConnectionTimeout) {
+ this.sourceConnectionTimeout = sourceConnectionTimeout.intValue();
+ }
+
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("username=").append(this.username);
+ sb.append(" ConnectorStateClass=").append(this.connectorStateClass);
+ sb.append(" URL=").append(this.URL);
+ return sb.toString();
+ }
+}
Modified: branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/SalesforceConnection.java
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/SalesforceConnection.java 2009-12-15 20:07:33 UTC (rev 1670)
+++ branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/SalesforceConnection.java 2009-12-15 23:28:12 UTC (rev 1671)
@@ -21,11 +21,11 @@
*/
package com.metamatrix.connector.salesforce.connection;
-import java.net.URL;
import java.util.Calendar;
import java.util.List;
-import org.teiid.connector.api.ConnectorEnvironment;
+import javax.security.auth.Subject;
+
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.ExecutionContext;
import org.teiid.connector.api.ProcedureExecution;
@@ -38,6 +38,7 @@
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.connector.salesforce.Messages;
+import com.metamatrix.connector.salesforce.SalesForceManagedConnectionFactory;
import com.metamatrix.connector.salesforce.connection.impl.ConnectionImpl;
import com.metamatrix.connector.salesforce.execution.DataPayload;
import com.metamatrix.connector.salesforce.execution.DeletedResult;
@@ -45,46 +46,35 @@
import com.metamatrix.connector.salesforce.execution.QueryExecutionImpl;
import com.metamatrix.connector.salesforce.execution.UpdateExecutionParent;
import com.metamatrix.connector.salesforce.execution.UpdatedResult;
+import com.metamatrix.core.MetaMatrixRuntimeException;
import com.sforce.soap.partner.QueryResult;
public class SalesforceConnection extends BasicConnection {
- private ConnectorEnvironment connectorEnv;
+ private SalesForceManagedConnectionFactory connectorEnv;
private ConnectionImpl connection;
- public SalesforceConnection(String username, String password, URL url, ConnectorEnvironment env) throws ConnectorException {
+ public SalesforceConnection(Subject subject, SalesForceManagedConnectionFactory env) {
+ throw new MetaMatrixRuntimeException("not supported yet..");
+ }
+
+ public SalesforceConnection(SalesForceManagedConnectionFactory env) throws ConnectorException {
try {
connectorEnv = env;
- long pingInterval = 5000;
- try {
- String pingIntervalString = env.getProperties().getProperty("SourceConnectionTestInterval");
- if(null != pingIntervalString) {
- pingInterval = Long.decode(pingIntervalString);
- }
- } catch (NumberFormatException e) {
- throw new ConnectorException(Messages.getString("SalesforceConnection.bad.ping.value"));
- }
+ long pingInterval = env.getSourceConnectionTestInterval();
+
//600000 - 10 minutes
- int timeout = 120000; // two minutes
- try {
- String timeoutString = env.getProperties().getProperty("SourceConnectionTimeout");
- if(null != timeoutString) {
- timeout = Integer.decode(timeoutString).intValue();
- }
- } catch (NumberFormatException e) {
- throw new ConnectorException(Messages.getString("SalesforceConnection.bad.timeout.value"));
- }
+ int timeout = env.getSourceConnectionTimeout();
- connection = new ConnectionImpl(username, password, url, pingInterval, env.getLogger(), timeout);
+ connection = new ConnectionImpl(env.getUsername(), env.getPassword(), env.getURL(), pingInterval, env.getLogger(), timeout);
} catch(Throwable t) {
env.getLogger().logError("SalesforceConnection() ErrorMessage: " + t.getMessage());
if(t instanceof ConnectorException) {
// don't wrap it again
throw (ConnectorException) t;
- } else {
- throw new ConnectorException(t);
- }
+ }
+ throw new ConnectorException(t);
}
}
@@ -132,11 +122,6 @@
return connection.isAlive();
}
- @Override
- public void closeCalled() {
-
- }
-
public int delete(String[] ids) throws ConnectorException {
return connection.delete(ids);
}
Added: branches/JCA/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml (rev 0)
+++ branches/JCA/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml 2009-12-15 23:28:12 UTC (rev 1671)
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<connector xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
+ version="1.5">
+
+ <vendor-name>Red Hat Middleware LLC</vendor-name>
+ <eis-type>Teiid Sales Force Connector</eis-type>
+ <resourceadapter-version>1.0</resourceadapter-version>
+ <license>
+ <description>
+ JBoss, Home of Professional Open Source.
+ Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ as indicated by the @author tags. See the copyright.txt file in the
+ distribution for a full listing of individual contributors.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ </description>
+ <license-required>true</license-required>
+ </license>
+ <resourceadapter>
+ <resourceadapter-class>org.teiid.connector.basic.BasicResourceAdapter</resourceadapter-class>
+
+ <outbound-resourceadapter>
+ <connection-definition>
+ <managedconnectionfactory-class>com.metamatrix.connector.salesforce.SalesForceManagedConnectionFactory</managedconnectionfactory-class>
+
+ <config-property>
+ <description>Connector Class</description>
+ <config-property-name>ConnectorClass</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>com.metamatrix.connector.salesforce.Connector</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Connector Capabilities</description>
+ <description>The class to use to provide the Connector Capabilities</description>
+ <config-property-name>CapabilitiesClass</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>com.metamatrix.connector.salesforce.SalesforceCapabilities</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Is Immutable</description>
+ <description>Is Immutable, True if the source never changes.</description>
+ <config-property-name>Immutable</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>false</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Is XA Capable</description>
+ <description>True, if this connector supports XA Transactions</description>
+ <config-property-name>XaCapable</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>false</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Exception on Exceeding Max Rows</description>
+ <description>Indicates if an Exception should be thrown if the specified value for Maximum Result Rows is exceeded; else no exception and no more than the maximum will be returned</description>
+ <config-property-name>ExceptionOnMaxRows</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>true</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Maximum Result Rows</description>
+ <description>Maximum Result Rows allowed</description>
+ <config-property-name>MaxResultRows</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>10000</config-property-value>
+ </config-property>
+
+ <!-- Salesforce Specific properties -->
+
+ <config-property>
+ <description>User Name</description>
+ <description>Name value for Salesforce authentication</description>
+ <config-property-name>username</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ </config-property>
+
+ <config-property>
+ <description>Password</description>
+ <description>Password value for Salesforce authentication</description>
+ <config-property-name>password</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ </config-property>
+
+ <config-property>
+ <description>Connector State Class</description>
+ <config-property-name>ConnectorStateClass</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>com.metamatrix.connector.salesforce.ConnectorState</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Salesforce URL</description>
+ <description>URL for connecting to Salesforce</description>
+ <config-property-name>URL</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>com.metamatrix.connector.salesforce.ConnectorState</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Source Connection Test Interval</description>
+ <config-property-name>SourceConnectionTestInterval</config-property-name>
+ <config-property-type>java.lang.Long</config-property-type>
+ <config-property-value>5000</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Source Connection Timeout</description>
+ <config-property-name>SourceConnectionTimeout</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>120000</config-property-value>
+ </config-property>
+
+ <connectionfactory-interface>org.teiid.connector.api.Connector</connectionfactory-interface>
+ <connectionfactory-impl-class>org.teiid.connector.basic.WrappedConnector</connectionfactory-impl-class>
+ <connection-interface>org.teiid.connector.api.Connection</connection-interface>
+ <connection-impl-class>org.teiid.connector.basic.WrappedConnection</connection-impl-class>
+
+ </connection-definition>
+
+ <transaction-support>NoTransaction</transaction-support>
+
+ <authentication-mechanism>
+ <authentication-mechanism-type>BasicPassword</authentication-mechanism-type>
+ <credential-interface>javax.resource.spi.security.PasswordCredential</credential-interface>
+ </authentication-mechanism>
+ <reauthentication-support>false</reauthentication-support>
+ </outbound-resourceadapter>
+ </resourceadapter>
+</connector>
Deleted: branches/JCA/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/TestConnector.java
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/TestConnector.java 2009-12-15 20:07:33 UTC (rev 1670)
+++ branches/JCA/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/TestConnector.java 2009-12-15 23:28:12 UTC (rev 1671)
@@ -1,138 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package com.metamatrix.connector.salesforce;
-
-import junit.framework.TestCase;
-
-import org.teiid.connector.api.ConnectorEnvironment;
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ExecutionContext;
-
-import com.metamatrix.connector.salesforce.test.util.ObjectFactory;
-
-public class TestConnector extends TestCase {
-
- Connector connector_not_initialized;
- Connector connector;
- Connector noCredConnector;
-
- public TestConnector() {
- super("TestConnector");
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- connector_not_initialized = new Connector();
-
- ConnectorEnvironment env = ObjectFactory.getDefaultTestConnectorEnvironment();
- connector = new Connector();
- connector.start(env);
-
- ConnectorEnvironment env2 = ObjectFactory.getNoCredTestConnectorEnvironment();
- noCredConnector = new Connector();
- noCredConnector.start(env2);
- }
-
- /*
- public void testGetConnectionTrustedToken() {
- ExecutionContext secContext = TestObjectFactory.getTokenExecutionContext();
- try {
- SalesforceConnection connection = (SalesforceConnection) noCredConnector.getConnection(secContext);
- assertNotNull("the connection is null", connection);
- } catch (ConnectorException e) {
- fail(e.getMessage());
- }
- }
- */
- public void testGetConnectionBadUser() {
- ConnectorEnvironment env = ObjectFactory.getConnectorEnvironmentBadUser();
- ExecutionContext secContext = ObjectFactory.getDefaultSecurityContext();
- Connector localConnector = new Connector();
- try {
- localConnector.start(env);
- localConnector.getConnection(secContext);
- fail("should have produced an exception");
- } catch (ConnectorException e) {
- assertFalse("There is no error message", e.getMessage().length() == 0);
- }
- }
-
- public void testGetConnectionEmptyUser() {
- ConnectorEnvironment env = ObjectFactory.getConnectorEnvironmentEmptyUser();
- ExecutionContext secContext = ObjectFactory.getDefaultSecurityContext();
- Connector localConnector = new Connector();
- try {
- localConnector.start(env);
- localConnector.getConnection(secContext);
- fail("should have produced an exception");
- } catch (ConnectorException e) {
- assertTrue("Wrong error message", e.getMessage().contains("Invalid"));
- }
- }
-
- public void testGetConnectionBadPass() {
- ConnectorEnvironment env = ObjectFactory.getConnectorEnvironmentBadPass();
- ExecutionContext secContext = ObjectFactory.getDefaultSecurityContext();
- Connector localConnector = new Connector();
- try {
- localConnector.start(env);
- localConnector.getConnection(secContext);
- fail("should have produced an exception");
- } catch (ConnectorException e) {
- assertFalse("There is no error message", e.getMessage().length() == 0);
- }
- }
-
- public void testGetConnectionEmptyPass() {
- ConnectorEnvironment env = ObjectFactory.getConnectorEnvironmentEmptyPass();
- ExecutionContext secContext = ObjectFactory.getDefaultSecurityContext();
- Connector localConnector = new Connector();
- try {
- localConnector.start(env);
- localConnector.getConnection(secContext);
- fail("should have produced an exception");
- } catch (ConnectorException e) {
- assertTrue("Wrong error message", e.getMessage().contains("Invalid credential configuration"));
- }
- }
-
- public void testInitialize() throws Exception {
- Connector localConnector = new Connector();
- localConnector.start(ObjectFactory.getDefaultTestConnectorEnvironment());
- assertEquals(ObjectFactory.VALID_PASSWORD, connector.getState().getPassword());
- assertEquals(ObjectFactory.VALID_USERNAME, connector.getState().getUsername());
- }
-
-
- public void testGetLogger() throws Exception {
- assertNotNull(connector.getLogger());
- }
-
- public void testGetState() {
- assertNotNull(connector.getState());
- }
-
- public void testStopNoInit() {
- connector_not_initialized.stop();
- }
-
-}
Deleted: branches/JCA/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/test/util/ObjectFactory.java
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/test/util/ObjectFactory.java 2009-12-15 20:07:33 UTC (rev 1670)
+++ branches/JCA/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/test/util/ObjectFactory.java 2009-12-15 23:28:12 UTC (rev 1671)
@@ -1,120 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package com.metamatrix.connector.salesforce.test.util;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import org.teiid.connector.api.ConnectorEnvironment;
-import org.teiid.connector.api.CredentialMap;
-import org.teiid.connector.api.ExecutionContext;
-
-import com.metamatrix.cdk.api.EnvironmentUtility;
-import com.metamatrix.connector.salesforce.ConnectorState;
-
-public class ObjectFactory {
-
- public static boolean DEBUG = false;
-
- public static final String VALID_USERNAME= "jdoyleoss(a)gmail.com";
- public static final String VALID_PASSWORD = "l3tm31nNZ4loJCls59GlDr4sZLB8N4TT";
-
- public static final String BOGUS_USERNAME= "bogus(a)gmail.com";
- public static final String BOGUS_PASSWORD = "k33pm30ut";
-
- public static ConnectorEnvironment getDefaultTestConnectorEnvironment() {
- Properties props = getDefaultProps();
- ConnectorEnvironment env = EnvironmentUtility.createEnvironment(props, DEBUG);
- return env;
- }
-
- public static ConnectorEnvironment getNoCredTestConnectorEnvironment() {
- Properties props = new Properties();
- props.put("sandbox", "false");
- ConnectorEnvironment env = EnvironmentUtility.createEnvironment(props, DEBUG);
- return env;
- }
-
- public static ConnectorEnvironment getConnectorEnvironmentBadUser() {
- Properties props = getDefaultProps();
- props.put(ConnectorState.USERNAME, BOGUS_USERNAME);
- ConnectorEnvironment env = EnvironmentUtility.createEnvironment(props, DEBUG);
- return env;
- }
-
- public static ConnectorEnvironment getConnectorEnvironmentBadPass() {
- Properties props = getDefaultProps();
- props.put(ConnectorState.PASSWORD, BOGUS_PASSWORD);
- ConnectorEnvironment env = EnvironmentUtility.createEnvironment(props, DEBUG);
- return env;
- }
-
- public static ConnectorEnvironment getConnectorEnvironmentEmptyPass() {
- Properties props = getDefaultProps();
- props.put(ConnectorState.PASSWORD, "");
- ConnectorEnvironment env = EnvironmentUtility.createEnvironment(props, DEBUG);
- return env;
- }
-
- public static Properties getDefaultProps() {
- Properties props = new Properties();
-
- props.put(ConnectorState.USERNAME, VALID_USERNAME);
- props.put(ConnectorState.PASSWORD, VALID_PASSWORD);
- props.put("sandbox", "false");
- props.put("ConnectorCapabilities", "com.metamatrix.connector.salesforce.SalesforceCapabilities");
- props.put("InLimit","-1");
- return props;
- }
-
- public static Properties getNoCredProps() {
- Properties props = new Properties();
- props.put("ConnectorCapabilities", "com.metamatrix.connector.salesforce.SalesforceCapabilities");
- props.put("sandbox", "false");
- return props;
- }
-
- public static ExecutionContext getDefaultSecurityContext() {
- return EnvironmentUtility.createSecurityContext("MetaMatrixAdmin");
- }
-
- public static ExecutionContext getTokenSecurityContext() {
- CredentialMap cMap = getCredentialMap();
- return EnvironmentUtility.createSecurityContext("Foo","1", "MetaMatrixAdmin", cMap);
- }
-
- public static CredentialMap getCredentialMap() {
- Map values = new HashMap();
- values.put(CredentialMap.USER_KEYWORD, VALID_USERNAME);
- values.put(CredentialMap.PASSWORD_KEYWORD, VALID_PASSWORD);
- CredentialMap cMap = new CredentialMap();
- cMap.addSystemCredentials("Connector<CDK>",values);
- return cMap;
- }
- public static ConnectorEnvironment getConnectorEnvironmentEmptyUser() {
- Properties props = getDefaultProps();
- props.put(ConnectorState.USERNAME, "");
- ConnectorEnvironment env = EnvironmentUtility.createEnvironment(props, DEBUG);
- return env;
- }
-}
Modified: branches/JCA/connectors/connector-text/pom.xml
===================================================================
--- branches/JCA/connectors/connector-text/pom.xml 2009-12-15 20:07:33 UTC (rev 1670)
+++ branches/JCA/connectors/connector-text/pom.xml 2009-12-15 23:28:12 UTC (rev 1671)
@@ -9,7 +9,9 @@
<artifactId>connector-text</artifactId>
<groupId>org.jboss.teiid.connectors</groupId>
<name>Text Connector</name>
+ <packaging>rar</packaging>
<description>This connector reads data from text files.</description>
+
<dependencies>
<dependency>
<groupId>org.jboss.teiid</groupId>
Modified: branches/JCA/connectors/connector-text/src/main/rar/META-INF/ra.xml
===================================================================
--- branches/JCA/connectors/connector-text/src/main/rar/META-INF/ra.xml 2009-12-15 20:07:33 UTC (rev 1670)
+++ branches/JCA/connectors/connector-text/src/main/rar/META-INF/ra.xml 2009-12-15 23:28:12 UTC (rev 1671)
@@ -7,7 +7,7 @@
version="1.5">
<vendor-name>Red Hat Middleware LLC</vendor-name>
- <eis-type>Teiid JDBC Connector</eis-type>
+ <eis-type>Teiid Text Connector</eis-type>
<resourceadapter-version>1.0</resourceadapter-version>
<license>
<description>
Modified: branches/JCA/connectors/pom.xml
===================================================================
--- branches/JCA/connectors/pom.xml 2009-12-15 20:07:33 UTC (rev 1670)
+++ branches/JCA/connectors/pom.xml 2009-12-15 23:28:12 UTC (rev 1671)
@@ -85,14 +85,14 @@
<module>connector-loopback</module>
<module>connector-text</module>
<module>connector-ldap</module>
-
+ <module>connector-salesforce</module>
+ <module>salesforce-api</module>
+ <module>connector-xml-common</module>
+
<!--
<module>connector-xml</module>
<module>sandbox</module>
- <module>connector-salesforce</module>
- <module>salesforce-api</module>
- <module>connector-xml-common</module>
-->
</modules>
</project>
\ No newline at end of file
15 years, 1 month
teiid SVN: r1670 - in branches/JCA: connector-api/src/main/java/org/teiid/connector/basic and 8 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-12-15 15:07:33 -0500 (Tue, 15 Dec 2009)
New Revision: 1670
Added:
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPManagedConnectionFactory.java
branches/JCA/connectors/connector-ldap/src/main/rar/
branches/JCA/connectors/connector-ldap/src/main/rar/META-INF/
branches/JCA/connectors/connector-ldap/src/main/rar/META-INF/ra.xml
Removed:
branches/JCA/connectors/connector-ldap/src/assembly/
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnectorPropertyNames.java
Modified:
branches/JCA/build/assembly/jboss-container/connectors.xml
branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicConnector.java
branches/JCA/connectors/connector-ldap/pom.xml
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/IQueryToLdapSearchParser.java
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnection.java
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnector.java
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPSyncQueryExecution.java
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPUpdateExecution.java
branches/JCA/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestIQueryToLdapSearchParser.java
branches/JCA/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestLDAPConnection.java
branches/JCA/connectors/pom.xml
Log:
TEIID-861: Converted LDAP connector as JCA connector
Modified: branches/JCA/build/assembly/jboss-container/connectors.xml
===================================================================
--- branches/JCA/build/assembly/jboss-container/connectors.xml 2009-12-15 19:24:54 UTC (rev 1669)
+++ branches/JCA/build/assembly/jboss-container/connectors.xml 2009-12-15 20:07:33 UTC (rev 1670)
@@ -18,7 +18,7 @@
<include>org.jboss.teiid.connectors:connector-jdbc:rar</include>
<include>org.jboss.teiid.connectors:connector-loopback</include>
<include>org.jboss.teiid.connectors:connector-text</include>
-
+ <include>org.jboss.teiid.connectors:connector-ldap</include>
</includes>
<binaries>
Modified: branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicConnector.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicConnector.java 2009-12-15 19:24:54 UTC (rev 1669)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicConnector.java 2009-12-15 20:07:33 UTC (rev 1670)
@@ -10,6 +10,7 @@
public abstract class BasicConnector implements Connector {
protected ConnectorEnvironment config;
+ protected ConnectorCapabilities capabilities;
@Override
public void initialize(ConnectorEnvironment config) throws ConnectorException {
@@ -27,19 +28,21 @@
@Override
public ConnectorCapabilities getCapabilities() throws ConnectorException {
- // create Capabilities
- String className = this.config.getCapabilitiesClass();
- try {
- ConnectorCapabilities result = null;
- if (className != null && className.length() > 0) {
- result = (ConnectorCapabilities) ReflectionHelper.create(className, null, Thread.currentThread().getContextClassLoader());
- } else {
- result = getDefaultCapabilities().newInstance();
+ if (capabilities == null) {
+ // create Capabilities
+ String className = this.config.getCapabilitiesClass();
+ try {
+ if (className != null && className.length() > 0) {
+ capabilities = (ConnectorCapabilities) ReflectionHelper.create(className, null, Thread.currentThread().getContextClassLoader());
+ } else {
+ capabilities = getDefaultCapabilities().newInstance();
+ }
+
+ return capabilities;
+ } catch (Exception e) {
+ throw new ConnectorException(e);
}
-
- return result;
- } catch (Exception e) {
- throw new ConnectorException(e);
- }
+ }
+ return capabilities;
}
}
Modified: branches/JCA/connectors/connector-ldap/pom.xml
===================================================================
--- branches/JCA/connectors/connector-ldap/pom.xml 2009-12-15 19:24:54 UTC (rev 1669)
+++ branches/JCA/connectors/connector-ldap/pom.xml 2009-12-15 20:07:33 UTC (rev 1670)
@@ -21,100 +21,27 @@
<artifactId>teiid-common-core</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
-
- <!-- This build portion is identical for all the connectors that are deployed; so when making changes make sure
- it applies to all the connectors. This below block computes the classpath, writes to classpath.properties; it replaces
- classpath in the xml file, then bundles current project and its dependencies and xml file in a zip for deployment-->
+
<build>
<plugins>
- <!-- build class path -->
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
+ <artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
- <id>build-classpath</id>
- <phase>generate-sources</phase>
+ <id>build_jar</id>
+ <phase>process-classes</phase>
<goals>
- <goal>build-classpath</goal>
+ <goal>jar</goal>
</goals>
- <configuration>
- <fileSeparator>:</fileSeparator>
- <pathSeparator>;</pathSeparator>
- <prefix>extensionjar</prefix>
- <excludeTransitive>false</excludeTransitive>
- <includeScope>runtime</includeScope>
- <excludeTypes>pom</excludeTypes>
- <outputFile>target/classpath.properties</outputFile>
- <regenerateFile>true</regenerateFile>
- <outputFilterFile>true</outputFilterFile>
- </configuration>
</execution>
</executions>
</plugin>
-
- <!-- bundles all its dependencies in a single zip file -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-dependencies</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- <configuration>
- <excludeTransitive>false</excludeTransitive>
- <includeScope>runtime</includeScope>
- <excludeTypes>pom</excludeTypes>
- <outputDirectory>target/dependency</outputDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>2.2-beta-2</version>
- <configuration>
- <descriptors>
- <descriptor>src/assembly/bundle.xml</descriptor>
- </descriptors>
- <outputDirectory>target/distribution</outputDirectory>
- <workDirectory>target/assembly/work</workDirectory>
- </configuration>
- <executions>
- <execution>
- <id>make-assembly</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
</plugins>
- <!-- replaces the classpath tokens in the xml file -->
- <filters>
- <filter>target/classpath.properties</filter>
- </filters>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>true</filtering>
- <includes>
- <include>**/*.xml</include>
- </includes>
- </resource>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>false</filtering>
- <excludes>
- <exclude>**/*.xml</exclude>
- </excludes>
- </resource>
- </resources>
-
- </build>
+ </build>
</project>
\ No newline at end of file
Modified: branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/IQueryToLdapSearchParser.java
===================================================================
--- branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/IQueryToLdapSearchParser.java 2009-12-15 19:24:54 UTC (rev 1669)
+++ branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/IQueryToLdapSearchParser.java 2009-12-15 20:07:33 UTC (rev 1670)
@@ -41,7 +41,6 @@
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
-import java.util.Properties;
import javax.naming.NamingException;
import javax.naming.directory.BasicAttribute;
@@ -49,7 +48,6 @@
import javax.naming.ldap.SortKey;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorLogger;
import org.teiid.connector.language.IAggregate;
import org.teiid.connector.language.ICompareCriteria;
import org.teiid.connector.language.ICompoundCriteria;
@@ -81,19 +79,17 @@
* Utility class which translates a SQL query into an LDAP search.
*/
public class IQueryToLdapSearchParser {
- private ConnectorLogger logger;
private RuntimeMetadata rm;
- private Properties props;
+ private LDAPManagedConnectionFactory config;
/**
* Constructor.
* @param logger the connector logger
* @param rm the RuntimeMetadata
*/
- public IQueryToLdapSearchParser(ConnectorLogger logger, RuntimeMetadata rm, Properties props) {
- this.logger = logger;
+ public IQueryToLdapSearchParser(RuntimeMetadata rm, LDAPManagedConnectionFactory config) {
this.rm = rm;
- this.props = props;
+ this.config = config;
}
/**
@@ -127,13 +123,13 @@
Iterator itr = fromList.listIterator();
if(!itr.hasNext()) {
final String msg = LDAPPlugin.Util.getString("IQueryToLdapSearchParser.noTablesInFromError"); //$NON-NLS-1$
- logger.logError(msg);
+ this.config.getLogger().logError(msg);
throw new ConnectorException(msg);
}
IFromItem fItm = (IFromItem)itr.next();
if(itr.hasNext()) {
final String msg = LDAPPlugin.Util.getString("IQueryToLdapSearchParser.multiItemsInFromError"); //$NON-NLS-1$
- logger.logError(msg);
+ this.config.getLogger().logError(msg);
throw new ConnectorException(msg);
}
String contextName = getContextNameFromFromItem(fItm);
@@ -176,7 +172,7 @@
LDAPSearchDetails sd = new LDAPSearchDetails(contextName, searchScope, filter, attributeList, sortKeys, countLimit, elementList);
// Search Details logging
try {
- sd.printDetailsToLog(logger);
+ sd.printDetailsToLog(this.config.getLogger());
} catch (NamingException nme) {
final String msg = LDAPPlugin.Util.getString("IQueryToLdapSearchParser.searchDetailsLoggingError"); //$NON-NLS-1$
throw new ConnectorException(msg);
@@ -206,12 +202,12 @@
IOrderByItem item = (IOrderByItem)orderItr.next();
if(item != null) {
String itemName = getExpressionString((IExpression)item.getElement());
- logger.logTrace("Adding sort key for item: " + itemName); //$NON-NLS-1$
+ this.config.getLogger().logTrace("Adding sort key for item: " + itemName); //$NON-NLS-1$
if(item.getDirection() == IOrderByItem.ASC) {
- logger.logTrace("with ASC ordering."); //$NON-NLS-1$
+ this.config.getLogger().logTrace("with ASC ordering."); //$NON-NLS-1$
sortKey = new SortKey(itemName, true, null);
} else if(item.getDirection() == IOrderByItem.DESC){
- logger.logTrace("with DESC ordering."); //$NON-NLS-1$
+ this.config.getLogger().logTrace("with DESC ordering."); //$NON-NLS-1$
sortKey = new SortKey(itemName, false, null);
}
}
@@ -252,7 +248,7 @@
// if there is no context name specified
// try the default in the connector properties
if(contextName.equals("")) { //$NON-NLS-1$
- contextName = props.getProperty(LDAPConnectorPropertyNames.LDAP_DEFAULT_BASEDN);
+ contextName = this.config.getSearchDefaultBaseDN();
}
} else {
final String msg = LDAPPlugin.Util.getString("IQueryToLdapSearchParser.groupCountExceededError"); //$NON-NLS-1$
@@ -297,8 +293,7 @@
// see if the connector property is set to true. If
// it is, use the Name of the class for the restriction.
if(namedClass == null || namedClass.equals("")) { //$NON-NLS-1$
- String restrictToObjectClass = props.getProperty(LDAPConnectorPropertyNames.LDAP_RESTRICT_TO_OBJECTCLASS);
- if (restrictToObjectClass == null || restrictToObjectClass.toUpperCase().equals("FALSE")) { //$NON-NLS-1$
+ if (!this.config.isRestrictToObjectClass()) { //$NON-NLS-1$
namedClass = ""; //$NON-NLS-1$
} else {
namedClass = mdIDGroup.getName();
@@ -332,7 +327,7 @@
// if there is no search scope specified
// try the default in the connector properties
if(searchScopeString.equals("")) { //$NON-NLS-1$
- searchScopeString = props.getProperty(LDAPConnectorPropertyNames.LDAP_DEFAULT_SCOPE);
+ searchScopeString = this.config.getSearchDefaultScope();
// protect against getting null back from the property
if(searchScopeString == null) {
searchScopeString = ""; //$NON-NLS-1$
@@ -390,13 +385,13 @@
} else if(e instanceof ILiteral) {
try {
if(((ILiteral)e).getType().equals(Class.forName(Timestamp.class.getName()))) {
- logger.logTrace("Found an expression that uses timestamp; converting to LDAP string format."); //$NON-NLS-1$
+ this.config.getLogger().logTrace("Found an expression that uses timestamp; converting to LDAP string format."); //$NON-NLS-1$
Timestamp ts = (Timestamp)((ILiteral)e).getValue();
Date dt = new Date(ts.getTime());
//TODO: Fetch format if provided.
SimpleDateFormat sdf = new SimpleDateFormat(LDAPConnectorConstants.ldapTimestampFormat);
expressionName = sdf.format(dt);
- logger.logTrace("Timestamp to stsring is: " + expressionName); //$NON-NLS-1$
+ this.config.getLogger().logTrace("Timestamp to stsring is: " + expressionName); //$NON-NLS-1$
}
else {
expressionName = ((ILiteral)e).getValue().toString();
@@ -408,13 +403,13 @@
} else {
if(e instanceof IAggregate) {
- logger.logError("Received IAggregate, but it is not supported. Check capabilities."); //$NON-NLS-1$
+ this.config.getLogger().logError("Received IAggregate, but it is not supported. Check capabilities."); //$NON-NLS-1$
} else if(e instanceof IFunction) {
- logger.logError("Received IFunction, but it is not supported. Check capabilties."); //$NON-NLS-1$
+ this.config.getLogger().logError("Received IFunction, but it is not supported. Check capabilties."); //$NON-NLS-1$
} else if(e instanceof IScalarSubquery) {
- logger.logError("Received IScalarSubquery, but it is not supported. Check capabilties."); //$NON-NLS-1$
+ this.config.getLogger().logError("Received IScalarSubquery, but it is not supported. Check capabilties."); //$NON-NLS-1$
} else if (e instanceof ISearchedCaseExpression) {
- logger.logError("Received ISearchedCaseExpression, but it is not supported. Check capabilties."); //$NON-NLS-1$
+ this.config.getLogger().logError("Received ISearchedCaseExpression, but it is not supported. Check capabilties."); //$NON-NLS-1$
}
final String msg = LDAPPlugin.Util.getString("IQueryToLdapSearchParser.unsupportedElementError"); //$NON-NLS-1$
throw new ConnectorException(msg + e.toString());
@@ -465,7 +460,7 @@
boolean isNegated = false;
// Recursive case: compound criteria
if(criteria instanceof ICompoundCriteria) {
- logger.logTrace("Parsing compound criteria."); //$NON-NLS-1$
+ this.config.getLogger().logTrace("Parsing compound criteria."); //$NON-NLS-1$
ICompoundCriteria.Operator op = ((ICompoundCriteria) criteria).getOperator();
List criteriaList = ((ICompoundCriteria) criteria).getCriteria();
String stringOp = parseCompoundCriteriaOp(op);
@@ -482,7 +477,7 @@
// Base case
} else if(criteria instanceof ICompareCriteria) {
- logger.logTrace("Parsing compare criteria."); //$NON-NLS-1$
+ this.config.getLogger().logTrace("Parsing compare criteria."); //$NON-NLS-1$
ICompareCriteria.Operator op = ((ICompareCriteria) criteria).getOperator();
isNegated = op == Operator.NE || op == Operator.GT || op == Operator.LT;
@@ -500,11 +495,11 @@
addCompareCriteriaToList(filterList, op, lhsString, rhsString);
// Base case
} else if(criteria instanceof IExistsCriteria) {
- logger.logTrace("Parsing EXISTS criteria: NOT IMPLEMENTED YET"); //$NON-NLS-1$
+ this.config.getLogger().logTrace("Parsing EXISTS criteria: NOT IMPLEMENTED YET"); //$NON-NLS-1$
// TODO Exists should be supported in a future release.
// Base case
} else if(criteria instanceof ILikeCriteria) {
- logger.logTrace("Parsing LIKE criteria."); //$NON-NLS-1$
+ this.config.getLogger().logTrace("Parsing LIKE criteria."); //$NON-NLS-1$
isNegated = ((ILikeCriteria) criteria).isNegated();
// Convert LIKE to Equals, where any "%" symbol is replaced with "*".
ICompareCriteria.Operator op = Operator.EQ;
@@ -518,14 +513,14 @@
// Base case
} else if(criteria instanceof IInCriteria) {
- logger.logTrace("Parsing IN criteria."); //$NON-NLS-1$
+ this.config.getLogger().logTrace("Parsing IN criteria."); //$NON-NLS-1$
isNegated = ((IInCriteria) criteria).isNegated();
IExpression lhs = ((IInCriteria)criteria).getLeftExpression();
List rhsList = ((IInCriteria)criteria).getRightExpressions();
// Recursively add each IN expression to the filter list.
processInCriteriaList(filterList, rhsList, lhs);
} else if (criteria instanceof INotCriteria) {
- logger.logTrace("Parsing NOT criteria."); //$NON-NLS-1$
+ this.config.getLogger().logTrace("Parsing NOT criteria."); //$NON-NLS-1$
isNegated = true;
filterList.addAll(getSearchFilterFromWhereClause(((INotCriteria)criteria).getCriteria(), new LinkedList()));
}
Modified: branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnection.java
===================================================================
--- branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnection.java 2009-12-15 19:24:54 UTC (rev 1669)
+++ branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnection.java 2009-12-15 20:07:33 UTC (rev 1670)
@@ -46,37 +46,27 @@
*/
public class LDAPConnection extends BasicConnection {
+ private LDAPManagedConnectionFactory config;
+
// Standard Connection data members
- private ConnectorLogger logger;
private InitialLdapContext initCtx;
- private Properties props;
// LDAP-specific properties
public static final String LDAP_AUTH_TYPE = "simple"; //$NON-NLS-1$
public static final String LDAP_USER_OBJECT_TYPE = "person"; //$NON-NLS-1$
public static final String LDAP_REFERRAL_MODE = "follow"; //$NON-NLS-1$
- private String ldapURL;
- private String ldapAdminUserDN;
- private String ldapAdminUserPass;
- private String ldapTxnTimeoutInMillis;
+
private String jndiLdapCtxFactory;
- /**
- * Constructor.
- * @param ctx
- * @param props
- * @param logger
- */
- public LDAPConnection(ExecutionContext ctx, Properties props, ConnectorLogger logger) throws ConnectorException {
- this(ctx, props, logger, LDAPConnectorConstants.JNDI_LDAP_CTX_FACTORY);
+ public LDAPConnection(LDAPManagedConnectionFactory config) throws ConnectorException {
+ this(config, LDAPConnectorConstants.JNDI_LDAP_CTX_FACTORY);
}
- public LDAPConnection(ExecutionContext ctx, Properties props, ConnectorLogger logger, String jndiLdapCtxFactory) throws ConnectorException {
- this.logger = logger;
- this.props = props;
+ public LDAPConnection(LDAPManagedConnectionFactory config, String jndiLdapCtxFactory) throws ConnectorException {
+ this.config = config;
this.jndiLdapCtxFactory = jndiLdapCtxFactory;
- parseProperties(props);
+ checkProperties();
// Create initial LDAP connection.
try {
@@ -86,7 +76,7 @@
throw new ConnectorException(ce, msg);
}
- logger.logDetail("LDAP Connection has been newly created."); //$NON-NLS-1$
+ this.config.getLogger().logDetail("LDAP Connection has been newly created."); //$NON-NLS-1$
}
public void setJndiLdapCtxFactory(String jndiLdapCtxFactory) {
@@ -98,26 +88,22 @@
* a ConnectorException is thrown.
* @param props
*/
- private void parseProperties(Properties props) throws ConnectorException {
+ private void checkProperties() throws ConnectorException {
// LDAP URL
- if((ldapURL = props.getProperty(LDAPConnectorPropertyNames.LDAP_URL)) == null) {
+ if(this.config.getLdapUrl() == null) {
final String msg = LDAPPlugin.Util.getString("LDAPConnection.urlPropNotFound"); //$NON-NLS-1$
throw new ConnectorException(msg);
}
// LDAP Admin User DN
- if((ldapAdminUserDN = props.getProperty(LDAPConnectorPropertyNames.LDAP_ADMIN_USER_DN)) == null) {
+ if(this.config.getLdapAdminUserDN() == null) {
final String msg = LDAPPlugin.Util.getString("LDAPConnection.adminUserDNPropNotFound"); //$NON-NLS-1$
throw new ConnectorException(msg);
}
// LDAP Admin User Password
- if((ldapAdminUserPass = props.getProperty(LDAPConnectorPropertyNames.LDAP_ADMIN_USER_PASSWORD)) == null) {
+ if(this.config.getLdapAdminUserPassword() == null) {
final String msg = LDAPPlugin.Util.getString("LDAPConnection.adminUserPassPropNotFound"); //$NON-NLS-1$
throw new ConnectorException(msg);
}
- // LDAP Txn Timeout in Milliseconds
- if((ldapTxnTimeoutInMillis = props.getProperty(LDAPConnectorPropertyNames.LDAP_TXN_TIMEOUT_IN_MILLIS)) == null) {
- // If unset, leave it at null, since we will default to TCP timeout value.
- }
}
/**
@@ -132,22 +118,22 @@
Hashtable connenv = new Hashtable();
connenv.put(Context.INITIAL_CONTEXT_FACTORY, jndiLdapCtxFactory);
- connenv.put(Context.PROVIDER_URL, this.ldapURL);
+ connenv.put(Context.PROVIDER_URL, this.config.getLdapUrl());
connenv.put(Context.REFERRAL, LDAP_REFERRAL_MODE);
// If username is blank, we will perform an anonymous bind.
// Note: This is not supported when using Sun's VLVs, so remove this if VLVs are used.
- if(!ldapAdminUserDN.equals("")) { //$NON-NLS-1$
+ if(!this.config.getLdapAdminUserDN().equals("")) { //$NON-NLS-1$
connenv.put(Context.SECURITY_AUTHENTICATION, LDAP_AUTH_TYPE);
- connenv.put(Context.SECURITY_PRINCIPAL, this.ldapAdminUserDN);
- connenv.put(Context.SECURITY_CREDENTIALS, this.ldapAdminUserPass);
+ connenv.put(Context.SECURITY_PRINCIPAL, this.config.getLdapAdminUserDN());
+ connenv.put(Context.SECURITY_CREDENTIALS, this.config.getLdapAdminUserPassword());
} else {
- logger.logWarning("LDAP Username DN was blank; performing anonymous bind."); //$NON-NLS-1$
+ this.config.getLogger().logWarning("LDAP Username DN was blank; performing anonymous bind."); //$NON-NLS-1$
connenv.put(Context.SECURITY_AUTHENTICATION, "none"); //$NON-NLS-1$
}
- if(ldapTxnTimeoutInMillis != null && !ldapTxnTimeoutInMillis.equals("")) { //$NON-NLS-1$
- connenv.put("com.sun.jndi.ldap.connect.timeout", ldapTxnTimeoutInMillis); //$NON-NLS-1$
+ if(this.config.getLdapTxnTimeoutInMillis() != -1) { //$NON-NLS-1$
+ connenv.put("com.sun.jndi.ldap.connect.timeout", this.config.getLdapTxnTimeoutInMillis()); //$NON-NLS-1$
}
// Enable connection pooling for the Initial context.
@@ -163,7 +149,7 @@
final String msg = LDAPPlugin.Util.getString("LDAPConnection.directoryInitError"); //$NON-NLS-1$
throw new ConnectorException(e, msg);
}
- logger.logDetail("Successfully obtained initial LDAP context."); //$NON-NLS-1$
+ this.config.getLogger().logDetail("Successfully obtained initial LDAP context."); //$NON-NLS-1$
return initContext;
}
@@ -171,14 +157,14 @@
public ResultSetExecution createResultSetExecution(IQueryCommand command,
ExecutionContext executionContext, RuntimeMetadata metadata)
throws ConnectorException {
- return new LDAPSyncQueryExecution((IQuery)command, executionContext, metadata, this.logger, this.initCtx, this.props);
+ return new LDAPSyncQueryExecution((IQuery)command, executionContext, metadata, this.initCtx, this.config);
}
@Override
public UpdateExecution createUpdateExecution(ICommand command,
ExecutionContext executionContext, RuntimeMetadata metadata)
throws ConnectorException {
- return new LDAPUpdateExecution(command, executionContext, metadata, this.logger, this.initCtx);
+ return new LDAPUpdateExecution(command, executionContext, metadata, this.initCtx, this.config);
}
/**
@@ -192,10 +178,10 @@
try {
initCtx.close();
} catch(NamingException e) {
- logger.logDetail(LDAPPlugin.Util.getString("LDAPConnection.contextCloseError",e.getExplanation())); //$NON-NLS-1$
+ this.config.getLogger().logDetail(LDAPPlugin.Util.getString("LDAPConnection.contextCloseError",e.getExplanation())); //$NON-NLS-1$
}
}
- logger.logDetail("LDAP context has been closed."); //$NON-NLS-1$
+ this.config.getLogger().logDetail("LDAP context has been closed."); //$NON-NLS-1$
}
/**
@@ -213,13 +199,8 @@
*/
@Override
public boolean isAlive() {
- logger.logTrace("LDAP Connection is alive."); //$NON-NLS-1$
+ this.config.getLogger().logTrace("LDAP Connection is alive."); //$NON-NLS-1$
return true;
}
- @Override
- public void closeCalled() {
-
- }
-
}
Modified: branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnector.java
===================================================================
--- branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnector.java 2009-12-15 19:24:54 UTC (rev 1669)
+++ branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnector.java 2009-12-15 20:07:33 UTC (rev 1670)
@@ -21,14 +21,10 @@
*/
package com.metamatrix.connector.ldap;
-import java.util.Properties;
-
import org.teiid.connector.api.Connection;
import org.teiid.connector.api.ConnectorCapabilities;
import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorLogger;
-import org.teiid.connector.api.ExecutionContext;
import org.teiid.connector.basic.BasicConnector;
@@ -37,48 +33,20 @@
* a connection factory, and obtaining connections to LDAP.
*/
public class LDAPConnector extends BasicConnector {
- private ConnectorEnvironment env;
- private ConnectorLogger logger;
- private Properties props;
- private LDAPConnectorCapabilities myCaps;
+ private LDAPManagedConnectionFactory config;
- @Override
- public ConnectorCapabilities getCapabilities() {
- return myCaps;
+ public Connection getConnection() throws ConnectorException {
+ config.getLogger().logDetail(LDAPPlugin.Util.getString("LDAPSourceConnectionFactory.creatingConnection"));
+ return new LDAPConnection(this.config);
}
- /*
- * @see com.metamatrix.data.Connector#getConnection(com.metamatrix.data.SecurityContext)
- */
- public Connection getConnection(ExecutionContext ctx) throws ConnectorException {
- final String msg = LDAPPlugin.Util.getString("LDAPSourceConnectionFactory.creatingConnection"); //$NON-NLS-1$
- logger.logDetail(msg);
- return new LDAPConnection(ctx, this.props, this.logger);
- }
-
- /**
- * (non-Javadoc)
- * @see org.teiid.connector.basic.BasicConnector#initialize(org.teiid.connector.api.ConnectorEnvironment)
- */
@Override
- public void start(ConnectorEnvironment env) throws ConnectorException {
- this.env = env;
- this.logger = this.env.getLogger();
- if(logger == null) {
- final String msg = LDAPPlugin.Util.getString("LDAPConnector.loggerNotFound"); //$NON-NLS-1$
- final ConnectorException e = new ConnectorException(msg);
- throw e;
- }
- this.props = env.getProperties();
-
- // Create and configure capabilities class.
- myCaps = new LDAPConnectorCapabilities();
- }
-
- /**
- */
- @Override
- public void stop() {
- }
+ public void initialize(ConnectorEnvironment env) throws ConnectorException {
+ super.initialize(env);
+ this.config = (LDAPManagedConnectionFactory)env;
+ }
+ public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
+ return LDAPConnectorCapabilities.class;
+ }
}
Deleted: branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnectorPropertyNames.java
===================================================================
--- branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnectorPropertyNames.java 2009-12-15 19:24:54 UTC (rev 1669)
+++ branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnectorPropertyNames.java 2009-12-15 20:07:33 UTC (rev 1670)
@@ -1,35 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package com.metamatrix.connector.ldap;
-
-/**
- * Property names used in the LDAP connector.
- */
-public class LDAPConnectorPropertyNames {
- public static final String LDAP_URL = "LdapUrl"; //$NON-NLS-1$
- public static final String LDAP_ADMIN_USER_DN = "LdapAdminUserDN"; //$NON-NLS-1$
- public static final String LDAP_ADMIN_USER_PASSWORD = "LdapAdminUserPassword"; //$NON-NLS-1$
- public static final String LDAP_TXN_TIMEOUT_IN_MILLIS = "LdapTxnTimeoutInMillis"; //$NON-NLS-1$
- public static final String LDAP_DEFAULT_BASEDN = "SearchDefaultBaseDN"; //$NON-NLS-1$
- public static final String LDAP_DEFAULT_SCOPE = "SearchDefaultScope"; //$NON-NLS-1$
- public static final String LDAP_RESTRICT_TO_OBJECTCLASS = "RestrictToObjectClass"; //$NON-NLS-1$
-}
Added: branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPManagedConnectionFactory.java
===================================================================
--- branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPManagedConnectionFactory.java (rev 0)
+++ branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPManagedConnectionFactory.java 2009-12-15 20:07:33 UTC (rev 1670)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package com.metamatrix.connector.ldap;
+
+import org.teiid.connector.basic.BasicManagedConnectionFactory;
+
+public class LDAPManagedConnectionFactory extends BasicManagedConnectionFactory {
+
+ private static final long serialVersionUID = -1832915223199053471L;
+
+ private String searchDefaultBaseDN;
+ private String ldapAdminUserDN;
+ private String ldapAdminUserPassword;
+ private boolean restrictToObjectClass = false;
+ private long ldapTxnTimeoutInMillis;
+ private String ldapUrl;
+ private String searchDefaultScope = "SUBTREE_SCOPE";
+
+ public String getSearchDefaultBaseDN() {
+ return searchDefaultBaseDN;
+ }
+
+ public void setSearchDefaultBaseDN(String searchDefaultBaseDN) {
+ this.searchDefaultBaseDN = searchDefaultBaseDN;
+ }
+
+ public String getLdapAdminUserDN() {
+ return ldapAdminUserDN;
+ }
+
+ public void setLdapAdminUserDN(String ldapAdminUserDN) {
+ this.ldapAdminUserDN = ldapAdminUserDN;
+ }
+
+ public String getLdapAdminUserPassword() {
+ return ldapAdminUserPassword;
+ }
+
+ public void setLdapAdminUserPassword(String ldapAdminUserPassword) {
+ this.ldapAdminUserPassword = ldapAdminUserPassword;
+ }
+
+ public boolean isRestrictToObjectClass() {
+ return restrictToObjectClass;
+ }
+
+ public void setRestrictToObjectClass(Boolean restrictToObjectClass) {
+ this.restrictToObjectClass = restrictToObjectClass.booleanValue();
+ }
+
+ public long getLdapTxnTimeoutInMillis() {
+ return ldapTxnTimeoutInMillis;
+ }
+
+ public void setLdapTxnTimeoutInMillis(Long ldapTxnTimeoutInMillis) {
+ this.ldapTxnTimeoutInMillis = ldapTxnTimeoutInMillis.longValue();
+ }
+
+ public String getLdapUrl() {
+ return ldapUrl;
+ }
+
+ public void setLdapUrl(String ldapUrl) {
+ this.ldapUrl = ldapUrl;
+ }
+
+ public String getSearchDefaultScope() {
+ return searchDefaultScope;
+ }
+
+ public void setSearchDefaultScope(String searchDefaultScope) {
+ this.searchDefaultScope = searchDefaultScope;
+ }
+}
Modified: branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPSyncQueryExecution.java
===================================================================
--- branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPSyncQueryExecution.java 2009-12-15 19:24:54 UTC (rev 1669)
+++ branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPSyncQueryExecution.java 2009-12-15 20:07:33 UTC (rev 1670)
@@ -110,15 +110,14 @@
*/
public class LDAPSyncQueryExecution extends BasicExecution implements ResultSetExecution {
- private ConnectorLogger logger;
private LDAPSearchDetails searchDetails;
private RuntimeMetadata rm;
private InitialLdapContext initialLdapContext;
private LdapContext ldapCtx;
private NamingEnumeration searchEnumeration;
private IQueryToLdapSearchParser parser;
- private Properties props;
private IQuery query;
+ private LDAPManagedConnectionFactory config;
/**
* Constructor
@@ -128,14 +127,11 @@
* @param logger the ConnectorLogger
* @param ldapCtx the LDAP Context
*/
- public LDAPSyncQueryExecution(IQuery query, ExecutionContext ctx,
- RuntimeMetadata rm, ConnectorLogger logger,
- InitialLdapContext ldapCtx, Properties props) throws ConnectorException {
+ public LDAPSyncQueryExecution(IQuery query, ExecutionContext ctx, RuntimeMetadata rm, InitialLdapContext ldapCtx, LDAPManagedConnectionFactory config) throws ConnectorException {
this.rm = rm;
- this.logger = logger;
this.initialLdapContext = ldapCtx;
- this.props = props;
this.query = query;
+ this.config = config;
}
/**
@@ -146,7 +142,7 @@
@Override
public void execute() throws ConnectorException {
// Parse the IQuery, and translate it into an appropriate LDAP search.
- this.parser = new IQueryToLdapSearchParser(logger, this.rm, this.props);
+ this.parser = new IQueryToLdapSearchParser(this.rm, this.config);
searchDetails = parser.translateSQLQueryToLDAPSearch(query);
// Create and configure the new search context.
@@ -167,7 +163,7 @@
try {
sortCtrl[0] = new SortControl(keys, Control.NONCRITICAL);
this.ldapCtx.setRequestControls(sortCtrl);
- logger.logTrace("Sort ordering was requested, and sort control was created successfully."); //$NON-NLS-1$
+ this.config.getLogger().logTrace("Sort ordering was requested, and sort control was created successfully."); //$NON-NLS-1$
} catch (NamingException ne) {
final String msg = LDAPPlugin.Util.getString("LDAPSyncQueryExecution.setControlsError") + //$NON-NLS-1$
" : "+ne.getExplanation(); //$NON-NLS-1$
@@ -189,7 +185,7 @@
ldapCtx = (LdapContext) this.initialLdapContext.lookup(searchDetails.getContextName());
} catch (NamingException ne) {
if (searchDetails.getContextName() != null) {
- logger.logError("Attempted to search context: " //$NON-NLS-1$
+ this.config.getLogger().logError("Attempted to search context: " //$NON-NLS-1$
+ searchDetails.getContextName());
}
final String msg = LDAPPlugin.Util.getString("LDAPSyncQueryExecution.createContextError"); //$NON-NLS-1$
@@ -215,11 +211,6 @@
i++;
}
- if(attrs == null) {
- final String msg = LDAPPlugin.Util.getString("LDAPSyncQueryExecution.configAttrsError"); //$NON-NLS-1$
- throw new ConnectorException(msg);
- }
-
ctrls.setSearchScope(searchDetails.getSearchScope());
ctrls.setReturningAttributes(attrs);
@@ -238,17 +229,17 @@
String ctxName = searchDetails.getContextName();
String filter = searchDetails.getContextFilter();
if (ctxName == null || filter == null || ctrls == null) {
- logger.logError("Search context, filter, or controls were null. Cannot execute search."); //$NON-NLS-1$
+ this.config.getLogger().logError("Search context, filter, or controls were null. Cannot execute search."); //$NON-NLS-1$
}
try {
searchEnumeration = this.ldapCtx.search("", filter, ctrls); //$NON-NLS-1$
} catch (NamingException ne) {
- logger.logError("LDAP search failed. Attempted to search context " //$NON-NLS-1$
+ this.config.getLogger().logError("LDAP search failed. Attempted to search context " //$NON-NLS-1$
+ ctxName + " using filter " + filter); //$NON-NLS-1$
final String msg = LDAPPlugin.Util.getString("LDAPSyncQueryExecution.execSearchError"); //$NON-NLS-1$
throw new ConnectorException(msg + " : " + ne.getExplanation()); //$NON-NLS-1$
} catch(Exception e) {
- logger.logError("LDAP search failed. Attempted to search context " //$NON-NLS-1$
+ this.config.getLogger().logError("LDAP search failed. Attempted to search context " //$NON-NLS-1$
+ ctxName + " using filter " + filter); //$NON-NLS-1$
final String msg = LDAPPlugin.Util.getString("LDAPSyncQueryExecution.execSearchError"); //$NON-NLS-1$
throw new ConnectorException(e, msg);
@@ -283,7 +274,7 @@
ldapCtx.close();
} catch (NamingException ne) {
final String msg = LDAPPlugin.Util.getString("LDAPSyncQueryExecution.closeContextError",ne.getExplanation()); //$NON-NLS-1$
- logger.logError(msg);
+ this.config.getLogger().logError(msg);
}
}
}
@@ -312,12 +303,12 @@
return result;
} catch (SizeLimitExceededException e) {
- logger.logWarning("Search results exceeded size limit. Results may be incomplete."); //$NON-NLS-1$
+ this.config.getLogger().logWarning("Search results exceeded size limit. Results may be incomplete."); //$NON-NLS-1$
searchEnumeration = null; // GHH 20080326 - NamingEnumartion's are no longer good after an exception so toss it
return null; // GHH 20080326 - if size limit exceeded don't try to read more results
} catch (NamingException ne) {
final String msg = "Ldap error while processing next batch of results: " + ne.getExplanation(); //$NON-NLS-1$
- logger.logError(msg); // GHH 20080326 - changed to output explanation from LDAP server
+ this.config.getLogger().logError(msg); // GHH 20080326 - changed to output explanation from LDAP server
searchEnumeration = null; // GHH 20080326 - NamingEnumertion's are no longer good after an exception so toss it
throw new ConnectorException(msg);
}
@@ -330,7 +321,7 @@
*/
// GHH 20080326 - added fetching of DN of result, for directories that
// do not include it as an attribute
- private List getRow(SearchResult result) throws ConnectorException, NamingException {
+ private List getRow(SearchResult result) throws ConnectorException {
Attributes attrs = result.getAttributes();
String resultDN = result.getNameInNamespace(); // added GHH 20080326
ArrayList attributeList = searchDetails.getElementList();
@@ -358,11 +349,11 @@
// value for that column in the result
// GHH 20080326 - added handling of ClassCastException when non-string
// attribute is returned
- private void addResultToRow(Element modelElement, String resultDistinguishedName, Attributes attrs, List row) throws ConnectorException, NamingException {
+ private void addResultToRow(Element modelElement, String resultDistinguishedName, Attributes attrs, List row) throws ConnectorException {
String strResult;
String modelAttrName = parser.getNameFromElement(modelElement);
- Class modelAttrClass = (Class)modelElement.getJavaType();
+ Class modelAttrClass = modelElement.getJavaType();
if(modelAttrName == null) {
final String msg = LDAPPlugin.Util.getString("LDAPSyncQueryExecution.nullAttrError"); //$NON-NLS-1$
throw new ConnectorException(msg);
@@ -398,7 +389,7 @@
objResult = resultAttr.get();
} catch (NamingException ne) {
final String msg = LDAPPlugin.Util.getString("LDAPSyncQueryExecution.attrValueFetchError",modelAttrName); //$NON-NLS-1$
- logger.logWarning(msg+" : "+ne.getExplanation()); //$NON-NLS-1$
+ this.config.getLogger().logWarning(msg+" : "+ne.getExplanation()); //$NON-NLS-1$
throw new ConnectorException(msg+" : "+ne.getExplanation()); //$NON-NLS-1$
}
Modified: branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPUpdateExecution.java
===================================================================
--- branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPUpdateExecution.java 2009-12-15 19:24:54 UTC (rev 1669)
+++ branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPUpdateExecution.java 2009-12-15 20:07:33 UTC (rev 1670)
@@ -34,7 +34,6 @@
import javax.naming.ldap.LdapContext;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorLogger;
import org.teiid.connector.api.DataNotAvailableException;
import org.teiid.connector.api.ExecutionContext;
import org.teiid.connector.api.UpdateExecution;
@@ -71,19 +70,18 @@
* of attributes to assign values in an INSERT operation * Responsible for update/insert/delete operations against LDAP
*/
public class LDAPUpdateExecution extends BasicExecution implements UpdateExecution {
- private ConnectorLogger logger;
private RuntimeMetadata rm;
private InitialLdapContext initialLdapContext;
private LdapContext ldapCtx;
private ICommand command;
+ private LDAPManagedConnectionFactory config;
public LDAPUpdateExecution(ICommand command, ExecutionContext ctx,
- RuntimeMetadata rm, ConnectorLogger logger,
- InitialLdapContext ldapCtx) throws ConnectorException {
+ RuntimeMetadata rm, InitialLdapContext ldapCtx, LDAPManagedConnectionFactory config) throws ConnectorException {
this.rm = rm;
- this.logger = logger;
this.initialLdapContext = ldapCtx;
this.command = command;
+ this.config = config;
}
/** execute generic update-class (either an update, delete, or insert)
@@ -440,7 +438,7 @@
}
} catch (NamingException ne) {
final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.closeContextError",ne.getExplanation()); //$NON-NLS-1$
- logger.logError(msg);
+ this.config.getLogger().logError(msg);
}
}
Added: branches/JCA/connectors/connector-ldap/src/main/rar/META-INF/ra.xml
===================================================================
--- branches/JCA/connectors/connector-ldap/src/main/rar/META-INF/ra.xml (rev 0)
+++ branches/JCA/connectors/connector-ldap/src/main/rar/META-INF/ra.xml 2009-12-15 20:07:33 UTC (rev 1670)
@@ -0,0 +1,163 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<connector xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
+ version="1.5">
+
+ <vendor-name>Red Hat Middleware LLC</vendor-name>
+ <eis-type>Teiid JDBC Connector</eis-type>
+ <resourceadapter-version>1.0</resourceadapter-version>
+ <license>
+ <description>
+ JBoss, Home of Professional Open Source.
+ Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ as indicated by the @author tags. See the copyright.txt file in the
+ distribution for a full listing of individual contributors.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ </description>
+ <license-required>true</license-required>
+ </license>
+ <resourceadapter>
+ <resourceadapter-class>org.teiid.connector.basic.BasicResourceAdapter</resourceadapter-class>
+
+ <outbound-resourceadapter>
+ <connection-definition>
+ <managedconnectionfactory-class>com.metamatrix.connector.ldap.LDAPManagedConnectionFactory</managedconnectionfactory-class>
+
+ <config-property>
+ <description>Connector Class</description>
+ <config-property-name>ConnectorClass</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>com.metamatrix.connector.ldap.LDAPConnector</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Connector Capabilities</description>
+ <description>The class to use to provide the Connector Capabilities</description>
+ <config-property-name>CapabilitiesClass</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>com.metamatrix.connector.ldap.LDAPConnectorCapabilities</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Is Immutable</description>
+ <description>Is Immutable, True if the source never changes.</description>
+ <config-property-name>Immutable</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>true</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Is XA Capable</description>
+ <description>True, if this connector supports XA Transactions</description>
+ <config-property-name>XaCapable</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>false</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Exception on Exceeding Max Rows</description>
+ <description>Indicates if an Exception should be thrown if the specified value for Maximum Result Rows is exceeded; else no exception and no more than the maximum will be returned</description>
+ <config-property-name>ExceptionOnMaxRows</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>true</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Maximum Result Rows</description>
+ <description>Maximum Result Rows allowed</description>
+ <config-property-name>MaxResultRows</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>10000</config-property-value>
+ </config-property>
+
+ <!-- Loopback Specific properties -->
+
+ <config-property>
+ <description>Default Search Base DN</description>
+ <description>Default Base DN for LDAP Searches</description>
+ <config-property-name>SearchDefaultBaseDN</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ </config-property>
+
+ <config-property>
+ <description>Ldap Admin User DN</description>
+ <description>User DN for the LDAP admin account</description>
+ <config-property-name>LdapAdminUserDN</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>cn=<>,ou=<>,dc=<></config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Ldap Admin Password</description>
+ <description>Password of the LDAP admin user account</description>
+ <config-property-name>LdapAdminUserPassword</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ </config-property>
+
+ <config-property>
+ <description>Restrict Searches To Named Object Class</description>
+ <description>Restrict Searches to objectClass named in the Name field for a table</description>
+ <config-property-name>RestrictToObjectClass</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>false</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Ldap Transaction Timeout (ms)</description>
+ <description>Timeout value for LDAP searches. Defaults to TCP timeout value.</description>
+ <config-property-name>LdapTxnTimeoutInMillis</config-property-name>
+ <config-property-type>java.lang.Long</config-property-type>
+ <config-property-value>-1</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Ldap URL</description>
+ <description>Ldap URL of the server, including port number.</description>
+ <config-property-name>LdapUrl</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>ldap://<ldapServer>:<389></config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Default Search Scope</description>
+ <description>Default Scope for LDAP Searches</description>
+ <description>${ALLOWED}:OBJECT_SCOPE,ONELEVEL_SCOPE,SUBTREE_SCOPE</description>
+ <config-property-name>SearchDefaultScope</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>SUBTREE_SCOPE</config-property-value>
+ </config-property>
+
+ <connectionfactory-interface>org.teiid.connector.api.Connector</connectionfactory-interface>
+ <connectionfactory-impl-class>org.teiid.connector.basic.WrappedConnector</connectionfactory-impl-class>
+ <connection-interface>org.teiid.connector.api.Connection</connection-interface>
+ <connection-impl-class>org.teiid.connector.basic.WrappedConnection</connection-impl-class>
+
+ </connection-definition>
+
+ <transaction-support>NoTransaction</transaction-support>
+
+ <authentication-mechanism>
+ <authentication-mechanism-type>BasicPassword</authentication-mechanism-type>
+ <credential-interface>javax.resource.spi.security.PasswordCredential</credential-interface>
+ </authentication-mechanism>
+ <reauthentication-support>false</reauthentication-support>
+ </outbound-resourceadapter>
+ </resourceadapter>
+</connector>
Modified: branches/JCA/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestIQueryToLdapSearchParser.java
===================================================================
--- branches/JCA/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestIQueryToLdapSearchParser.java 2009-12-15 19:24:54 UTC (rev 1669)
+++ branches/JCA/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestIQueryToLdapSearchParser.java 2009-12-15 20:07:33 UTC (rev 1670)
@@ -21,15 +21,19 @@
*/
package com.metamatrix.connector.ldap;
+import static org.mockito.Mockito.mock;
+
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import java.util.Properties;
import javax.naming.directory.Attribute;
import javax.naming.directory.SearchControls;
import javax.naming.ldap.SortKey;
+import junit.framework.TestCase;
+
+import org.mockito.Mockito;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.ConnectorLogger;
import org.teiid.connector.language.ICommand;
@@ -37,10 +41,7 @@
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
-import junit.framework.TestCase;
-
import com.metamatrix.cdk.CommandBuilder;
-import com.metamatrix.cdk.api.SysLogger;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.unittest.FakeMetadataFacade;
@@ -249,13 +250,14 @@
}
private LDAPSearchDetails helpGetSearchDetails(String queryString) throws ConnectorException {
- ConnectorLogger logger = new SysLogger(false);
QueryMetadataInterface metadata = exampleLdap();
RuntimeMetadata rm = new RuntimeMetadataImpl(metadata);
- Properties props = new Properties();
- IQueryToLdapSearchParser searchParser = new IQueryToLdapSearchParser(logger,rm,props);
+ LDAPManagedConnectionFactory config = mock(LDAPManagedConnectionFactory.class);
+ Mockito.stub(config.getLogger()).toReturn(Mockito.mock(ConnectorLogger.class));
+ IQueryToLdapSearchParser searchParser = new IQueryToLdapSearchParser(rm, config);
+
IQuery query = (IQuery)getCommand(queryString, metadata);
LDAPSearchDetails searchDetails = searchParser.translateSQLQueryToLDAPSearch(query);
Modified: branches/JCA/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestLDAPConnection.java
===================================================================
--- branches/JCA/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestLDAPConnection.java 2009-12-15 19:24:54 UTC (rev 1669)
+++ branches/JCA/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestLDAPConnection.java 2009-12-15 20:07:33 UTC (rev 1670)
@@ -22,8 +22,10 @@
package com.metamatrix.connector.ldap;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.stub;
+
import java.util.Hashtable;
-import java.util.Properties;
import javax.naming.Context;
import javax.naming.NamingException;
@@ -31,9 +33,8 @@
import org.junit.Test;
import org.mockito.Mockito;
+import org.teiid.connector.api.ConnectorLogger;
-import com.metamatrix.cdk.api.EnvironmentUtility;
-import com.metamatrix.cdk.api.SysLogger;
public class TestLDAPConnection {
@@ -46,11 +47,15 @@
}
@Test public void testInitialization() throws Exception {
- Properties p = new Properties();
- p.setProperty(LDAPConnectorPropertyNames.LDAP_URL, "ldap://foo"); //$NON-NLS-1$
- p.setProperty(LDAPConnectorPropertyNames.LDAP_ADMIN_USER_DN, "admin"); //$NON-NLS-1$
- p.setProperty(LDAPConnectorPropertyNames.LDAP_ADMIN_USER_PASSWORD, "password"); //$NON-NLS-1$
- new LDAPConnection(EnvironmentUtility.createExecutionContext("1", "1"), p, EnvironmentUtility.createStdoutLogger(SysLogger.ERROR), FakeFactory.class.getName()); //$NON-NLS-1$ //$NON-NLS-2$
+
+ LDAPManagedConnectionFactory config = mock(LDAPManagedConnectionFactory.class);
+ stub(config.getLdapUrl()).toReturn("ldap://foo");
+ stub(config.getLdapAdminUserDN()).toReturn("admin");
+ stub(config.getLdapAdminUserPassword()).toReturn("password");
+
+ Mockito.stub(config.getLogger()).toReturn(Mockito.mock(ConnectorLogger.class));
+
+ new LDAPConnection(config, FakeFactory.class.getName());
}
}
Modified: branches/JCA/connectors/pom.xml
===================================================================
--- branches/JCA/connectors/pom.xml 2009-12-15 19:24:54 UTC (rev 1669)
+++ branches/JCA/connectors/pom.xml 2009-12-15 20:07:33 UTC (rev 1670)
@@ -84,13 +84,14 @@
<module>connector-jdbc</module>
<module>connector-loopback</module>
<module>connector-text</module>
+ <module>connector-ldap</module>
+
<!--
-
<module>connector-xml</module>
<module>sandbox</module>
<module>connector-salesforce</module>
<module>salesforce-api</module>
- <module>connector-ldap</module>
+
<module>connector-xml-common</module>
-->
</modules>
15 years, 1 month
teiid SVN: r1669 - in trunk/test-integration/db/src/main/java/org/teiid/test/framework: datasource and 1 other directory.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-12-15 14:24:54 -0500 (Tue, 15 Dec 2009)
New Revision: 1669
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java
Log:
Teiid 781 - removed using the connection proxy because it interfers with the integration tests, also fixed the logger and changed the expected results to support specifying that there are no rows expected for a query.
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java 2009-12-15 19:23:10 UTC (rev 1668)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java 2009-12-15 19:24:54 UTC (rev 1669)
@@ -20,7 +20,6 @@
import org.teiid.adminapi.VDB;
import org.teiid.test.framework.ConfigPropertyLoader;
import org.teiid.test.framework.TestLogger;
-import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
import org.teiid.test.framework.datasource.DataSource;
import org.teiid.test.framework.datasource.DataSourceFactory;
import org.teiid.test.framework.datasource.DataSourceMgr;
@@ -37,6 +36,8 @@
private Properties env = null;
private DataSourceFactory dsFactory;
+ // the useProxy is used for non-teiid connections so that the sources are closed and reconnected all the time
+ private boolean useProxy = false;
public ConnectionStrategy(Properties props, DataSourceFactory dsf) {
@@ -55,6 +56,14 @@
*/
public abstract Connection getConnection() throws QueryTestFailedException;
+ public boolean useProxy() {
+ return this.useProxy;
+ }
+
+ void setUseProxy(boolean useproxy) {
+ this.useProxy = useproxy;
+ }
+
/**
* @since
*/
@@ -121,25 +130,23 @@
if (this.isDataStoreDisabled()) {
return;
}
-
-
- String ac = this.env.getProperty(CONNECTION_STRATEGY_PROPS.AUTOCOMMIT, "true");
- this.autoCommit = Boolean.getBoolean(ac);
-
- com.metamatrix.jdbc.api.Connection c =null;
+
+ com.metamatrix.jdbc.MMConnection c = null;
try {
// the the driver strategy is going to be used to connection directly to the connector binding
// source, then no administration can be done
- java.sql.Connection conn = getConnection();
- if ( conn instanceof com.metamatrix.jdbc.api.Connection) {
- c = (com.metamatrix.jdbc.api.Connection) conn;
- } else {
- return;
- }
+ java.sql.Connection conn = getConnection();
+ if ( conn instanceof com.metamatrix.jdbc.MMConnection) {
+ c = (com.metamatrix.jdbc.MMConnection) conn;
+ } else {
+ TestLogger.log("ConnectionStrategy configuration: connection is not of type MMConnection and therefore no vdb setup will be performed");
+ return;
+ }
+
Admin admin = (Admin)c.getAdminAPI();
-
+
setupVDBConnectorBindings(admin);
@@ -267,7 +274,7 @@
}
ds.setConnection(cs);
-
+
return ds.getConnection();
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java 2009-12-15 19:23:10 UTC (rev 1668)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java 2009-12-15 19:24:54 UTC (rev 1669)
@@ -104,6 +104,7 @@
private void loadDataSourceMappings() throws QueryTestFailedException {
if (ConfigPropertyLoader.getInstance().isDataStoreDisabled()) {
+ TestLogger.log("DataStore usage has been disabled");
return;
}
15 years, 1 month
teiid SVN: r1668 - in trunk/test-integration/db/src/main/java/org/teiid/test: framework and 1 other directories.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-12-15 14:23:10 -0500 (Tue, 15 Dec 2009)
New Revision: 1668
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/TestLogger.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java
Log:
Teiid 781 - removed using the connection proxy because it interfers with the integration tests, also fixed the logger and changed the expected results to support specifying that there are no rows expected for a query.
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java 2009-12-15 17:41:34 UTC (rev 1667)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java 2009-12-15 19:23:10 UTC (rev 1668)
@@ -183,16 +183,19 @@
// printResultSet(results));
// Convert results to ResultsHolder
- actualResults = new ResultsHolder(TagNames.Elements.QUERY_RESULTS);
- actualResults.setQueryID(expectedResults.getQueryID());
- convertResults(resultSet, batchSize, actualResults);
+ if (expectedResults.getRows().size() > 0) {
+ actualResults = new ResultsHolder(TagNames.Elements.QUERY_RESULTS);
+ actualResults.setQueryID(expectedResults.getQueryID());
+ convertResults(resultSet, batchSize, actualResults);
+ compareResults(actualResults, expectedResults, eMsg, isOrdered);
+ }
// DEBUG:
// debugOut.println("*** Actual Results (holder): " +
// actualResults);
// Compare expected results with actual results, record by record
- compareResults(actualResults, expectedResults, eMsg, isOrdered);
+
break;
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/TestLogger.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/TestLogger.java 2009-12-15 17:41:34 UTC (rev 1667)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TestLogger.java 2009-12-15 19:23:10 UTC (rev 1668)
@@ -24,6 +24,10 @@
import java.util.logging.Level;
import java.util.logging.Logger;
+import org.apache.log4j.BasicConfigurator;
+import org.apache.log4j.ConsoleAppender;
+
+
/**
* @author vanhalbert
*
@@ -34,10 +38,13 @@
public static final Level DEBUG = Level.FINEST;
public static final Level IMPORTANT = Level.FINE;
- private static final Logger LOGGER = Logger.getLogger("org.teiid.test");
+ private static final Logger LOGGER = Logger.getLogger("org.teiid.test");
static {
- LOGGER.setLevel(IMPORTANT);
+ BasicConfigurator.configure(new ConsoleAppender());
+
+ LOGGER.setLevel(INFO);
+
}
public static final void setLogLevel(Level level) {
@@ -45,16 +52,16 @@
}
public static final void logDebug(String msg) {
- log(Level.FINEST, msg, null);
+ log(Level.ALL, msg, null);
}
public static final void logDebug(String msg, Throwable t) {
- log(Level.FINEST, msg, t);
+ log(Level.ALL, msg, t);
}
// info related messages, which
public static final void logInfo(String msg) {
- log(Level.FINER, msg, null);
+ log(Level.INFO, msg, null);
}
// configuration related messages
@@ -64,12 +71,13 @@
// most important messages
public static final void log(String msg) {
- log(Level.FINE, msg, null);
+ log(Level.INFO, msg, null);
}
private static final void log(Level javaLevel, Object msg, Throwable t) {
+// System.out.println(msg);
+ if (LOGGER.isLoggable(javaLevel)) {
- if (LOGGER.isLoggable(javaLevel)) {
LOGGER.log(javaLevel, msg.toString(), t);
}
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java 2009-12-15 17:41:34 UTC (rev 1667)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java 2009-12-15 19:23:10 UTC (rev 1668)
@@ -134,9 +134,6 @@
ClassNotFoundException {
TestLogger.log("Creating Datasource Connection: \"" + this.serverName + " - " + this.databaseName + "\""); //$NON-NLS-1$ //$NON-NLS-2$
- // DataSource dataSource = (DataSource)Class.forName(props.getProperty(prefix+DS_DRIVER)).newInstance();
-
-
DataSource ds = (DataSource)Class.forName(this.driver).newInstance();
if (ds instanceof BaseDataSource) {
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java 2009-12-15 17:41:34 UTC (rev 1667)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java 2009-12-15 19:23:10 UTC (rev 1668)
@@ -125,9 +125,10 @@
conn = DriverManager.getConnection(url);
}
- conn = (Connection)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {java.sql.Connection.class}, new CloseInterceptor(conn));
+// if (this.useProxy()) {
+// conn = (Connection)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {java.sql.Connection.class}, new CloseInterceptor(conn));
+// }
-
// } catch (SQLException e) {
} catch (Throwable t) {
15 years, 1 month
teiid SVN: r1667 - in branches/JCA/connectors/sandbox: connector-template and 7 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-12-15 12:41:34 -0500 (Tue, 15 Dec 2009)
New Revision: 1667
Added:
branches/JCA/connectors/sandbox/connector-template/
branches/JCA/connectors/sandbox/connector-template/src/
branches/JCA/connectors/sandbox/connector-template/src/main/
branches/JCA/connectors/sandbox/connector-template/src/main/java/
branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}/
branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}/${connector-name}Capabilities.java
branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}/${connector-name}Connection.java
branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}/${connector-name}Connector.java
branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}/${connector-name}Execution.java
branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}/${connector-name}ManagedConnectionFactory.java
branches/JCA/connectors/sandbox/connector-template/src/main/rar/
branches/JCA/connectors/sandbox/connector-template/src/main/rar/META-INF/
branches/JCA/connectors/sandbox/connector-template/src/main/rar/META-INF/ra.xml
branches/JCA/connectors/sandbox/connector-template/src/main/resources/
branches/JCA/connectors/sandbox/connector-template/src/test/
branches/JCA/connectors/sandbox/connector-template/src/test/java/
branches/JCA/connectors/sandbox/connector-template/src/test/resources/
Log:
TEIID-907: Adding a sample connector template for the purposes of custom CDK development.
Added: branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}/${connector-name}Capabilities.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}/${connector-name}Capabilities.java (rev 0)
+++ branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}/${connector-name}Capabilities.java 2009-12-15 17:41:34 UTC (rev 1667)
@@ -0,0 +1,21 @@
+/*
+ * ${license}
+ */
+package ${package-name};
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.teiid.connector.basic.BasicConnectorCapabilities;
+
+
+/**
+ * Specifies the capabilities of this connector.
+ */
+public class ${connector-name}Capabilities extends BasicConnectorCapabilities {
+
+ // TODO: override "supports*" methods from the BaseConnectorCapabilities to
+ // extend the capabilities of your connector. By specifying the correct capabilities
+ // Teiid will push certain commands and joins etc to be handled by the connector,
+ // which is more performent.
+}
Property changes on: branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}/${connector-name}Capabilities.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}/${connector-name}Connection.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}/${connector-name}Connection.java (rev 0)
+++ branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}/${connector-name}Connection.java 2009-12-15 17:41:34 UTC (rev 1667)
@@ -0,0 +1,33 @@
+/*
+ * ${license}
+ */
+package ${package-name};
+
+import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.api.Execution;
+import org.teiid.connector.api.ExecutionContext;
+import org.teiid.connector.basic.BasicConnection;
+import org.teiid.connector.language.ICommand;
+import org.teiid.connector.metadata.runtime.RuntimeMetadata;
+
+/**
+ * Connection to the resource.
+ */
+public class ${connector-name}Connection extends BasicConnection {
+
+ private ${connector-name}ManagedConnectionFactory config;
+
+ public ${connector-name}Connection(${connector-name}ManagedConnectionFactory env) {
+ this.config = env;
+ }
+
+ @Override
+ public Execution createExecution(ICommand command, ExecutionContext executionContext, RuntimeMetadata metadata) throws ConnectorException {
+ return new ${connector-name}Execution(command, config, metadata);
+ }
+
+ @Override
+ public void close() {
+
+ }
+}
Property changes on: branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}/${connector-name}Connection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}/${connector-name}Connector.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}/${connector-name}Connector.java (rev 0)
+++ branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}/${connector-name}Connector.java 2009-12-15 17:41:34 UTC (rev 1667)
@@ -0,0 +1,38 @@
+/*
+ * ${license}
+ */
+package ${package-name};
+
+import org.teiid.connector.api.Connection;
+import org.teiid.connector.api.ConnectorCapabilities;
+import org.teiid.connector.api.ConnectorEnvironment;
+import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.api.ConnectorLogger;
+import org.teiid.connector.basic.BasicConnector;
+
+
+public class ${connector-name}Connector extends BasicConnector {
+
+ private ${connector-name}ManagedConnectionFactory config;
+
+ @Override
+ public void initialize(ConnectorEnvironment env) throws ConnectorException {
+ super.initialize(env);
+
+ this.config = (${connector-name}ManagedConnectionFactory)env;
+
+ // TODO: do connector initialization here..
+ }
+
+
+ public Connection getConnection() throws ConnectorException {
+ // TODO: create the connector connection here.
+ return new ${connector-name}Connection(this.config);
+ }
+
+ @Override
+ public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
+ // TODO: if you not already defined the Capabilities class in "ra.xml" define it here.
+ return ${connector-name}Capabilities.class;
+ }
+}
Property changes on: branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}/${connector-name}Connector.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}/${connector-name}Execution.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}/${connector-name}Execution.java (rev 0)
+++ branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}/${connector-name}Execution.java 2009-12-15 17:41:34 UTC (rev 1667)
@@ -0,0 +1,189 @@
+/*
+ * ${license}
+ */
+package ${package-name};
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.List;
+import java.util.Random;
+
+import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.api.DataNotAvailableException;
+import org.teiid.connector.api.ProcedureExecution;
+import org.teiid.connector.api.TypeFacility;
+import org.teiid.connector.api.UpdateExecution;
+import org.teiid.connector.basic.BasicExecution;
+import org.teiid.connector.language.IBatchedUpdates;
+import org.teiid.connector.language.ICommand;
+import org.teiid.connector.language.IDelete;
+import org.teiid.connector.language.IInsert;
+import org.teiid.connector.language.IParameter;
+import org.teiid.connector.language.IProcedure;
+import org.teiid.connector.language.IQueryCommand;
+import org.teiid.connector.language.IUpdate;
+import org.teiid.connector.language.IParameter.Direction;
+import org.teiid.connector.metadata.runtime.RuntimeMetadata;
+
+import com.metamatrix.query.optimizer.relational.rules.NewCalculateCostUtil;
+
+
+/**
+ * Execution of a command. This may be select, update or procedure command.
+ */
+public class ${connector-name}Execution extends BasicExecution implements UpdateExecution, ProcedureExecution {
+
+ // Connector resources
+ private ${connector-name}ManagedConnectionFactory config;
+ private ICommand command;
+ private RuntimeMetadata metadata;
+
+ private List<Object> row;
+
+ public ${connector-name}Execution(ICommand command, ${connector-name}ManagedConnectionFactory config, RuntimeMetadata metadata) {
+ this.config = config;
+ this.command = command;
+ this.metadata = metadata;
+ }
+
+ @Override
+ public void execute() throws ConnectorException {
+
+ // Log our command
+ this.config.getLogger().logTrace("executing command: " + command); //$NON-NLS-1$
+
+ // Note that a connector does not have support all types of commands always. If you are
+ // writing read-only then "query" may be sufficient.
+ if (command instanceof IQueryCommand) {
+ IQueryCommand queryCommand = (IQueryCommand)command;
+ // TODO: execute and produce results for "select" command
+ }
+ else if (command instanceof IInsert) {
+ // TODO: fill in for "insert" command support
+ }
+ else if (command instanceof IUpdate) {
+ // TODO: fill in for "update" command support
+ }
+ else if (command instanceof IDelete) {
+ // TODO: fill in for "delete" command support
+ }
+ else if (command instanceof IProcedure) {
+ // TODO: fill in for "procedure" command support
+ }
+ else if (command instanceof IBatchedUpdates) {
+ // TODO: fill in for "batched updates" command support
+ }
+
+ // Note here that we executed the command, however the results are read by calling
+ // next() or getUpdateCounts() or getOutputParameterValues() methods.
+ List types = determineOutputTypes(this.command);
+ createDummyRow(types);
+ }
+
+ @Override
+ public List<?> next() throws ConnectorException, DataNotAvailableException {
+ // create and return one row at a time for your
+
+ return row;
+ }
+
+ @Override
+ public int[] getUpdateCounts() throws DataNotAvailableException, ConnectorException {
+ return new int [] {0};
+ }
+
+ @Override
+ public List<?> getOutputParameterValues() throws ConnectorException {
+ IProcedure proc = (IProcedure)this.command;
+ int count = 0;
+ for (IParameter param : proc.getParameters()) {
+ if (param.getDirection() == Direction.INOUT || param.getDirection() == Direction.OUT || param.getDirection() == Direction.RETURN) {
+ count++;
+ }
+ }
+ return Arrays.asList(new Object[count]);
+ }
+
+
+ @Override
+ public void close() throws ConnectorException {
+ // TODO:cleanup your execution based resources here
+ }
+
+ @Override
+ public void cancel() throws ConnectorException {
+ //TODO: initiate the "abort" of execution
+ }
+
+ private List<Class<?>> determineOutputTypes(ICommand command) throws ConnectorException {
+ // Get select columns and lookup the types in metadata
+ if(command instanceof IQueryCommand) {
+ IQueryCommand query = (IQueryCommand) command;
+ return Arrays.asList(query.getColumnTypes());
+ }
+
+ if (command instanceof IProcedure) {
+ return Arrays.asList(((IProcedure)command).getResultSetColumnTypes());
+ }
+
+ // this is for insert/update/delete calls
+ List<Class<?>> types = new ArrayList<Class<?>>(1);
+ types.add(Integer.class);
+ return types;
+ }
+
+ // TODO: replace this method with your own.
+ private void createDummyRow(List<Class<?>> types) {
+ row = new ArrayList<Object>(types.size());
+
+ for (Class<?> type : types) {
+ row.add(getValue(type) );
+ }
+ }
+
+ // TODO: this method is provided for example purposes only for creating a dummy row.
+ private Object getValue(Class type) {
+ if(type.equals(java.lang.String.class)) {
+ return "some string value";
+ } else if(type.equals(java.lang.Integer.class)) {
+ return new Integer(0);
+ } else if(type.equals(java.lang.Short.class)) {
+ return new Short((short)0);
+ } else if(type.equals(java.lang.Long.class)) {
+ return new Long(0);
+ } else if(type.equals(java.lang.Float.class)) {
+ return new Float(0.0);
+ } else if(type.equals(java.lang.Double.class)) {
+ return new Double(0.0);
+ } else if(type.equals(java.lang.Character.class)) {
+ return new Character('c');
+ } else if(type.equals(java.lang.Byte.class)) {
+ return new Byte((byte)0);
+ } else if(type.equals(java.lang.Boolean.class)) {
+ return Boolean.FALSE;
+ } else if(type.equals(java.math.BigInteger.class)) {
+ return new BigInteger("0");
+ } else if(type.equals(java.math.BigDecimal.class)) {
+ return new BigDecimal("0");
+ } else if(type.equals(java.sql.Date.class)) {
+ return new Date(cal.getTimeInMillis());
+ } else if(type.equals(java.sql.Time.class)) {
+ return new Time(cal.getTimeInMillis());
+ } else if(type.equals(java.sql.Timestamp.class)) {
+ return new Timestamp(cal.getTimeInMillis());
+ } else if(type.equals(TypeFacility.RUNTIME_TYPES.CLOB)) {
+ return this.config.getTypeFacility().convertToRuntimeType("some string value");
+ } else if(type.equals(TypeFacility.RUNTIME_TYPES.BLOB)) {
+ return this.config.getTypeFacility().convertToRuntimeType("some string value");
+ } else {
+ return "some string value";
+ }
+ }
+
+}
Property changes on: branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}/${connector-name}Execution.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}/${connector-name}ManagedConnectionFactory.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}/${connector-name}ManagedConnectionFactory.java (rev 0)
+++ branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}/${connector-name}ManagedConnectionFactory.java 2009-12-15 17:41:34 UTC (rev 1667)
@@ -0,0 +1,12 @@
+/*
+ * ${license}
+ */
+package ${package-name};
+
+import org.teiid.connector.basic.BasicManagedConnectionFactory;
+
+public class ${connector-name}ManagedConnectionFactory extends BasicManagedConnectionFactory{
+
+ // ra.xml files getters and setters go here.
+
+}
Property changes on: branches/JCA/connectors/sandbox/connector-template/src/main/java/${package-name}/${connector-name}ManagedConnectionFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/JCA/connectors/sandbox/connector-template/src/main/rar/META-INF/ra.xml
===================================================================
--- branches/JCA/connectors/sandbox/connector-template/src/main/rar/META-INF/ra.xml (rev 0)
+++ branches/JCA/connectors/sandbox/connector-template/src/main/rar/META-INF/ra.xml 2009-12-15 17:41:34 UTC (rev 1667)
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<connector xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
+ version="1.5">
+
+ <vendor-name>${vendor-name}</vendor-name>
+ <eis-type>${connector-name}</eis-type>
+ <resourceadapter-version>1.0</resourceadapter-version>
+ <license>
+ <description>
+ ${license}
+ </description>
+ <license-required>true</license-required>
+ </license>
+ <resourceadapter>
+ <resourceadapter-class>org.teiid.connector.basic.BasicResourceAdapter</resourceadapter-class>
+
+ <outbound-resourceadapter>
+ <connection-definition>
+ <managedconnectionfactory-class>${package-name}.${connector-name}ManagedConnectionFactory</managedconnectionfactory-class>
+
+ <!-- Common properties for all connectors -->
+ <config-property>
+ <description>Connector Class</description>
+ <config-property-name>ConnectorClass</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>${package-name}.${connector-name}Connector</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Connector Capabilities</description>
+ <description>The class to use to provide the Connector Capabilities</description>
+ <config-property-name>CapabilitiesClass</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>${package-name}.${connector-name}Capabilities</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Is Immutable</description>
+ <description>Is Immutable, True if the source never changes.</description>
+ <config-property-name>Immutable</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>false</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Is XA Capable</description>
+ <description>True, if this connector supports XA Transactions</description>
+ <config-property-name>XaCapable</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>false</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Exception on Exceeding Max Rows</description>
+ <description>Indicates if an Exception should be thrown if the specified value for Maximum Result Rows is exceeded; else no exception and no more than the maximum will be returned</description>
+ <config-property-name>ExceptionOnMaxRows</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>true</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Maximum Result Rows</description>
+ <description>Maximum Result Rows allowed</description>
+ <config-property-name>MaxResultRows</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>10000</config-property-value>
+ </config-property>
+
+ <!-- ${connector-name} Specific properties START -->
+
+
+ <!-- ${connector-name} Specific properties END -->
+
+ <connectionfactory-interface>org.teiid.connector.api.Connector</connectionfactory-interface>
+ <connectionfactory-impl-class>org.teiid.connector.basic.WrappedConnector</connectionfactory-impl-class>
+ <connection-interface>org.teiid.connector.api.Connection</connection-interface>
+ <connection-impl-class>org.teiid.connector.basic.WrappedConnection</connection-impl-class>
+
+ </connection-definition>
+
+ <transaction-support>NoTransaction</transaction-support>
+
+ <authentication-mechanism>
+ <authentication-mechanism-type>BasicPassword</authentication-mechanism-type>
+ <credential-interface>javax.resource.spi.security.PasswordCredential</credential-interface>
+ </authentication-mechanism>
+ <reauthentication-support>false</reauthentication-support>
+ </outbound-resourceadapter>
+ </resourceadapter>
+</connector>
Property changes on: branches/JCA/connectors/sandbox/connector-template/src/main/rar/META-INF/ra.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 1 month
teiid SVN: r1666 - in branches/JCA: connectors and 8 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-12-14 20:04:57 -0500 (Mon, 14 Dec 2009)
New Revision: 1666
Added:
branches/JCA/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextManagedConnectionFactory.java
branches/JCA/connectors/connector-text/src/main/rar/
branches/JCA/connectors/connector-text/src/main/rar/META-INF/
branches/JCA/connectors/connector-text/src/main/rar/META-INF/ra.xml
Removed:
branches/JCA/connectors/connector-text/src/assembly/
branches/JCA/connectors/connector-text/src/main/resources/connector-text.xml
Modified:
branches/JCA/build/assembly/jboss-container/connectors.xml
branches/JCA/connectors/connector-text/pom.xml
branches/JCA/connectors/connector-text/src/main/java/com/metamatrix/connector/text/StringToDateTranslator.java
branches/JCA/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextConnection.java
branches/JCA/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextConnector.java
branches/JCA/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextSynchExecution.java
branches/JCA/connectors/connector-text/src/test/java/com/metamatrix/connector/text/TestTextConnection.java
branches/JCA/connectors/connector-text/src/test/java/com/metamatrix/connector/text/TestTextConnector.java
branches/JCA/connectors/connector-text/src/test/java/com/metamatrix/connector/text/Util.java
branches/JCA/connectors/pom.xml
Log:
TEIID-861: Converted Text Converter to JCA Connector
Modified: branches/JCA/build/assembly/jboss-container/connectors.xml
===================================================================
--- branches/JCA/build/assembly/jboss-container/connectors.xml 2009-12-14 22:41:13 UTC (rev 1665)
+++ branches/JCA/build/assembly/jboss-container/connectors.xml 2009-12-15 01:04:57 UTC (rev 1666)
@@ -17,6 +17,8 @@
<includes>
<include>org.jboss.teiid.connectors:connector-jdbc:rar</include>
<include>org.jboss.teiid.connectors:connector-loopback</include>
+ <include>org.jboss.teiid.connectors:connector-text</include>
+
</includes>
<binaries>
Modified: branches/JCA/connectors/connector-text/pom.xml
===================================================================
--- branches/JCA/connectors/connector-text/pom.xml 2009-12-14 22:41:13 UTC (rev 1665)
+++ branches/JCA/connectors/connector-text/pom.xml 2009-12-15 01:04:57 UTC (rev 1666)
@@ -20,107 +20,29 @@
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-common-core</artifactId>
<scope>provided</scope>
- </dependency>
+ </dependency>
+ <dependency>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
- <!-- This build portion is identical for all the connectors that are deployed; so when making changes make sure
- it applies to all the connectors. This below block computes the classpath, writes to classpath.properties; it replaces
- classpath in the xml file, then bundles current project and its dependencies and xml file in a zip for deployment-->
+
<build>
<plugins>
- <!-- build class path -->
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
+ <artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
- <id>build-classpath</id>
- <phase>generate-sources</phase>
+ <id>build_jar</id>
+ <phase>process-classes</phase>
<goals>
- <goal>build-classpath</goal>
+ <goal>jar</goal>
</goals>
- <configuration>
- <fileSeparator>:</fileSeparator>
- <pathSeparator>;</pathSeparator>
- <prefix>extensionjar</prefix>
- <excludeTransitive>false</excludeTransitive>
- <includeScope>runtime</includeScope>
- <excludeTypes>pom</excludeTypes>
- <outputFile>target/classpath.properties</outputFile>
- <regenerateFile>true</regenerateFile>
- <outputFilterFile>true</outputFilterFile>
- </configuration>
</execution>
</executions>
</plugin>
-
- <!-- bundles all its dependencies in a single zip file -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-dependencies</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- <configuration>
- <excludeTransitive>false</excludeTransitive>
- <includeScope>runtime</includeScope>
- <excludeTypes>pom</excludeTypes>
- <outputDirectory>target/dependency</outputDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>2.2-beta-2</version>
- <configuration>
- <descriptors>
- <descriptor>src/assembly/bundle.xml</descriptor>
- </descriptors>
- <outputDirectory>target/distribution</outputDirectory>
- <workDirectory>target/assembly/work</workDirectory>
- </configuration>
- <executions>
- <execution>
- <id>make-assembly</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
</plugins>
- <!-- replaces the classpath tokens in the xml file -->
- <filters>
- <filter>target/classpath.properties</filter>
- </filters>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>true</filtering>
- <includes>
- <include>**/*.xml</include>
- </includes>
- </resource>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>false</filtering>
- <excludes>
- <exclude>**/*.xml</exclude>
- </excludes>
- </resource>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>false</filtering>
- <excludes>
- <exclude>**/*.xml</exclude>
- </excludes>
- </resource>
- </resources>
-
- </build>
+ </build>
+
</project>
\ No newline at end of file
Modified: branches/JCA/connectors/connector-text/src/main/java/com/metamatrix/connector/text/StringToDateTranslator.java
===================================================================
--- branches/JCA/connectors/connector-text/src/main/java/com/metamatrix/connector/text/StringToDateTranslator.java 2009-12-14 22:41:13 UTC (rev 1665)
+++ branches/JCA/connectors/connector-text/src/main/java/com/metamatrix/connector/text/StringToDateTranslator.java 2009-12-15 01:04:57 UTC (rev 1666)
@@ -22,12 +22,14 @@
package com.metamatrix.connector.text;
-import java.util.*;
-import java.text.*;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
-import org.teiid.connector.api.ConnectorLogger;
-
/**
* <p>This is a helper class for TextTranslators that can be used to translate
* any String that is a representation of a date to a java.util.Date object.
@@ -44,6 +46,8 @@
*/
public class StringToDateTranslator {
+ TextManagedConnectionFactory config;
+
/**
* The SimpleDateFormat objects that are used to translate dates for this
* connector.
@@ -62,8 +66,6 @@
*/
private boolean hasFormatters=false;
- private ConnectorLogger logger;
-
/**
* <p>This class is created by passing it a properties object that contains at least
* one property. The value of this property is a String that can be a delimited list of
@@ -91,16 +93,12 @@
* PropertyValue: Delimiter for value of TextPropertyNames.DATE_RESULT_FORMATS
* </pre>
*/
- public StringToDateTranslator(Properties props, ConnectorLogger logger) {
-
- if (props==null) {
- return;
- }
+ public StringToDateTranslator(TextManagedConnectionFactory config) {
+ this.config = config;
+
+ String dateFormats = config.getDateResultFormats();
+ String dateFormatsDelimiter = config.getDateResultFormatsDelimiter();
- this.logger = logger;
-
- String dateFormats = props.getProperty(TextPropertyNames.DATE_RESULT_FORMATS);
- String dateFormatsDelimiter = props.getProperty(TextPropertyNames.DATE_RESULT_FORMATS_DELIMITER);
if (!(dateFormatsDelimiter == null || dateFormatsDelimiter.trim().length() == 0)) {
if (!(dateFormats == null || dateFormats.trim().length() == 0)) {
createSimpleDateFormats(dateFormats, dateFormatsDelimiter);
@@ -202,7 +200,7 @@
while (tokenizer.hasMoreTokens()) {
String token = tokenizer.nextToken();
- logger.logTrace("Creating simple Date format for formatting String: " +token); //$NON-NLS-1$
+ this.config.getLogger().logTrace("Creating simple Date format for formatting String: " +token); //$NON-NLS-1$
dateFormatStrings.add(token);
SimpleDateFormat formatter = new SimpleDateFormat(token.trim());
@@ -220,7 +218,7 @@
private void createSimpleDateFormat(String dateFormats) {
simpleDateFormats = new ArrayList();
dateFormatStrings = new ArrayList();
- logger.logTrace("Creating simple Date format for formatting String: " +dateFormats); //$NON-NLS-1$
+ this.config.getLogger().logTrace("Creating simple Date format for formatting String: " +dateFormats); //$NON-NLS-1$
SimpleDateFormat formatter = new SimpleDateFormat(dateFormats);
dateFormatStrings.add(dateFormats);
Modified: branches/JCA/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextConnection.java
===================================================================
--- branches/JCA/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextConnection.java 2009-12-14 22:41:13 UTC (rev 1665)
+++ branches/JCA/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextConnection.java 2009-12-15 01:04:57 UTC (rev 1666)
@@ -22,49 +22,78 @@
package com.metamatrix.connector.text;
-import java.util.HashMap;
import java.util.Map;
+import java.util.Properties;
-import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.ExecutionContext;
+import org.teiid.connector.api.MetadataProvider;
import org.teiid.connector.api.ResultSetExecution;
+import org.teiid.connector.api.TypeFacility;
import org.teiid.connector.basic.BasicConnection;
import org.teiid.connector.language.IQuery;
import org.teiid.connector.language.IQueryCommand;
+import org.teiid.connector.metadata.runtime.Column;
+import org.teiid.connector.metadata.runtime.MetadataFactory;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
+import org.teiid.connector.metadata.runtime.Table;
/**
* Implementation of Connection interface for text connection.
*/
-public class TextConnection extends BasicConnection {
+public class TextConnection extends BasicConnection implements MetadataProvider {
// metadata props -- Map<groupName --> Map<propName, propValue>
- Map metadataProps = new HashMap();
+ Map <String, Properties> metadataProps;
// connector props
- ConnectorEnvironment env;
+ private TextManagedConnectionFactory config;
/**
* Constructor.
* @param env
*/
- TextConnection(ConnectorEnvironment env, Map metadataProps) throws ConnectorException {
- this.env = env;
+ TextConnection(TextManagedConnectionFactory env, Map metadataProps) {
+ this.config = env;
this.metadataProps = metadataProps;
}
@Override
- public ResultSetExecution createResultSetExecution(IQueryCommand command,
- ExecutionContext executionContext, RuntimeMetadata metadata)
+ public ResultSetExecution createResultSetExecution(IQueryCommand command, ExecutionContext executionContext, RuntimeMetadata metadata)
throws ConnectorException {
- return new TextSynchExecution((IQuery)command, this, metadata);
+ return new TextSynchExecution(this.config, (IQuery)command, this.metadataProps);
}
@Override
public void close() {
metadataProps = null;
- env.getLogger().logDetail("Text Connection is successfully closed."); //$NON-NLS-1$
}
+
+ @Override
+ public void getConnectorMetadata(MetadataFactory metadataFactory) throws ConnectorException {
+ for (Map.Entry<String, Properties> entry : this.metadataProps.entrySet()) {
+ Properties p = entry.getValue();
+ String columns = p.getProperty(TextPropertyNames.COLUMNS);
+ if (columns == null) {
+ continue;
+ }
+ String types = p.getProperty(TextPropertyNames.TYPES);
+ String[] columnNames = columns.trim().split(","); //$NON-NLS-1$
+ String[] typeNames = null;
+ if (types != null) {
+ typeNames = types.trim().split(","); //$NON-NLS-1$
+ if (typeNames.length != columnNames.length) {
+ throw new ConnectorException(TextPlugin.Util.getString("TextConnector.column_mismatch", entry.getKey())); //$NON-NLS-1$
+ }
+ }
+ Table table = metadataFactory.addTable(entry.getKey().substring(entry.getKey().indexOf('.') + 1));
+ for (int i = 0; i < columnNames.length; i++) {
+ String type = typeNames == null?TypeFacility.RUNTIME_NAMES.STRING:typeNames[i].trim().toLowerCase();
+ Column column = metadataFactory.addColumn(columnNames[i].trim(), type, table);
+ column.setNameInSource(String.valueOf(i));
+ column.setNativeType(TypeFacility.RUNTIME_NAMES.STRING);
+ }
+ }
+ }
}
Modified: branches/JCA/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextConnector.java
===================================================================
--- branches/JCA/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextConnector.java 2009-12-14 22:41:13 UTC (rev 1665)
+++ branches/JCA/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextConnector.java 2009-12-15 01:04:57 UTC (rev 1666)
@@ -35,71 +35,48 @@
import java.util.Properties;
import org.teiid.connector.api.Connection;
-import org.teiid.connector.api.ConnectorCapabilities;
import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorLogger;
-import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.api.MetadataProvider;
-import org.teiid.connector.api.TypeFacility;
import org.teiid.connector.basic.BasicConnector;
-import org.teiid.connector.metadata.runtime.Column;
-import org.teiid.connector.metadata.runtime.MetadataFactory;
-import org.teiid.connector.metadata.runtime.Table;
/**
* Implementation of text connector.
*/
-public class TextConnector extends BasicConnector implements MetadataProvider {
+public class TextConnector extends BasicConnector {
- private ConnectorLogger logger;
- private ConnectorEnvironment env;
+ private TextManagedConnectionFactory config;
private int srcFiles = 0;
private int srcFileErrs = 0;
private Map<String, Properties> metadataProps = new HashMap<String, Properties>();
private String parentDirectory;
- /**
- * Initialization with environment.
- */
- @Override
- public void start(ConnectorEnvironment environment) throws ConnectorException {
- logger = environment.getLogger();
- this.env = environment;
+ @Override
+ public void initialize(ConnectorEnvironment env) throws ConnectorException {
+ super.initialize(env);
+
+ this.config = (TextManagedConnectionFactory)env;
initMetaDataProps();
+
// test connection
- TextConnection test = new TextConnection(this.env, metadataProps);
+ TextConnection test = new TextConnection(this.config, metadataProps);
test.close();
-
- // logging
- logger = environment.getLogger();
- logger.logInfo("Text Connector is started."); //$NON-NLS-1$
}
- public void stop() {
- logger.logInfo("Text Connector is stoped."); //$NON-NLS-1$
- }
- /*
- * @see com.metamatrix.data.Connector#getConnection(com.metamatrix.data.SecurityContext)
- */
- public Connection getConnection(ExecutionContext context) throws ConnectorException {
- return new TextConnection(this.env, metadataProps);
+ public Connection getConnection() throws ConnectorException {
+ return new TextConnection(this.config, metadataProps);
}
private void initMetaDataProps() throws ConnectorException {
- Properties connectorProps = env.getProperties();
- String descriptor = connectorProps.getProperty(TextPropertyNames.DESCRIPTOR_FILE);
- boolean partialStartupAllowed = getPartialStartupAllowedValue(connectorProps);
reinitFileCounts();
try {
- readDescriptor(descriptor,partialStartupAllowed);
+ readDescriptor(this.config.getDescriptorFile(),this.config.isPartialStartupAllowed());
reinitFileCounts();
} catch (ConnectorException ce) {
// If partial startup is not allowed, throw the exception
- if(!partialStartupAllowed ) {
+ if(!this.config.isPartialStartupAllowed() ) {
reinitFileCounts();
throw ce;
// If partial startup is allowed, only throw exception if no files connected
@@ -109,12 +86,8 @@
}
}
}
+
- private boolean getPartialStartupAllowedValue(Properties connectorProps) {
- String partialAllowedStr = connectorProps.getProperty(TextPropertyNames.PARTIAL_STARTUP_ALLOWED,"true"); //$NON-NLS-1$
- return Boolean.valueOf(partialAllowedStr).booleanValue();
- }
-
private void reinitFileCounts() {
this.srcFiles=0;
this.srcFileErrs=0;
@@ -138,7 +111,7 @@
BufferedReader br = null;
try {
br = getReader(descriptorFile);
- logger.logInfo("Reading descriptor file: " + descriptorFile); //$NON-NLS-1$
+ this.config.getLogger().logInfo("Reading descriptor file: " + descriptorFile); //$NON-NLS-1$
String line = null;
// Walk through records, finding matches
@@ -170,14 +143,14 @@
if(connExcep!=null) throw connExcep;
} catch (IOException e) {
- logger.logError(TextPlugin.Util.getString("TextConnection.Error_while_reading_text_file__{0}_1", new Object[] {e.getMessage()}), e); //$NON-NLS-1$
+ this.config.getLogger().logError(TextPlugin.Util.getString("TextConnection.Error_while_reading_text_file__{0}_1", new Object[] {e.getMessage()}), e); //$NON-NLS-1$
throw new ConnectorException(e, TextPlugin.Util.getString("TextConnection.Error_trying_to_establish_connection_5")); //$NON-NLS-1$
} finally {
if (br != null) {
try {br.close();} catch (Exception ee) {}
}
}
- logger.logDetail("Successfully read metadata information from the descriptor file " + descriptorFile); //$NON-NLS-1$
+ this.config.getLogger().logDetail("Successfully read metadata information from the descriptor file " + descriptorFile); //$NON-NLS-1$
}
/**
@@ -261,7 +234,6 @@
metadataProps.put(groupName, props);
}
} catch (Exception e) {
- logger.logError(TextPlugin.Util.getString("TextConnection.Error_parsing_property_string_{0}_5", new Object[] {propStr}), e); //$NON-NLS-1$
throw new ConnectorException(TextPlugin.Util.getString("TextConnection.Error_parsing_property_string_{0}__{1}_6", new Object[] {propStr, e.getMessage()})); //$NON-NLS-1$
}
@@ -353,35 +325,7 @@
return br;
}
- public ConnectorCapabilities getCapabilities() {
- return TextCapabilities.INSTANCE;
- }
- @Override
- public void getConnectorMetadata(MetadataFactory metadataFactory) throws ConnectorException {
- for (Map.Entry<String, Properties> entry : this.metadataProps.entrySet()) {
- Properties p = entry.getValue();
- String columns = p.getProperty(TextPropertyNames.COLUMNS);
- if (columns == null) {
- continue;
- }
- String types = p.getProperty(TextPropertyNames.TYPES);
- String[] columnNames = columns.trim().split(","); //$NON-NLS-1$
- String[] typeNames = null;
- if (types != null) {
- typeNames = types.trim().split(","); //$NON-NLS-1$
- if (typeNames.length != columnNames.length) {
- throw new ConnectorException(TextPlugin.Util.getString("TextConnector.column_mismatch", entry.getKey())); //$NON-NLS-1$
- }
- }
- Table table = metadataFactory.addTable(entry.getKey().substring(entry.getKey().indexOf('.') + 1));
- for (int i = 0; i < columnNames.length; i++) {
- String type = typeNames == null?TypeFacility.RUNTIME_NAMES.STRING:typeNames[i].trim().toLowerCase();
- Column column = metadataFactory.addColumn(columnNames[i].trim(), type, table);
- column.setNameInSource(String.valueOf(i));
- column.setNativeType(TypeFacility.RUNTIME_NAMES.STRING);
- }
- }
- }
+
}
Added: branches/JCA/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextManagedConnectionFactory.java
===================================================================
--- branches/JCA/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextManagedConnectionFactory.java (rev 0)
+++ branches/JCA/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextManagedConnectionFactory.java 2009-12-15 01:04:57 UTC (rev 1666)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package com.metamatrix.connector.text;
+
+import org.teiid.connector.basic.BasicManagedConnectionFactory;
+
+public class TextManagedConnectionFactory extends BasicManagedConnectionFactory{
+
+ private static final long serialVersionUID = -1495488034205703625L;
+
+ private String descriptorFile;
+ private boolean partialStartupAllowed = true;
+ private boolean enforceColumnCount = false;
+ private String dateResultFormatsDelimiter;
+ private String dateResultFormats;
+
+ public String getDescriptorFile() {
+ return descriptorFile;
+ }
+
+ public void setDescriptorFile(String descriptorFile) {
+ this.descriptorFile = descriptorFile;
+ }
+
+ public boolean isPartialStartupAllowed() {
+ return partialStartupAllowed;
+ }
+
+ public void setPartialStartupAllowed(Boolean partialStartupAllowed) {
+ this.partialStartupAllowed = partialStartupAllowed.booleanValue();
+ }
+
+ public boolean isEnforceColumnCount() {
+ return enforceColumnCount;
+ }
+
+ public void setEnforceColumnCount(Boolean enforceColumnCount) {
+ this.enforceColumnCount = enforceColumnCount.booleanValue();
+ }
+
+ public String getDateResultFormatsDelimiter() {
+ return dateResultFormatsDelimiter;
+ }
+
+ public void setDateResultFormatsDelimiter(String dateResultFormatsDelimiter) {
+ this.dateResultFormatsDelimiter = dateResultFormatsDelimiter;
+ }
+
+ public String getDateResultFormats() {
+ return dateResultFormats;
+ }
+
+ public void setDateResultFormats(String dateResultFormats) {
+ this.dateResultFormats = dateResultFormats;
+ }
+
+}
Modified: branches/JCA/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextSynchExecution.java
===================================================================
--- branches/JCA/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextSynchExecution.java 2009-12-14 22:41:13 UTC (rev 1665)
+++ branches/JCA/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextSynchExecution.java 2009-12-15 01:04:57 UTC (rev 1666)
@@ -40,7 +40,6 @@
import java.util.Properties;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorLogger;
import org.teiid.connector.api.DataNotAvailableException;
import org.teiid.connector.api.ResultSetExecution;
import org.teiid.connector.api.TypeFacility;
@@ -53,7 +52,6 @@
import org.teiid.connector.language.ISelectSymbol;
import org.teiid.connector.metadata.runtime.Element;
import org.teiid.connector.metadata.runtime.Group;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.core.util.StringUtil;
@@ -65,16 +63,11 @@
// Command to be executed
private IQuery cmd;
- private TextConnection txtConn;
-
// metadata properties
private Map metadataProps;
- private ConnectorLogger logger;
+ private TextManagedConnectionFactory config;
- // runtime metadata
- private RuntimeMetadata rm;
-
// metadata properties for a given group
private Properties groupProps = null;
@@ -101,7 +94,6 @@
// the number of modeled columsn should match the
// number of colums parsed from the file
private int numModeledColumns = 0;
- private boolean useModeledColumnCntedit=false;
// If a header row is to be used, this is where the
// column names will be saved
@@ -119,11 +111,9 @@
* @param cmd
* @param txtConn
*/
- public TextSynchExecution(IQuery query, TextConnection txtConn, RuntimeMetadata metadata) {
- this.txtConn = txtConn;
- this.rm = metadata;
- this.logger = this.txtConn.env.getLogger();
- this.metadataProps = this.txtConn.metadataProps;
+ public TextSynchExecution(TextManagedConnectionFactory config, IQuery query, Map <String, Properties> metaProps) {
+ this.config = config;
+ this.metadataProps = metaProps;
this.cmd = query;
}
@@ -195,7 +185,7 @@
Object[] params = new Object[] { line };
String msg = TextPlugin.Util.getString("TextSynchExecution.Text_has_no_determined_ending_qualifier", params); //$NON-NLS-1$
- logger.logError(msg);
+ this.config.getLogger().logError(msg);
throw new ConnectorException( msg);
}
@@ -212,11 +202,8 @@
++rowsProduced;
// Save selected columns into query results
- if (this.useModeledColumnCntedit && record.size() != numModeledColumns) {
- Object[] params = new Object[] { new Integer(numModeledColumns), new Integer(record.size()) };
- String msg = TextPlugin.Util.getString("TextSynchExecution.Input_column_cnt_incorrect", params); //$NON-NLS-1$
- logger.logError(msg);
- throw new ConnectorException( msg);
+ if (this.config.isEnforceColumnCount() && record.size() != numModeledColumns) {
+ throw new ConnectorException(TextPlugin.Util.getString("TextSynchExecution.Input_column_cnt_incorrect", new Object[] { new Integer(numModeledColumns), new Integer(record.size()) }));
}
return getRow(record, cols, types);
@@ -224,9 +211,7 @@
} catch(ConnectorException ce) {
throw ce;
} catch(Throwable e) {
- Object[] params = new Object[] { location, e.getMessage() };
- logger.logError(TextPlugin.Util.getString("TextSynchExecution.Error_reading_text_file", params), e); //$NON-NLS-1$
- throw new ConnectorException(e, "Error while reading text file: "+location); //$NON-NLS-1$
+ throw new ConnectorException(e, TextPlugin.Util.getString("TextSynchExecution.Error_reading_text_file", new Object[] { location, e.getMessage() })); //$NON-NLS-1$
}
}
@@ -277,7 +262,7 @@
Object[] params = new Object[] { TextPropertyNames.HEADER_ROW, new Integer(headerRowNum), new Integer(numTop) };
String msg = TextPlugin.Util.getString("TextSynchExecution.Property_contains_an_invalid_value_Using_value", params); //$NON-NLS-1$
// TODO: We should include the group name in the log message.
- logger.logWarning(msg);
+ this.config.getLogger().logWarning(msg);
headerRowNum = numTop;
}
@@ -309,7 +294,6 @@
else {
Object[] params = new Object[] { line };
String msg = TextPlugin.Util.getString("TextSynchExecution.Text_has_no_determined_ending_qualifier", params); //$NON-NLS-1$
- logger.logError(msg);
throw new ConnectorException(msg);
}
}
@@ -329,9 +313,7 @@
} else if (numTop >= lineNum) continue;
}
} catch (Throwable e) {
- Object[] params = new Object[] { location, e.getMessage() };
- logger.logError(TextPlugin.Util.getString("TextSynchExecution.Error_reading_text_file", params), e); //$NON-NLS-1$
- throw new ConnectorException(e, "Error while reading text file: " + location); //$NON-NLS-1$
+ throw new ConnectorException(e, TextPlugin.Util.getString("TextSynchExecution.Error_reading_text_file", new Object[] { location, e.getMessage() })); //$NON-NLS-1$
}
}
@@ -362,7 +344,7 @@
}
}
readerQueue.clear();
- logger.logInfo("TextSynchExecution is successfully closed."); //$NON-NLS-1$
+ this.config.getLogger().logInfo("TextSynchExecution is successfully closed."); //$NON-NLS-1$
}
public void cancel() {
@@ -436,12 +418,6 @@
* @return Object
*/
protected Object submitRequest(Object req) {
- Properties connprops = txtConn.env.getProperties();
-
- String cnt_edit = (String) connprops.get(TextPropertyNames.COLUMN_CNT_MUST_MATCH_MODEL);
- if (cnt_edit != null && cnt_edit.equalsIgnoreCase(Boolean.TRUE.toString())) {
- this.useModeledColumnCntedit = true;
- }
return metadataProps;
}
@@ -466,10 +442,9 @@
String groupName = group.getFullName();
Map metadataMap = (Map) response;
- Properties connProps = this.txtConn.env.getProperties();
- if(connProps.get(TextPropertyNames.DATE_RESULT_FORMATS) != null) {
- stringToDateTranslator = new StringToDateTranslator(connProps, logger);
+ if(this.config.getDateResultFormats() != null) {
+ stringToDateTranslator = new StringToDateTranslator(this.config);
}
groupProps = (Properties) metadataMap.get(groupName.toUpperCase());
@@ -559,13 +534,13 @@
BufferedReader r = new BufferedReader(inSR);
//new FileReader(datafile));
- logger.logInfo("Reading file: " + fileName); //$NON-NLS-1$
+ this.config.getLogger().logInfo("Reading file: " + fileName); //$NON-NLS-1$
readerQueue.add(r);
}
- private void addReader(String fileName, InputStreamReader inSr) throws IOException {
+ private void addReader(String fileName, InputStreamReader inSr) {
BufferedReader r = new BufferedReader(inSr);
- logger.logInfo("Reading URL: " + fileName); //$NON-NLS-1$
+ this.config.getLogger().logInfo("Reading URL: " + fileName); //$NON-NLS-1$
readerQueue.add(r);
}
@@ -602,7 +577,7 @@
* @param symbol Input ISelectSymbol
* @return Element returned metadata runtime Element
*/
- private Element getElementFromSymbol(ISelectSymbol symbol) throws ConnectorException {
+ private Element getElementFromSymbol(ISelectSymbol symbol) {
IElement expr = (IElement) symbol.getExpression();
return expr.getMetadataObject();
}
@@ -740,8 +715,6 @@
if(charIndex < totalChars && line.charAt(charIndex) != delimChar) {
Object[] params = new Object[] { ""+(columns.size()+1), line }; //$NON-NLS-1$
String msg = TextPlugin.Util.getString("TextSynchExecution.Text_file_must_have_delimiter", params);//$NON-NLS-1$
-// Object[] params = new Object[] { location, e.getMessage() };
- logger.logError(msg);
// changed to Connectorexception so that the exception is thrown to the user
// and becomes known a problem, rather than just
// keeping it internally to the server
Added: branches/JCA/connectors/connector-text/src/main/rar/META-INF/ra.xml
===================================================================
--- branches/JCA/connectors/connector-text/src/main/rar/META-INF/ra.xml (rev 0)
+++ branches/JCA/connectors/connector-text/src/main/rar/META-INF/ra.xml 2009-12-15 01:04:57 UTC (rev 1666)
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<connector xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
+ version="1.5">
+
+ <vendor-name>Red Hat Middleware LLC</vendor-name>
+ <eis-type>Teiid JDBC Connector</eis-type>
+ <resourceadapter-version>1.0</resourceadapter-version>
+ <license>
+ <description>
+ JBoss, Home of Professional Open Source.
+ Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ as indicated by the @author tags. See the copyright.txt file in the
+ distribution for a full listing of individual contributors.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ </description>
+ <license-required>true</license-required>
+ </license>
+ <resourceadapter>
+ <resourceadapter-class>org.teiid.connector.basic.BasicResourceAdapter</resourceadapter-class>
+
+ <outbound-resourceadapter>
+ <connection-definition>
+ <managedconnectionfactory-class>com.metamatrix.connector.text.TextManagedConnectionFactory</managedconnectionfactory-class>
+
+ <config-property>
+ <description>Connector Class</description>
+ <config-property-name>ConnectorClass</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>TextConnector.java.TextConnector</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Connector Capabilities</description>
+ <description>The class to use to provide the Connector Capabilities</description>
+ <config-property-name>CapabilitiesClass</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>com.metamatrix.connector.text.TextCapabilities</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Is Immutable</description>
+ <description>Is Immutable, True if the source never changes.</description>
+ <config-property-name>Immutable</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>true</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Is XA Capable</description>
+ <description>True, if this connector supports XA Transactions</description>
+ <config-property-name>XaCapable</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>false</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Exception on Exceeding Max Rows</description>
+ <description>Indicates if an Exception should be thrown if the specified value for Maximum Result Rows is exceeded; else no exception and no more than the maximum will be returned</description>
+ <config-property-name>ExceptionOnMaxRows</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>true</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Maximum Result Rows</description>
+ <description>Maximum Result Rows allowed</description>
+ <config-property-name>MaxResultRows</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>10000</config-property-value>
+ </config-property>
+
+ <!-- Text Connector Specific properties -->
+
+ <config-property>
+ <description>Text File Descriptor</description>
+ <config-property-name>DescriptorFile</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ </config-property>
+
+ <config-property>
+ <description>Partial Startup Allowed</description>
+ <config-property-name>PartialStartupAllowed</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>true</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Enforce Column Count</description>
+ <description>This forces the number of columns in text file to match what was modeled</description>
+ <config-property-name>EnforceColumnCount</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>false</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Date Result Formats Delimiter</description>
+ <config-property-name>DateResultFormatsDelimiter</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ </config-property>
+
+ <config-property>
+ <description>Date Result Formats</description>
+ <config-property-name>DateResultFormats</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ </config-property>
+
+
+ <connectionfactory-interface>org.teiid.connector.api.Connector</connectionfactory-interface>
+ <connectionfactory-impl-class>org.teiid.connector.basic.WrappedConnector</connectionfactory-impl-class>
+ <connection-interface>org.teiid.connector.api.Connection</connection-interface>
+ <connection-impl-class>org.teiid.connector.basic.WrappedConnection</connection-impl-class>
+
+ </connection-definition>
+
+ <transaction-support>NoTransaction</transaction-support>
+
+ <authentication-mechanism>
+ <authentication-mechanism-type>BasicPassword</authentication-mechanism-type>
+ <credential-interface>javax.resource.spi.security.PasswordCredential</credential-interface>
+ </authentication-mechanism>
+ <reauthentication-support>false</reauthentication-support>
+ </outbound-resourceadapter>
+ </resourceadapter>
+</connector>
Deleted: branches/JCA/connectors/connector-text/src/main/resources/connector-text.xml
===================================================================
--- branches/JCA/connectors/connector-text/src/main/resources/connector-text.xml 2009-12-14 22:41:13 UTC (rev 1665)
+++ branches/JCA/connectors/connector-text/src/main/resources/connector-text.xml 2009-12-15 01:04:57 UTC (rev 1666)
@@ -1,12 +0,0 @@
- <ComponentType Name="Text File Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" LastChangedDate="2008-10-31T10:26:19.945-06:00" CreatedBy="ConfigurationStartup" CreationDate="2008-10-31T10:26:19.945-06:00">
- <PropertyDefinition Name="ConnectorTypeClassPath" DisplayName="Connector Type Class Path" ShortDescription="Connector Type classpath (defined by system, do not modify)" DefaultValue="extensionjar:connector_patch.jar;extensionjar:${project.artifactId}-${project.version}.jar;${classpath}" IsModifiable="false" />
- <PropertyDefinition Name="PartialStartupAllowed" DisplayName="Partial Startup Allowed" ShortDescription="" DefaultValue="true" IsRequired="true" PropertyType="Boolean" IsExpert="true" />
- <PropertyDefinition Name="Standard" DisplayName="Standard Type" ShortDescription="Standard Built-in Connector Type" DefaultValue="true" PropertyType="Boolean" IsExpert="true" IsModifiable="false" />
- <PropertyDefinition Name="DescriptorFile" DisplayName="Text File Descriptor" ShortDescription="" IsRequired="true" />
- <PropertyDefinition Name="ConnectorClass" DisplayName="Connector Class" ShortDescription="" DefaultValue="com.metamatrix.connector.text.TextConnector" IsRequired="true" IsExpert="true" />
- <PropertyDefinition Name="EnforceColumnCount" DisplayName="Enforce Column Count" ShortDescription="This forces the number of columns in text file to match what was modeled" DefaultValue="false" PropertyType="Boolean" />
- <PropertyDefinition Name="DateResultFormatsDelimiter" DisplayName="Date Result Formats Delimiter" ShortDescription="" IsExpert="true" />
- <PropertyDefinition Name="DateResultFormats" DisplayName="Date Result Formats" ShortDescription="" IsExpert="true" />
- <PropertyDefinition Name="Immutable" DisplayName="Is Immutable" ShortDescription="True if the source never changes." DefaultValue="true" IsRequired="true" PropertyType="Boolean" IsExpert="true" />
- </ComponentType>
-
\ No newline at end of file
Modified: branches/JCA/connectors/connector-text/src/test/java/com/metamatrix/connector/text/TestTextConnection.java
===================================================================
--- branches/JCA/connectors/connector-text/src/test/java/com/metamatrix/connector/text/TestTextConnection.java 2009-12-14 22:41:13 UTC (rev 1665)
+++ branches/JCA/connectors/connector-text/src/test/java/com/metamatrix/connector/text/TestTextConnection.java 2009-12-15 01:04:57 UTC (rev 1666)
@@ -25,12 +25,12 @@
import java.util.Map;
import java.util.Properties;
-import org.teiid.connector.api.ConnectorEnvironment;
+import junit.framework.TestCase;
+
+import org.mockito.Mockito;
import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.api.ConnectorLogger;
-import junit.framework.TestCase;
-
-import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.core.util.UnitTestUtil;
/**
@@ -49,11 +49,15 @@
String descFile = UnitTestUtil.getTestDataPath() + "/EmployeeTestDataSalary.txt"; //$NON-NLS-1$
props.put(TextPropertyNames.DESCRIPTOR_FILE, descFile);
- ConnectorEnvironment env = EnvironmentUtility.createEnvironment(props, false);
+ TextManagedConnectionFactory config = Mockito.mock(TextManagedConnectionFactory.class);
+ Mockito.stub(config.getDescriptorFile()).toReturn(descFile);
+ Mockito.stub(config.getLogger()).toReturn(Mockito.mock(ConnectorLogger.class));
+
TextConnector txr = new TextConnector();
- txr.start(env);
- TextConnection conn = (TextConnection)txr.getConnection(null);
+ txr.initialize(config);
+ TextConnection conn = (TextConnection)txr.getConnection();
+
Map actualProps = conn.metadataProps;
assertNotNull(actualProps);
}
@@ -65,11 +69,13 @@
Properties props = new Properties();
String descFile = UnitTestUtil.getTestDataPath() + "/testDescriptorDelimited.txt"; //$NON-NLS-1$
- props.put(TextPropertyNames.DESCRIPTOR_FILE, descFile);
+ TextManagedConnectionFactory config = Mockito.mock(TextManagedConnectionFactory.class);
+ Mockito.stub(config.getDescriptorFile()).toReturn(descFile);
+ Mockito.stub(config.getLogger()).toReturn(Mockito.mock(ConnectorLogger.class));
+ Mockito.stub(config.isPartialStartupAllowed()).toReturn(true);
- ConnectorEnvironment env = EnvironmentUtility.createEnvironment(props, false);
TextConnector txr = new TextConnector();
- txr.start(env);
+ txr.initialize(config);
}
/**
@@ -79,13 +85,14 @@
Properties props = new Properties();
String descFile = UnitTestUtil.getTestDataPath() + "/testDescriptorDelimited.txt"; //$NON-NLS-1$
- props.put(TextPropertyNames.DESCRIPTOR_FILE, descFile);
- props.put(TextPropertyNames.PARTIAL_STARTUP_ALLOWED, "false"); //$NON-NLS-1$
+ TextManagedConnectionFactory config = Mockito.mock(TextManagedConnectionFactory.class);
+ Mockito.stub(config.getDescriptorFile()).toReturn(descFile);
+ Mockito.stub(config.isPartialStartupAllowed()).toReturn(false);
+ Mockito.stub(config.getLogger()).toReturn(Mockito.mock(ConnectorLogger.class));
- ConnectorEnvironment env = EnvironmentUtility.createEnvironment(props, false);
TextConnector txr = new TextConnector();
try {
- txr.start(env);
+ txr.initialize(config);
fail("expected exception"); //$NON-NLS-1$
} catch (ConnectorException e) {
String m1 = "Error parsing property string text.library2.location"; //$NON-NLS-1$
@@ -106,12 +113,13 @@
Properties props = new Properties();
String descFile = UnitTestUtil.getTestDataPath() + "/testDescriptorDelimited.txt"; //$NON-NLS-1$
- props.put(TextPropertyNames.DESCRIPTOR_FILE, descFile);
- props.put(TextPropertyNames.PARTIAL_STARTUP_ALLOWED, "true"); //$NON-NLS-1$
+ TextManagedConnectionFactory config = Mockito.mock(TextManagedConnectionFactory.class);
+ Mockito.stub(config.getDescriptorFile()).toReturn(descFile);
+ Mockito.stub(config.isPartialStartupAllowed()).toReturn(true);
+ Mockito.stub(config.getLogger()).toReturn(Mockito.mock(ConnectorLogger.class));
- ConnectorEnvironment env = EnvironmentUtility.createEnvironment(props, false);
TextConnector txr = new TextConnector();
- txr.start(env);
+ txr.initialize(config);
}
}
Modified: branches/JCA/connectors/connector-text/src/test/java/com/metamatrix/connector/text/TestTextConnector.java
===================================================================
--- branches/JCA/connectors/connector-text/src/test/java/com/metamatrix/connector/text/TestTextConnector.java 2009-12-14 22:41:13 UTC (rev 1665)
+++ branches/JCA/connectors/connector-text/src/test/java/com/metamatrix/connector/text/TestTextConnector.java 2009-12-15 01:04:57 UTC (rev 1666)
@@ -22,20 +22,21 @@
package com.metamatrix.connector.text;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import org.junit.Test;
-import org.teiid.connector.api.ConnectorEnvironment;
+import org.mockito.Mockito;
+import org.teiid.connector.api.ConnectorLogger;
+import org.teiid.connector.api.MetadataProvider;
import org.teiid.connector.metadata.runtime.Datatype;
import org.teiid.connector.metadata.runtime.MetadataFactory;
-import org.teiid.connector.metadata.runtime.Schema;
import org.teiid.connector.metadata.runtime.Table;
-import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.core.util.UnitTestUtil;
@@ -48,16 +49,20 @@
Properties props = new Properties();
props.put(TextPropertyNames.DESCRIPTOR_FILE, descFile);
- ConnectorEnvironment env = EnvironmentUtility.createEnvironment(props, false);
+ TextManagedConnectionFactory config = Mockito.mock(TextManagedConnectionFactory.class);
+ Mockito.stub(config.getDescriptorFile()).toReturn(descFile);
+ Mockito.stub(config.getLogger()).toReturn(Mockito.mock(ConnectorLogger.class));
+ Mockito.stub(config.isPartialStartupAllowed()).toReturn(true);
+
TextConnector connector = new TextConnector();
- connector.start(env);
+ connector.initialize(config);
return connector;
}
// descriptor and data file both are files
@Test public void testGetConnection() throws Exception{
TextConnector connector = helpSetUp(DESC_FILE);
- TextConnection conn = (TextConnection) connector.getConnection(null);
+ TextConnection conn = (TextConnection) connector.getConnection();
assertNotNull(conn);
}
@@ -68,8 +73,11 @@
datatypes.put(DataTypeManager.DefaultDataTypes.BIG_INTEGER, new Datatype());
datatypes.put(DataTypeManager.DefaultDataTypes.INTEGER, new Datatype());
datatypes.put(DataTypeManager.DefaultDataTypes.TIMESTAMP, new Datatype());
+
MetadataFactory metadata = new MetadataFactory("SummitData", datatypes, new Properties()); //$NON-NLS-1$
- connector.getConnectorMetadata(metadata);
+
+ ((MetadataProvider)connector.getConnection()).getConnectorMetadata(metadata);
+
assertEquals(0, metadata.getMetadataStore().getSchemas().values().iterator().next().getProcedures().size());
Table group = metadata.getMetadataStore().getSchemas().values().iterator().next().getTables().get("summitdata"); //$NON-NLS-1$
assertEquals("SUMMITDATA", group.getName()); //$NON-NLS-1$
Modified: branches/JCA/connectors/connector-text/src/test/java/com/metamatrix/connector/text/Util.java
===================================================================
--- branches/JCA/connectors/connector-text/src/test/java/com/metamatrix/connector/text/Util.java 2009-12-14 22:41:13 UTC (rev 1665)
+++ branches/JCA/connectors/connector-text/src/test/java/com/metamatrix/connector/text/Util.java 2009-12-15 01:04:57 UTC (rev 1666)
@@ -23,12 +23,13 @@
package com.metamatrix.connector.text;
import java.io.File;
-import java.io.FileInputStream;
import java.util.List;
-import java.util.Properties;
import junit.framework.Assert;
+import org.mockito.Mockito;
+import org.teiid.connector.api.ConnectorLogger;
+
import com.metamatrix.cdk.api.ConnectorHost;
import com.metamatrix.cdk.unittest.FakeTranslationFactory;
import com.metamatrix.core.util.UnitTestUtil;
@@ -37,24 +38,31 @@
static void helpTestExecution(String vdb, String descriptorFile, String sql, int maxBatchSize, int expectedRowCount) throws Exception {
descriptorFile = UnitTestUtil.getTestDataPath() + File.separator + descriptorFile;
- Properties connProps = new Properties();
- connProps.load(new FileInputStream(descriptorFile));
- connProps.put(TextPropertyNames.DESCRIPTOR_FILE, descriptorFile);
- connProps.put(TextPropertyNames.DATE_RESULT_FORMATS, "yyyy-MM-dd,hh:mm:ss,hh:mm,dd/mm/yyyy"); //$NON-NLS-1$
- connProps.put(TextPropertyNames.DATE_RESULT_FORMATS_DELIMITER, ","); //$NON-NLS-1$
- ConnectorHost host = new ConnectorHost(new TextConnector(), connProps, UnitTestUtil.getTestDataPath() + File.separator + vdb, false);
+
+ TextManagedConnectionFactory config = Mockito.mock(TextManagedConnectionFactory.class);
+ Mockito.stub(config.getDescriptorFile()).toReturn(descriptorFile);
+ Mockito.stub(config.isPartialStartupAllowed()).toReturn(true);
+ Mockito.stub(config.getDateResultFormats()).toReturn("yyyy-MM-dd,hh:mm:ss,hh:mm,dd/mm/yyyy");
+ Mockito.stub(config.getDateResultFormatsDelimiter()).toReturn(",");
+ Mockito.stub(config.getLogger()).toReturn(Mockito.mock(ConnectorLogger.class));
+
+ ConnectorHost host = new ConnectorHost(new TextConnector(), config, UnitTestUtil.getTestDataPath() + File.separator + vdb);
List results = host.executeCommand(sql);
Assert.assertEquals("Total row count doesn't match expected size. ", expectedRowCount, results.size()); //$NON-NLS-1$
}
public static ConnectorHost getConnectorHostWithFakeMetadata(String descriptorFile) throws Exception {
- Properties connProps = new Properties();
- connProps.load(new FileInputStream(descriptorFile));
- connProps.put(TextPropertyNames.DESCRIPTOR_FILE, descriptorFile);
- connProps.put(TextPropertyNames.COLUMN_CNT_MUST_MATCH_MODEL, "true");
- connProps.put(TextPropertyNames.DATE_RESULT_FORMATS, "yyyy-MM-dd,hh:mm:ss,hh:mm,dd/mm/yyyy"); //$NON-NLS-1$
- connProps.put(TextPropertyNames.DATE_RESULT_FORMATS_DELIMITER, ","); //$NON-NLS-1$
- ConnectorHost host = new ConnectorHost(new TextConnector(), connProps, FakeTranslationFactory.getInstance().getTextTranslationUtility(), false);
+ TextManagedConnectionFactory config = Mockito.mock(TextManagedConnectionFactory.class);
+ Mockito.stub(config.getDescriptorFile()).toReturn(descriptorFile);
+ Mockito.stub(config.isPartialStartupAllowed()).toReturn(true);
+ Mockito.stub(config.getDateResultFormats()).toReturn("yyyy-MM-dd,hh:mm:ss,hh:mm,dd/mm/yyyy");
+ Mockito.stub(config.getDateResultFormatsDelimiter()).toReturn(",");
+ Mockito.stub(config.isEnforceColumnCount()).toReturn(true);
+
+ Mockito.stub(config.getLogger()).toReturn(Mockito.mock(ConnectorLogger.class));
+
+
+ ConnectorHost host = new ConnectorHost(new TextConnector(), config, FakeTranslationFactory.getInstance().getTextTranslationUtility());
return host;
}
Modified: branches/JCA/connectors/pom.xml
===================================================================
--- branches/JCA/connectors/pom.xml 2009-12-14 22:41:13 UTC (rev 1665)
+++ branches/JCA/connectors/pom.xml 2009-12-15 01:04:57 UTC (rev 1666)
@@ -83,8 +83,9 @@
<modules>
<module>connector-jdbc</module>
<module>connector-loopback</module>
+ <module>connector-text</module>
<!--
- <module>connector-text</module>
+
<module>connector-xml</module>
<module>sandbox</module>
<module>connector-salesforce</module>
15 years, 1 month
teiid SVN: r1665 - trunk/console.
by teiid-commits@lists.jboss.org
Author: loleary
Date: 2009-12-14 17:41:13 -0500 (Mon, 14 Dec 2009)
New Revision: 1665
Modified:
trunk/console/
Log:
Added .classpath, .settings, and .project to SVN ignore list.
Property changes on: trunk/console
___________________________________________________________________
Name: svn:ignore
- target
+ target
.classpath
.settings
.project
15 years, 1 month
teiid SVN: r1664 - in branches/JCA: connector-api/src/main/java/org/teiid/connector/basic and 14 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-12-14 16:26:42 -0500 (Mon, 14 Dec 2009)
New Revision: 1664
Added:
branches/JCA/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackManagedConnectionFactory.java
branches/JCA/connectors/connector-loopback/src/main/rar/
branches/JCA/connectors/connector-loopback/src/main/rar/META-INF/
branches/JCA/connectors/connector-loopback/src/main/rar/META-INF/ra.xml
Removed:
branches/JCA/connector-sdk/src/main/java/com/metamatrix/cdk/IConnectorHost.java
branches/JCA/connector-sdk/src/main/java/com/metamatrix/cdk/api/EnvironmentUtility.java
branches/JCA/connectors/connector-jdbc/src/assembly/
branches/JCA/connectors/connector-loopback/src/assembly/
branches/JCA/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackProperties.java
branches/JCA/connectors/connector-loopback/src/main/resources/connector-loopback.xml
Modified:
branches/JCA/build/assembly/jboss-container/connectors.xml
branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicConnector.java
branches/JCA/connector-sdk/src/main/java/com/metamatrix/cdk/ConnectorShell.java
branches/JCA/connector-sdk/src/main/java/com/metamatrix/cdk/ConnectorShellCommandTarget.java
branches/JCA/connector-sdk/src/main/java/com/metamatrix/cdk/api/ConnectorHost.java
branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TranslationHelper.java
branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/access/TestAccessSQLTranslator.java
branches/JCA/connectors/connector-loopback/pom.xml
branches/JCA/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackConnection.java
branches/JCA/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackConnector.java
branches/JCA/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackExecution.java
branches/JCA/connectors/connector-loopback/src/test/java/com/metamatrix/connector/loopback/TestLoobackAsynch.java
branches/JCA/connectors/connector-loopback/src/test/java/com/metamatrix/connector/loopback/TestLoopbackExecution.java
branches/JCA/connectors/pom.xml
Log:
TEIID-861: Loopback converted to JCA Connector
Modified: branches/JCA/build/assembly/jboss-container/connectors.xml
===================================================================
--- branches/JCA/build/assembly/jboss-container/connectors.xml 2009-12-14 20:20:24 UTC (rev 1663)
+++ branches/JCA/build/assembly/jboss-container/connectors.xml 2009-12-14 21:26:42 UTC (rev 1664)
@@ -16,6 +16,7 @@
<includes>
<include>org.jboss.teiid.connectors:connector-jdbc:rar</include>
+ <include>org.jboss.teiid.connectors:connector-loopback</include>
</includes>
<binaries>
Modified: branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicConnector.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicConnector.java 2009-12-14 20:20:24 UTC (rev 1663)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicConnector.java 2009-12-14 21:26:42 UTC (rev 1664)
@@ -1,9 +1,12 @@
package org.teiid.connector.basic;
import org.teiid.connector.api.Connector;
+import org.teiid.connector.api.ConnectorCapabilities;
import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
+import com.metamatrix.core.util.ReflectionHelper;
+
public abstract class BasicConnector implements Connector {
protected ConnectorEnvironment config;
@@ -17,4 +20,26 @@
public ConnectorEnvironment getConnectorEnvironment(){
return this.config;
}
+
+ public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
+ return BasicConnectorCapabilities.class;
+ }
+
+ @Override
+ public ConnectorCapabilities getCapabilities() throws ConnectorException {
+ // create Capabilities
+ String className = this.config.getCapabilitiesClass();
+ try {
+ ConnectorCapabilities result = null;
+ if (className != null && className.length() > 0) {
+ result = (ConnectorCapabilities) ReflectionHelper.create(className, null, Thread.currentThread().getContextClassLoader());
+ } else {
+ result = getDefaultCapabilities().newInstance();
+ }
+
+ return result;
+ } catch (Exception e) {
+ throw new ConnectorException(e);
+ }
+ }
}
Modified: branches/JCA/connector-sdk/src/main/java/com/metamatrix/cdk/ConnectorShell.java
===================================================================
--- branches/JCA/connector-sdk/src/main/java/com/metamatrix/cdk/ConnectorShell.java 2009-12-14 20:20:24 UTC (rev 1663)
+++ branches/JCA/connector-sdk/src/main/java/com/metamatrix/cdk/ConnectorShell.java 2009-12-14 21:26:42 UTC (rev 1664)
@@ -22,6 +22,7 @@
package com.metamatrix.cdk;
+import com.metamatrix.cdk.api.ConnectorHost;
import com.metamatrix.core.commandshell.CommandShell;
@@ -32,7 +33,7 @@
- public ConnectorShell(IConnectorHost host) {
+ public ConnectorShell(ConnectorHost host) {
super(new ConnectorShellCommandTarget(host));
}
Modified: branches/JCA/connector-sdk/src/main/java/com/metamatrix/cdk/ConnectorShellCommandTarget.java
===================================================================
--- branches/JCA/connector-sdk/src/main/java/com/metamatrix/cdk/ConnectorShellCommandTarget.java 2009-12-14 20:20:24 UTC (rev 1663)
+++ branches/JCA/connector-sdk/src/main/java/com/metamatrix/cdk/ConnectorShellCommandTarget.java 2009-12-14 21:26:42 UTC (rev 1664)
@@ -43,6 +43,7 @@
import org.teiid.connector.api.Connector;
import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.api.ExecutionContext;
import org.teiid.connector.language.ICommand;
import org.teiid.connector.language.IProcedure;
import org.teiid.connector.language.IQuery;
@@ -74,7 +75,7 @@
private static final String CONNECTOR_CLASSPATH = "ConnectorClassPath"; //$NON-NLS-1$
private static final String CONNECTOR_CLASS_NAME = "ConnectorClass"; //$NON-NLS-1$
- private IConnectorHost connectorHost;
+ private ConnectorHost connectorHost;
private Properties connectorProperties = null;
private Connector connector;
private String vdbFileName;
@@ -83,7 +84,7 @@
public ConnectorShellCommandTarget() {
}
- public ConnectorShellCommandTarget(IConnectorHost connectorHost) {
+ public ConnectorShellCommandTarget(ConnectorHost connectorHost) {
this.connectorHost = connectorHost;
}
@@ -116,7 +117,7 @@
*/
public void loadFromScript(String configurationScriptFileName) {
ComponentLoader loader = new ComponentLoader(this.getClass().getClassLoader(), configurationScriptFileName);
- connectorHost = (IConnectorHost) loader.load("ConnectorHost"); //$NON-NLS-1$
+ connectorHost = (ConnectorHost) loader.load("ConnectorHost"); //$NON-NLS-1$
}
public void load(String connectorClassName, String vdbFileName) throws IllegalAccessException,
@@ -135,7 +136,7 @@
public void start() throws IllegalAccessException,
- InstantiationException, ClassNotFoundException {
+ InstantiationException, ClassNotFoundException, ConnectorException {
if (connectorHost == null) {
if (vdbFileName == null) {
throw new RuntimeException(CdkPlugin.Util.getString("ConnectorShellCommandTarget.Connector_must_be_loaded_before_it_can_be_used._1")); //$NON-NLS-1$
@@ -146,7 +147,7 @@
else {
connector = (Connector) connectorClassLoader.loadClass(connectorClassName).newInstance();
}
- connectorHost = new ConnectorHost(connector, connectorProperties, shell.expandFileName(vdbFileName));
+ connectorHost = new ConnectorHost(connector, null, shell.expandFileName(vdbFileName));
}
}
@@ -224,8 +225,8 @@
shell.setPrintStackTraceOnException(printStackOnError);
}
- public void setSecurityContext(String vdbName, int vdbVersion, String userName) {
- getConnectorHost().setSecurityContext(vdbName, vdbVersion, userName, null, null);
+ public void setSecurityContext(ExecutionContext context) {
+ getConnectorHost().setExecutionContext(context);
}
public void setBatchSize(int batchSize) {
@@ -242,22 +243,10 @@
}
}
- private IConnectorHost getConnectorHost() {
+ private ConnectorHost getConnectorHost() {
return connectorHost;
}
- public String getProperties() {
- StringBuffer props = new StringBuffer();
- IConnectorHost host = getConnectorHost();
- if (host != null) {
- Properties properties = host.getConnectorEnvironmentProperties();
- stringifyProperties(properties, props);
- } else if (connectorProperties != null) {
- stringifyProperties(connectorProperties, props);
- }
- return props.toString();
- }
-
public void createTemplate(String filename) {
File file = new File(filename);
if (file.exists()) {
Deleted: branches/JCA/connector-sdk/src/main/java/com/metamatrix/cdk/IConnectorHost.java
===================================================================
--- branches/JCA/connector-sdk/src/main/java/com/metamatrix/cdk/IConnectorHost.java 2009-12-14 20:20:24 UTC (rev 1663)
+++ branches/JCA/connector-sdk/src/main/java/com/metamatrix/cdk/IConnectorHost.java 2009-12-14 21:26:42 UTC (rev 1664)
@@ -1,50 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.cdk;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.Properties;
-
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.language.ICommand;
-
-
-/**
- */
-public interface IConnectorHost {
-
- public Properties getConnectorEnvironmentProperties();
-
- public void setSecurityContext(String vdbName, int vdbVersion, String userName, Serializable trustedPayload);
-
- public void setSecurityContext(String vdbName, int vdbVersion, String userName,
- Serializable trustedPayload, Serializable executionPayload);
-
- public List executeCommand(String query) throws ConnectorException;
-
- ICommand getCommand(String query) throws ConnectorException;
- List executeCommand(ICommand command) throws ConnectorException;
-
- int[] executeBatchedUpdates(String[] updates) throws ConnectorException;
-}
Modified: branches/JCA/connector-sdk/src/main/java/com/metamatrix/cdk/api/ConnectorHost.java
===================================================================
--- branches/JCA/connector-sdk/src/main/java/com/metamatrix/cdk/api/ConnectorHost.java 2009-12-14 20:20:24 UTC (rev 1663)
+++ branches/JCA/connector-sdk/src/main/java/com/metamatrix/cdk/api/ConnectorHost.java 2009-12-14 21:26:42 UTC (rev 1664)
@@ -22,11 +22,12 @@
package com.metamatrix.cdk.api;
-import java.io.Serializable;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import java.util.Properties;
import org.teiid.connector.api.Connection;
import org.teiid.connector.api.Connector;
@@ -40,95 +41,38 @@
import org.teiid.connector.language.ICommand;
import org.teiid.connector.language.impl.BatchedUpdatesImpl;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-import org.teiid.dqp.internal.datamgr.impl.ExecutionContextImpl;
import org.teiid.metadata.index.VDBMetadataFactory;
-import com.metamatrix.cdk.IConnectorHost;
-import com.metamatrix.common.util.PropertiesUtils;
-
/**
* A simple test environment to execute commands on a connector.
* Provides an alternative to deploying the connector in the full DQP environment.
* Can be used for testing a connector.
*/
-public class ConnectorHost implements IConnectorHost {
+public class ConnectorHost {
private Connector connector;
private TranslationUtility util;
- private ConnectorEnvironment connectorEnvironment;
private ExecutionContext executionContext;
- private Properties connectorEnvironmentProperties;
-
- private boolean connectorStarted = false;
- /**
- * Create a new environment to test a connector.
- * @param connector a newly constructed connector to host in the new environment
- * @param connectorEnvironmentProperties the properties to expose to the connector as part of the connector environment
- * @param vdbFileName the path to the VDB file to load and use as the source of metadata for the queries sent to this connector
- */
- public ConnectorHost(Connector connector, Properties connectorEnvironmentProperties, String vdbFileName) {
- this(connector, connectorEnvironmentProperties, vdbFileName, true);
+ public ConnectorHost(Connector connector, ConnectorEnvironment connectorEnvironment, String vdbFileName) throws ConnectorException {
+ initialize(connector, connectorEnvironment, new TranslationUtility(VDBMetadataFactory.getVDBMetadata(vdbFileName)));
}
- public ConnectorHost(Connector connector, Properties connectorEnvironmentProperties, String vdbFileName, boolean showLog) {
- initialize(connector, connectorEnvironmentProperties, new TranslationUtility(VDBMetadataFactory.getVDBMetadata(vdbFileName)), showLog);
+ public ConnectorHost(Connector connector, ConnectorEnvironment connectorEnvironment, TranslationUtility util) throws ConnectorException{
+ initialize(connector, connectorEnvironment, util);
}
- public ConnectorHost(Connector connector, Properties connectorEnvironmentProperties, TranslationUtility util) {
- initialize(connector, connectorEnvironmentProperties, util, true);
- }
-
- public ConnectorHost(Connector connector, Properties connectorEnvironmentProperties, TranslationUtility util, boolean showLog) {
- initialize(connector, connectorEnvironmentProperties, util, showLog);
- }
-
- private void initialize(Connector connector, Properties connectorEnvironmentProperties, TranslationUtility util, boolean showLog) {
-
+ private void initialize(Connector connector, final ConnectorEnvironment env, TranslationUtility util) throws ConnectorException {
this.connector = connector;
this.util = util;
-
- this.connectorEnvironmentProperties = PropertiesUtils.clone(connectorEnvironmentProperties);
+ this.connector.initialize(env);
}
- public void startConnectorIfNeeded() throws ConnectorException {
- if (!connectorStarted) {
- startConnector();
- }
- }
-
- private void startConnector() throws ConnectorException {
- connectorStarted = true;
- }
-
- public Properties getConnectorEnvironmentProperties() {
- return PropertiesUtils.clone(connectorEnvironmentProperties);
- }
-
- public void addResourceToConnectorEnvironment(String resourceName, Object resource) {
- }
-
- /**
- * @see com.metamatrix.cdk.IConnectorHost#setSecurityContext(java.lang.String, java.lang.String, java.lang.String, java.io.Serializable)
- * @since 4.2
- */
- public void setSecurityContext(String vdbName,
- int vdbVersion,
- String userName,
- Serializable trustedPayload) {
- setSecurityContext(vdbName, vdbVersion, userName, trustedPayload, null);
- }
-
- public void setSecurityContext(String vdbName, int vdbVersion, String userName, Serializable trustedPayload, Serializable executionPayload) {
- this.executionContext = new ExecutionContextImpl(vdbName, vdbVersion, executionPayload, "Connection", "Connector<CDK>", "Request", "1", "0"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- }
-
public void setExecutionContext(ExecutionContext context) {
this.executionContext = context;
}
public List executeCommand(String query) throws ConnectorException {
- startConnectorIfNeeded();
Connection connection = null;
try {
@@ -145,7 +89,6 @@
}
public List executeCommand(ICommand command) throws ConnectorException {
- startConnectorIfNeeded();
Connection connection = null;
try {
@@ -163,9 +106,7 @@
private List executeCommand(Connection connection, ICommand command, RuntimeMetadata runtimeMetadata)
throws ConnectorException {
- ExecutionContext execContext = EnvironmentUtility.createExecutionContext("100", "1"); //$NON-NLS-1$ //$NON-NLS-2$
-
- Execution exec = connection.createExecution(command, execContext, runtimeMetadata);
+ Execution exec = connection.createExecution(command, this.executionContext, runtimeMetadata);
exec.execute();
List results = readResultsFromExecution(exec);
exec.close();
@@ -174,7 +115,6 @@
}
public int[] executeBatchedUpdates(String[] updates) throws ConnectorException {
- startConnectorIfNeeded();
Connection connection = null;
try {
@@ -243,4 +183,5 @@
Connection connection = connector.getConnection();
return connection;
}
+
}
Deleted: branches/JCA/connector-sdk/src/main/java/com/metamatrix/cdk/api/EnvironmentUtility.java
===================================================================
--- branches/JCA/connector-sdk/src/main/java/com/metamatrix/cdk/api/EnvironmentUtility.java 2009-12-14 20:20:24 UTC (rev 1663)
+++ branches/JCA/connector-sdk/src/main/java/com/metamatrix/cdk/api/EnvironmentUtility.java 2009-12-14 21:26:42 UTC (rev 1664)
@@ -1,111 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.cdk.api;
-
-import java.io.Serializable;
-
-import org.teiid.connector.api.ConnectorLogger;
-import org.teiid.connector.api.ExecutionContext;
-import org.teiid.dqp.internal.datamgr.impl.ExecutionContextImpl;
-
-
-/**
- * A utility factory class to create connector environment objects that are normally supplied
- * by the MetaMatrix Server. This utility will create objects that can be used for testing
- * of your connector outside the context of the MetaMatrix Server.
- */
-public class EnvironmentUtility {
-
- /**
- * Can't construct - this is a utility class.
- */
- private EnvironmentUtility() {
- }
-
- /**
- * Create a ConnectorLogger that prints to STDOUT at the specified log level (and above).
- * @param logLevel The logLevel as defined in {@link SysLogger}.
- * @return A logger
- */
- public static ConnectorLogger createStdoutLogger(int logLevel) {
- SysLogger logger = new SysLogger();
- logger.setLevel(logLevel);
- return logger;
- }
-
-
- /**
- * Create an ExecutionContext and set just the user name. Dummy information will be
- * created for the other parts of the context.
- * @param user User name
- * @return A SecurityContext / ExecutionContext instance
- */
- public static ExecutionContext createSecurityContext(String user) {
- return new ExecutionContextImpl("vdb", 1, null, "Connection", "ConnectorID<CDK>", "Request", "1", "0"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
- }
-
- /**
- * Create an ExecutionContext and set just the security parts. Dummy information will be
- * created for the other parts of the context.
- * @param vdbName Virtual database name
- * @param vdbVersion Virtual database version
- * @param user User name
- * @param trustedToken Trusted token (passed when creating JDBC Connection)
- * @return A SecurityContext / ExecutionContext instance
- */
- public static ExecutionContext createSecurityContext(String vdbName, int vdbVersion, String user, Serializable trustedToken) {
- return new ExecutionContextImpl(vdbName, vdbVersion, null, "Connection", "ConnectorID<CDK>", "Request", "1", "0"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- }
-
- /**
- * Create an ExecutionContext and set just the requestID and partID. Dummy information will be
- * created for the other parts of the context.
- * @param requestID Unique identifier for the user command within the server
- * @param partID Unique identifier for the source command within the context of a requestID
- * @return A SecurityContext / ExecutionContext instance
- */
- public static ExecutionContext createExecutionContext(String requestID, String partID) {
- return new ExecutionContextImpl("vdb", 1, null, "Connection", "ConnectorID<CDK>", requestID, partID, "0"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- }
-
- /**
- * Create an ExecutionContext and set all of the parts.
- * @param vdbName Virtual database name
- * @param vdbVersion Virtual database version
- * @param user User name
- * @param trustedToken Trusted token (passed when creating JDBC Connection)
- * @param executionPayload Command payload (passed for each command executed on JDBC Statement)
- * @param requestID Unique identifier for the user command within the server
- * @param partID Unique identifier for the source command within the context of a requestID
- * @param connectionID Unique identifier for the connection through which the command is executed
- * @param useResultSetCache Whether to use ResultSet cache if it is enabled.
- * @return A SecurityContext / ExecutionContext instance
- * @since 4.2
- */
- public static ExecutionContext createExecutionContext(String vdbName, int vdbVersion, String user,
- Serializable trustedToken, Serializable executionPayload,
- String connectionID, String connectorID, String requestID, String partID, boolean useResultSetCache) {
- return new ExecutionContextImpl(vdbName, vdbVersion, executionPayload, connectionID, connectorID, requestID, partID, "0"); //$NON-NLS-1$
- }
-
-}
Modified: branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TranslationHelper.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TranslationHelper.java 2009-12-14 20:20:24 UTC (rev 1663)
+++ branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TranslationHelper.java 2009-12-14 21:26:42 UTC (rev 1664)
@@ -22,16 +22,16 @@
package org.teiid.connector.jdbc;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import junit.framework.Assert;
+import org.mockito.Mockito;
import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.api.ExecutionContext;
import org.teiid.connector.jdbc.translator.TranslatedCommand;
import org.teiid.connector.jdbc.translator.Translator;
import org.teiid.connector.language.ICommand;
-import junit.framework.Assert;
-
-import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.cdk.api.TranslationUtility;
import com.metamatrix.cdk.unittest.FakeTranslationFactory;
@@ -61,7 +61,7 @@
public static void helpTestVisitor(String expectedOutput,
Translator translator, ICommand obj) throws ConnectorException {
- TranslatedCommand tc = new TranslatedCommand(EnvironmentUtility.createSecurityContext("user"), translator); //$NON-NLS-1$
+ TranslatedCommand tc = new TranslatedCommand(Mockito.mock(ExecutionContext.class), translator); //$NON-NLS-1$
tc.translateCommand(obj);
assertEquals("Did not get correct sql", expectedOutput, tc.getSql()); //$NON-NLS-1$
}
Modified: branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/access/TestAccessSQLTranslator.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/access/TestAccessSQLTranslator.java 2009-12-14 20:20:24 UTC (rev 1663)
+++ branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/access/TestAccessSQLTranslator.java 2009-12-14 21:26:42 UTC (rev 1664)
@@ -32,7 +32,6 @@
import org.teiid.connector.jdbc.translator.Translator;
import org.teiid.connector.language.ICommand;
-import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.cdk.unittest.FakeTranslationFactory;
Modified: branches/JCA/connectors/connector-loopback/pom.xml
===================================================================
--- branches/JCA/connectors/connector-loopback/pom.xml 2009-12-14 20:20:24 UTC (rev 1663)
+++ branches/JCA/connectors/connector-loopback/pom.xml 2009-12-14 21:26:42 UTC (rev 1664)
@@ -2,16 +2,18 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <artifactId>connectors</artifactId>
- <groupId>org.jboss.teiid</groupId>
- <version>7.0.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>connector-loopback</artifactId>
- <groupId>org.jboss.teiid.connectors</groupId>
- <name>Loopback Connector</name>
- <description>Loopback Connector</description>
+ <parent>
+ <artifactId>connectors</artifactId>
+ <groupId>org.jboss.teiid</groupId>
+ <version>7.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>connector-loopback</artifactId>
+ <groupId>org.jboss.teiid.connectors</groupId>
+ <name>Loopback Connector</name>
+ <packaging>rar</packaging>
+ <description>Loopback Connector</description>
+
<dependencies>
<dependency>
<groupId>org.jboss.teiid</groupId>
@@ -23,101 +25,28 @@
<artifactId>teiid-common-core</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
-
-
- <!-- This build portion is identical for all the connectors that are deployed; so when making changes make sure
- it applies to all the connectors. This below block computes the classpath, writes to classpath.properties; it replaces
- classpath in the xml file, then bundles current project and its dependencies and xml file in a zip for deployment-->
+
<build>
<plugins>
- <!-- build class path -->
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
+ <artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
- <id>build-classpath</id>
- <phase>generate-sources</phase>
+ <id>build_jar</id>
+ <phase>process-classes</phase>
<goals>
- <goal>build-classpath</goal>
+ <goal>jar</goal>
</goals>
- <configuration>
- <fileSeparator>:</fileSeparator>
- <pathSeparator>;</pathSeparator>
- <prefix>extensionjar</prefix>
- <excludeTransitive>false</excludeTransitive>
- <includeScope>runtime</includeScope>
- <excludeTypes>pom</excludeTypes>
- <outputFile>target/classpath.properties</outputFile>
- <regenerateFile>true</regenerateFile>
- <outputFilterFile>true</outputFilterFile>
- </configuration>
</execution>
</executions>
</plugin>
-
- <!-- bundles all its dependencies in a single zip file -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-dependencies</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- <configuration>
- <excludeTransitive>false</excludeTransitive>
- <includeScope>runtime</includeScope>
- <excludeTypes>pom</excludeTypes>
- <outputDirectory>target/dependency</outputDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>2.2-beta-2</version>
- <configuration>
- <descriptors>
- <descriptor>src/assembly/bundle.xml</descriptor>
- </descriptors>
- <outputDirectory>target/distribution</outputDirectory>
- <workDirectory>target/assembly/work</workDirectory>
- </configuration>
- <executions>
- <execution>
- <id>make-assembly</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
</plugins>
- <!-- replaces the classpath tokens in the xml file -->
- <filters>
- <filter>target/classpath.properties</filter>
- </filters>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>true</filtering>
- <includes>
- <include>**/*.xml</include>
- </includes>
- </resource>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>false</filtering>
- <excludes>
- <exclude>**/*.xml</exclude>
- </excludes>
- </resource>
- </resources>
- </build>
-
+ </build>
+
</project>
\ No newline at end of file
Modified: branches/JCA/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackConnection.java
===================================================================
--- branches/JCA/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackConnection.java 2009-12-14 20:20:24 UTC (rev 1663)
+++ branches/JCA/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackConnection.java 2009-12-14 21:26:42 UTC (rev 1664)
@@ -22,7 +22,6 @@
package com.metamatrix.connector.loopback;
-import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.Execution;
import org.teiid.connector.api.ExecutionContext;
@@ -36,20 +35,17 @@
*/
public class LoopbackConnection extends BasicConnection {
- private ConnectorEnvironment env;
+ private LoopbackManagedConnectionFactory config;
- /**
- *
- */
- public LoopbackConnection(ConnectorEnvironment env) {
- this.env = env;
+ public LoopbackConnection(LoopbackManagedConnectionFactory env) {
+ this.config = env;
}
@Override
public Execution createExecution(ICommand command,
ExecutionContext executionContext, RuntimeMetadata metadata)
throws ConnectorException {
- return new LoopbackExecution(command, env, metadata);
+ return new LoopbackExecution(command, config, metadata);
}
@Override
Modified: branches/JCA/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackConnector.java
===================================================================
--- branches/JCA/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackConnector.java 2009-12-14 20:20:24 UTC (rev 1663)
+++ branches/JCA/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackConnector.java 2009-12-14 21:26:42 UTC (rev 1664)
@@ -22,64 +22,37 @@
package com.metamatrix.connector.loopback;
-import org.teiid.connector.api.*;
+import org.teiid.connector.api.Connection;
+import org.teiid.connector.api.ConnectorCapabilities;
+import org.teiid.connector.api.ConnectorEnvironment;
+import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.api.ConnectorLogger;
import org.teiid.connector.basic.BasicConnector;
/**
- * Starting point for the Loopback connector.
+ * Loopback connector.
*/
public class LoopbackConnector extends BasicConnector {
- private ConnectorEnvironment env;
+ private LoopbackManagedConnectionFactory config;
+
+ @Override
+ public void initialize(ConnectorEnvironment env) throws ConnectorException {
+ super.initialize(env);
+
+ this.config = (LoopbackManagedConnectionFactory)env;
+
+ ConnectorLogger logger = config.getLogger();
+ logger.logInfo("Loaded for LoopbackConnector"); //$NON-NLS-1$
+ }
- private ConnectorCapabilities capabilities = new LoopbackCapabilities();
- /**
- *
- */
- public LoopbackConnector() {
- super();
+ public Connection getConnection() throws ConnectorException {
+ return new LoopbackConnection(this.config);
}
@Override
- public void start(ConnectorEnvironment environment) throws ConnectorException {
- this.env = environment;
-
- String capabilityClass = env.getProperties().getProperty(LoopbackProperties.CAPABILITIES_CLASS);
-
- if(capabilityClass != null && capabilityClass.length() > 0) {
- try {
- Class clazz = Thread.currentThread().getContextClassLoader().loadClass(capabilityClass);
- capabilities = (ConnectorCapabilities) clazz.newInstance();
- env.getLogger().logInfo("Loaded " + capabilityClass + " for LoopbackConnector"); //$NON-NLS-1$ //$NON-NLS-2$
- } catch(ClassNotFoundException cnfe) {
- env.getLogger().logError("Capabilities class not found: " + capabilityClass, cnfe); //$NON-NLS-1$
- } catch(IllegalAccessException iae) {
- env.getLogger().logError("Unable to create capabilities class: " + capabilityClass, iae); //$NON-NLS-1$
- } catch(InstantiationException ie) {
- env.getLogger().logError("Unable to create capabilities class: " + capabilityClass, ie); //$NON-NLS-1$
- } catch(ClassCastException cce) {
- env.getLogger().logError("Capabilities class does not extend ConnectorCapabilities: " + capabilityClass, cce); //$NON-NLS-1$
- }
- }
+ public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
+ return LoopbackCapabilities.class;
}
-
- /*
- * @see com.metamatrix.data.Connector#stop()
- */
- public void stop() {
- // nothing to do
- }
-
- /*
- * @see com.metamatrix.data.Connector#getConnection(com.metamatrix.data.SecurityContext)
- */
- public Connection getConnection(ExecutionContext context) throws ConnectorException {
- return new LoopbackConnection(env);
- }
-
- public ConnectorCapabilities getCapabilities() {
- return capabilities;
- }
-
}
Modified: branches/JCA/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackExecution.java
===================================================================
--- branches/JCA/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackExecution.java 2009-12-14 20:20:24 UTC (rev 1663)
+++ branches/JCA/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackExecution.java 2009-12-14 21:26:42 UTC (rev 1664)
@@ -33,7 +33,6 @@
import java.util.List;
import java.util.Random;
-import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.DataNotAvailableException;
import org.teiid.connector.api.ProcedureExecution;
@@ -56,42 +55,33 @@
private static final String ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; //$NON-NLS-1$
// Connector resources
- private ConnectorEnvironment env;
-// private RuntimeMetadata metadata;
+ private LoopbackManagedConnectionFactory config;
private ICommand command;
- // Configuration
- private int rowsNeeded = 1;
- private int waitTime = 0;
- private boolean error = false;
- private int pollInterval = -1;
-
// Execution state
private Random randomNumber = new Random(System.currentTimeMillis());
private List<Object> row;
private boolean waited = false;
private int rowsReturned = 0;
private boolean asynch = false;
+ private int rowsNeeded = 1;
- /**
- *
- */
- public LoopbackExecution(ICommand command, ConnectorEnvironment env, RuntimeMetadata metadata) {
- this.env = env;
+ public LoopbackExecution(ICommand command, LoopbackManagedConnectionFactory config, RuntimeMetadata metadata) {
+ this.config = config;
this.command = command;
}
@Override
public List<?> next() throws ConnectorException, DataNotAvailableException {
// Wait on first batch if necessary
- if(waitTime > 0 && !waited) {
+ if(this.config.getWaitTime() > 0 && !waited) {
// Wait a random amount of time up to waitTime milliseconds
- int randomTimeToWait = randomNumber.nextInt(waitTime);
+ int randomTimeToWait = randomNumber.nextInt(this.config.getWaitTime());
if(asynch) {
// If we're asynch and the wait time was longer than the poll interval,
// then just say we don't have results instead
- if(randomTimeToWait > pollInterval) {
+ if(randomTimeToWait > this.config.getPollIntervalInMilli()) {
waited = true;
throw new DataNotAvailableException(randomTimeToWait);
}
@@ -104,7 +94,7 @@
}
}
- if(rowsReturned < rowsNeeded && row.size() > 0) {
+ if(rowsReturned < this.rowsNeeded && row.size() > 0) {
rowsReturned++;
return row;
}
@@ -117,43 +107,16 @@
*/
@Override
public void execute() throws ConnectorException {
- // Get poll interval
- String pollIntervalString = env.getProperties().getProperty(LoopbackProperties.POLL_INTERVAL);
- if (pollIntervalString != null) {
- asynch = true;
- try {
- pollInterval = Integer.parseInt(pollIntervalString);
- } catch (Exception e) {
- throw new ConnectorException("Invalid " + LoopbackProperties.POLL_INTERVAL + "=" + pollIntervalString); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
+
// Log our command
- env.getLogger().logTrace("Loopback executing command: " + command); //$NON-NLS-1$
+ this.config.getLogger().logTrace("Loopback executing command: " + command); //$NON-NLS-1$
- // Get error mode
- String errorString = env.getProperties().getProperty(LoopbackProperties.ERROR, "false"); //$NON-NLS-1$
- error = errorString.equalsIgnoreCase("true"); //$NON-NLS-1$
- if(error) {
+ if(this.config.isThrowError()) {
throw new ConnectorException("Failing because Error=true"); //$NON-NLS-1$
}
-
- // Get max wait time
- String waitTimeString = env.getProperties().getProperty(LoopbackProperties.WAIT_TIME, "0"); //$NON-NLS-1$
- try {
- waitTime = Integer.parseInt(waitTimeString);
- } catch (Exception e) {
- throw new ConnectorException("Invalid " + LoopbackProperties.WAIT_TIME + "=" + waitTimeString); //$NON-NLS-1$ //$NON-NLS-2$
- }
+
+ this.rowsNeeded = this.config.getRowCount();
- // Get # of rows of data to return
- String rowCountString = env.getProperties().getProperty(LoopbackProperties.ROW_COUNT, "1"); //$NON-NLS-1$
- try {
- rowsNeeded = Integer.parseInt(rowCountString);
- } catch (Exception e) {
- throw new ConnectorException("Invalid " + LoopbackProperties.ROW_COUNT + "=" + rowCountString); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
if (command instanceof IQueryCommand) {
IQueryCommand queryCommand = (IQueryCommand)command;
if (queryCommand.getLimit() != null) {
@@ -293,9 +256,9 @@
} else if(type.equals(java.sql.Timestamp.class)) {
return TIMESTAMP_VAL;
} else if(type.equals(TypeFacility.RUNTIME_TYPES.CLOB)) {
- return env.getTypeFacility().convertToRuntimeType(ALPHA.toCharArray());
+ return this.config.getTypeFacility().convertToRuntimeType(ALPHA.toCharArray());
} else if(type.equals(TypeFacility.RUNTIME_TYPES.BLOB)) {
- return env.getTypeFacility().convertToRuntimeType(ALPHA.getBytes());
+ return this.config.getTypeFacility().convertToRuntimeType(ALPHA.getBytes());
} else {
return getVariableString(10);
}
Added: branches/JCA/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackManagedConnectionFactory.java
===================================================================
--- branches/JCA/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackManagedConnectionFactory.java (rev 0)
+++ branches/JCA/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackManagedConnectionFactory.java 2009-12-14 21:26:42 UTC (rev 1664)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package com.metamatrix.connector.loopback;
+
+import org.teiid.connector.basic.BasicManagedConnectionFactory;
+
+public class LoopbackManagedConnectionFactory extends BasicManagedConnectionFactory{
+
+ private static final long serialVersionUID = 6698482857582937744L;
+
+ private int waitTime = 0;
+ private int rowCount = 1;
+ private boolean throwError = false;
+ private long pollIntervalInMilli = -1;
+
+ public int getWaitTime() {
+ return waitTime;
+ }
+
+ public void setWaitTime(Integer waitTime) {
+ this.waitTime = waitTime.intValue();
+ }
+
+ public int getRowCount() {
+ return rowCount;
+ }
+
+ public void setRowCount(Integer rowCount) {
+ this.rowCount = rowCount;
+ }
+
+ public boolean isThrowError() {
+ return this.throwError;
+ }
+
+ public void setThrowError(Boolean error) {
+ this.throwError = error.booleanValue();
+ }
+
+ public long getPollIntervalInMilli() {
+ return this.pollIntervalInMilli;
+ }
+
+ public void setPollIntervalInMilli(Long intervel) {
+ this.pollIntervalInMilli = intervel.longValue();
+ }
+}
Property changes on: branches/JCA/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackManagedConnectionFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: branches/JCA/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackProperties.java
===================================================================
--- branches/JCA/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackProperties.java 2009-12-14 20:20:24 UTC (rev 1663)
+++ branches/JCA/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackProperties.java 2009-12-14 21:26:42 UTC (rev 1664)
@@ -1,39 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.loopback;
-
-/**
- * Holds property names for the loopback connector
- */
-public interface LoopbackProperties {
-
- public static final String WAIT_TIME = "WaitTime"; //$NON-NLS-1$
- public static final String ROW_COUNT = "RowCount"; //$NON-NLS-1$
- public static final String CAPABILITIES_CLASS = "CapabilitiesClass"; //$NON-NLS-1$
-
- /**
- * Specify true to thow an exception on all queries - useful for failure testing
- */
- public static final String ERROR = "Error"; //$NON-NLS-1$
- public static final String POLL_INTERVAL = "PollInterval"; //$NON-NLS-1$
-}
Added: branches/JCA/connectors/connector-loopback/src/main/rar/META-INF/ra.xml
===================================================================
--- branches/JCA/connectors/connector-loopback/src/main/rar/META-INF/ra.xml (rev 0)
+++ branches/JCA/connectors/connector-loopback/src/main/rar/META-INF/ra.xml 2009-12-14 21:26:42 UTC (rev 1664)
@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<connector xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
+ version="1.5">
+
+ <vendor-name>Red Hat Middleware LLC</vendor-name>
+ <eis-type>Teiid JDBC Connector</eis-type>
+ <resourceadapter-version>1.0</resourceadapter-version>
+ <license>
+ <description>
+ JBoss, Home of Professional Open Source.
+ Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ as indicated by the @author tags. See the copyright.txt file in the
+ distribution for a full listing of individual contributors.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ </description>
+ <license-required>true</license-required>
+ </license>
+ <resourceadapter>
+ <resourceadapter-class>org.teiid.connector.basic.BasicResourceAdapter</resourceadapter-class>
+
+ <outbound-resourceadapter>
+ <connection-definition>
+ <managedconnectionfactory-class>com.metamatrix.connector.loopback.LoopbackManagedConnectionFactory</managedconnectionfactory-class>
+
+ <config-property>
+ <description>Connector Class</description>
+ <config-property-name>ConnectorClass</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>com.metamatrix.connector.loopback.LoopbackConnector</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Connector Capabilities</description>
+ <description>The class to use to provide the Connector Capabilities</description>
+ <config-property-name>CapabilitiesClass</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>com.metamatrix.connector.loopback.LoopbackCapabilities</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Is Immutable</description>
+ <description>Is Immutable, True if the source never changes.</description>
+ <config-property-name>Immutable</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>true</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Is XA Capable</description>
+ <description>True, if this connector supports XA Transactions</description>
+ <config-property-name>XaCapable</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>false</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Exception on Exceeding Max Rows</description>
+ <description>Indicates if an Exception should be thrown if the specified value for Maximum Result Rows is exceeded; else no exception and no more than the maximum will be returned</description>
+ <config-property-name>ExceptionOnMaxRows</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>true</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Maximum Result Rows</description>
+ <description>Maximum Result Rows allowed</description>
+ <config-property-name>MaxResultRows</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>10000</config-property-value>
+ </config-property>
+
+ <!-- Loopback Specific properties -->
+
+ <config-property>
+ <description>Rows Per Query</description>
+ <config-property-name>RowCount</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>1</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Max Random Wait Time</description>
+ <config-property-name>WaitTime</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>0</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Always Throw Error</description>
+ <config-property-name>ThrowError</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>false</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Poll interval if using a Asynchronous Connector </description>
+ <config-property-name>PollIntervalInMilli</config-property-name>
+ <config-property-type>java.lang.Long</config-property-type>
+ </config-property>
+
+ <connectionfactory-interface>org.teiid.connector.api.Connector</connectionfactory-interface>
+ <connectionfactory-impl-class>org.teiid.connector.basic.WrappedConnector</connectionfactory-impl-class>
+ <connection-interface>org.teiid.connector.api.Connection</connection-interface>
+ <connection-impl-class>org.teiid.connector.basic.WrappedConnection</connection-impl-class>
+
+ </connection-definition>
+
+ <transaction-support>NoTransaction</transaction-support>
+
+ <authentication-mechanism>
+ <authentication-mechanism-type>BasicPassword</authentication-mechanism-type>
+ <credential-interface>javax.resource.spi.security.PasswordCredential</credential-interface>
+ </authentication-mechanism>
+ <reauthentication-support>false</reauthentication-support>
+ </outbound-resourceadapter>
+ </resourceadapter>
+</connector>
Property changes on: branches/JCA/connectors/connector-loopback/src/main/rar/META-INF/ra.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: branches/JCA/connectors/connector-loopback/src/main/resources/connector-loopback.xml
===================================================================
--- branches/JCA/connectors/connector-loopback/src/main/resources/connector-loopback.xml 2009-12-14 20:20:24 UTC (rev 1663)
+++ branches/JCA/connectors/connector-loopback/src/main/resources/connector-loopback.xml 2009-12-14 21:26:42 UTC (rev 1664)
@@ -1,9 +0,0 @@
- <ComponentType Name="Loopback Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" LastChangedDate="2008-10-31T10:26:19.945-06:00" CreatedBy="ConfigurationStartup" CreationDate="2008-10-31T10:26:19.945-06:00">
- <PropertyDefinition Name="ConnectorTypeClassPath" DisplayName="Connector Type Class Path" ShortDescription="Connector Type classpath (defined by system, do not modify)" DefaultValue="extensionjar:connector_patch.jar;extensionjar:${project.artifactId}-${project.version}.jar;${classpath}" IsModifiable="false" />
- <PropertyDefinition Name="CapabilitiesClass" DisplayName="Capabilities Class" ShortDescription="" DefaultValue="com.metamatrix.connector.loopback.LoopbackCapabilities" IsRequired="true" IsExpert="true" />
- <PropertyDefinition Name="WaitTime" DisplayName="Max Random Wait Time" ShortDescription="" DefaultValue="0" IsRequired="true" IsExpert="true" />
- <PropertyDefinition Name="ConnectorClass" DisplayName="Connector Class" ShortDescription="" DefaultValue="com.metamatrix.connector.loopback.LoopbackConnector" IsRequired="true" IsExpert="true" />
- <PropertyDefinition Name="RowCount" DisplayName="Rows Per Query" ShortDescription="" DefaultValue="1" IsRequired="true" IsExpert="true" />
- <PropertyDefinition Name="Standard" DisplayName="Standard Type" ShortDescription="Standard Built-in Connector Type" DefaultValue="true" PropertyType="Boolean" IsExpert="true" IsModifiable="false" />
- </ComponentType>
-
\ No newline at end of file
Modified: branches/JCA/connectors/connector-loopback/src/test/java/com/metamatrix/connector/loopback/TestLoobackAsynch.java
===================================================================
--- branches/JCA/connectors/connector-loopback/src/test/java/com/metamatrix/connector/loopback/TestLoobackAsynch.java 2009-12-14 20:20:24 UTC (rev 1663)
+++ branches/JCA/connectors/connector-loopback/src/test/java/com/metamatrix/connector/loopback/TestLoobackAsynch.java 2009-12-14 21:26:42 UTC (rev 1664)
@@ -23,8 +23,10 @@
package com.metamatrix.connector.loopback;
import java.util.List;
-import java.util.Properties;
+import org.mockito.Mockito;
+import org.teiid.connector.api.ConnectorLogger;
+
import junit.framework.TestCase;
import com.metamatrix.cdk.api.ConnectorHost;
@@ -39,12 +41,13 @@
public void test() throws Exception {
LoopbackConnector connector = new LoopbackConnector();
- Properties props = new Properties();
- props.setProperty(LoopbackProperties.POLL_INTERVAL, "100"); //$NON-NLS-1$
- props.setProperty(LoopbackProperties.WAIT_TIME, "200"); //$NON-NLS-1$
- props.setProperty(LoopbackProperties.ROW_COUNT, "1000"); //$NON-NLS-1$
-
- ConnectorHost host = new ConnectorHost(connector, props, FakeTranslationFactory.getInstance().getBQTTranslationUtility());
+ LoopbackManagedConnectionFactory config = Mockito.mock(LoopbackManagedConnectionFactory.class);
+ Mockito.stub(config.getWaitTime()).toReturn(200);
+ Mockito.stub(config.getRowCount()).toReturn(1000);
+ Mockito.stub(config.getPollIntervalInMilli()).toReturn(100L);
+ Mockito.stub(config.getLogger()).toReturn(Mockito.mock(ConnectorLogger.class));
+
+ ConnectorHost host = new ConnectorHost(connector, config, FakeTranslationFactory.getInstance().getBQTTranslationUtility());
List results = host.executeCommand("SELECT intkey from bqt1.smalla"); //$NON-NLS-1$
assertEquals(1000, results.size());
}
Modified: branches/JCA/connectors/connector-loopback/src/test/java/com/metamatrix/connector/loopback/TestLoopbackExecution.java
===================================================================
--- branches/JCA/connectors/connector-loopback/src/test/java/com/metamatrix/connector/loopback/TestLoopbackExecution.java 2009-12-14 20:20:24 UTC (rev 1663)
+++ branches/JCA/connectors/connector-loopback/src/test/java/com/metamatrix/connector/loopback/TestLoopbackExecution.java 2009-12-14 21:26:42 UTC (rev 1664)
@@ -25,12 +25,13 @@
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.List;
-import java.util.Properties;
+import junit.framework.TestCase;
+
+import org.mockito.Mockito;
import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.api.ConnectorLogger;
-import junit.framework.TestCase;
-
import com.metamatrix.cdk.api.ConnectorHost;
import com.metamatrix.cdk.api.TranslationUtility;
import com.metamatrix.cdk.unittest.FakeTranslationFactory;
@@ -41,11 +42,12 @@
super(name);
}
- public Properties exampleProperties(int waitTime, int rowCount) {
- Properties props = new Properties();
- props.setProperty(LoopbackProperties.WAIT_TIME, String.valueOf(waitTime));
- props.setProperty(LoopbackProperties.ROW_COUNT, String.valueOf(rowCount));
- return props;
+ public LoopbackManagedConnectionFactory exampleProperties(int waitTime, int rowCount) {
+ LoopbackManagedConnectionFactory config = Mockito.mock(LoopbackManagedConnectionFactory.class);
+ Mockito.stub(config.getWaitTime()).toReturn(waitTime);
+ Mockito.stub(config.getRowCount()).toReturn(rowCount);
+ Mockito.stub(config.getLogger()).toReturn(Mockito.mock(ConnectorLogger.class));
+ return config;
}
public void helpTestQuery(String sql, TranslationUtility metadata, Object[][] expectedResults) throws ConnectorException {
@@ -53,7 +55,7 @@
}
public void helpTestQuery(String sql, TranslationUtility metadata, int waitTime, int rowCount, Object[][] expectedResults) throws ConnectorException {
- ConnectorHost host = new ConnectorHost(new LoopbackConnector(), exampleProperties(waitTime, rowCount), metadata, false);
+ ConnectorHost host = new ConnectorHost(new LoopbackConnector(), exampleProperties(waitTime, rowCount), metadata);
List actualResults = host.executeCommand(sql);
Modified: branches/JCA/connectors/pom.xml
===================================================================
--- branches/JCA/connectors/pom.xml 2009-12-14 20:20:24 UTC (rev 1663)
+++ branches/JCA/connectors/pom.xml 2009-12-14 21:26:42 UTC (rev 1664)
@@ -12,8 +12,8 @@
<packaging>pom</packaging>
<name>Connectors</name>
<description>This project is aggregator for all the supported connectors.</description>
- <dependencies>
-
+ <dependencies>
+
<!-- Internal Test Dependencies -->
<dependency>
<groupId>org.jboss.teiid</groupId>
@@ -82,8 +82,8 @@
<modules>
<module>connector-jdbc</module>
- <!--
<module>connector-loopback</module>
+ <!--
<module>connector-text</module>
<module>connector-xml</module>
<module>sandbox</module>
15 years, 1 month
teiid SVN: r1663 - trunk/engine/src/main/java/com/metamatrix/connector/metadata/internal.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-12-14 15:20:24 -0500 (Mon, 14 Dec 2009)
New Revision: 1663
Removed:
trunk/engine/src/main/java/com/metamatrix/connector/metadata/internal/IObjectSource.java
Log:
TEIID-869 removing unused class
Deleted: trunk/engine/src/main/java/com/metamatrix/connector/metadata/internal/IObjectSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/connector/metadata/internal/IObjectSource.java 2009-12-14 18:48:26 UTC (rev 1662)
+++ trunk/engine/src/main/java/com/metamatrix/connector/metadata/internal/IObjectSource.java 2009-12-14 20:20:24 UTC (rev 1663)
@@ -1,39 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.metadata.internal;
-
-import java.util.Collection;
-import java.util.Map;
-
-public interface IObjectSource {
-
- /**
- * Return a collection that is results given the groupName(indexName) and
- * search criteria.
- * @param groupName The name of table/index to search.
- * @param criteria The map of metadata field name to MetadataSearchCriteria
- * @return The collection that is the MetadataRecord objects
- * @since 4.3
- */
- Collection getObjects(String groupName, Map criteria);
-}
15 years, 1 month
teiid SVN: r1662 - in trunk: client/src/main/java/com/metamatrix/jdbc/api and 14 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-12-14 13:48:26 -0500 (Mon, 14 Dec 2009)
New Revision: 1662
Removed:
trunk/engine/src/test/java/com/metamatrix/query/parser/TestParseCommandType.java
Modified:
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/BaseDataSource.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDriver.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDriver.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java
trunk/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDataSource.java
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDriver.java
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMStatement.java
trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java
trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestSocketProfile.java
trunk/client/src/main/java/com/metamatrix/dqp/message/RequestMessage.java
trunk/client/src/main/java/com/metamatrix/jdbc/api/ExecutionProperties.java
trunk/client/src/test/java/com/metamatrix/dqp/message/TestRequestMessage.java
trunk/documentation/reference/src/main/docbook/en-US/content/transaction_support.xml
trunk/engine/src/main/java/com/metamatrix/query/parser/QueryParser.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecDynamicSqlInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
trunk/engine/src/main/resources/com/metamatrix/dqp/i18n.properties
trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java
trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
Log:
TEIID-897 TEIID-906 initial changes to autowrap mode and adding the ability to use a set statement to control execution variables.
Modified: trunk/client/src/main/java/com/metamatrix/dqp/message/RequestMessage.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/dqp/message/RequestMessage.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/client/src/main/java/com/metamatrix/dqp/message/RequestMessage.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -68,9 +68,6 @@
// Treat the double quoted strings as variables in the command
private boolean ansiQuotedIdentifiers = true;
- //whether query plan is allowed or not
- private boolean queryPlanAllowed = true;
-
private boolean showPlan = false;
private int rowLimit;
@@ -204,7 +201,7 @@
*/
public String getTxnAutoWrapMode() {
if (txnAutoWrapMode == null) {
- return ExecutionProperties.AUTO_WRAP_OPTIMISTIC;
+ return ExecutionProperties.TXN_WRAP_AUTO;
}
return txnAutoWrapMode;
}
@@ -217,10 +214,9 @@
public void setTxnAutoWrapMode(String txnAutoWrapMode) throws MetaMatrixProcessingException {
if (txnAutoWrapMode != null) {
txnAutoWrapMode = txnAutoWrapMode.toUpperCase();
- if (!(txnAutoWrapMode.equals(ExecutionProperties.AUTO_WRAP_OFF)
- || txnAutoWrapMode.equals(ExecutionProperties.AUTO_WRAP_ON)
- || txnAutoWrapMode.equals(ExecutionProperties.AUTO_WRAP_OPTIMISTIC)
- || txnAutoWrapMode.equals(ExecutionProperties.AUTO_WRAP_PESSIMISTIC))) {
+ if (!(txnAutoWrapMode.equals(ExecutionProperties.TXN_WRAP_OFF)
+ || txnAutoWrapMode.equals(ExecutionProperties.TXN_WRAP_ON)
+ || txnAutoWrapMode.equals(ExecutionProperties.TXN_WRAP_AUTO))) {
throw new MetaMatrixProcessingException(CommonCommPlugin.Util.getString("RequestMessage.invalid_txnAutoWrap", txnAutoWrapMode)); //$NON-NLS-1$
}
}
@@ -315,14 +311,6 @@
this.ansiQuotedIdentifiers = ansiQuotedIdentifiers;
}
- public void setQueryPlanAllowed(boolean allowed) {
- queryPlanAllowed = allowed;
- }
-
- public boolean isQueryPlanAllowed() {
- return queryPlanAllowed;
- }
-
/**
* @return Returns the showPlan.
* @since 4.3
Modified: trunk/client/src/main/java/com/metamatrix/jdbc/api/ExecutionProperties.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/jdbc/api/ExecutionProperties.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/client/src/main/java/com/metamatrix/jdbc/api/ExecutionProperties.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -30,8 +30,6 @@
*/
public interface ExecutionProperties {
-
-
/** Execution property name for XML format */
public static final String PROP_XML_FORMAT = "XMLFormat"; //$NON-NLS-1$
@@ -39,7 +37,7 @@
public static final String PROP_XML_VALIDATION = "XMLValidation"; //$NON-NLS-1$
/** Execution property name for transaction auto wrap mode */
- public static final String PROP_TXN_AUTO_WRAP = "txnAutoWrap"; //$NON-NLS-1$
+ public static final String PROP_TXN_AUTO_WRAP = "autoCommitTxn"; //$NON-NLS-1$
/** Execution property name for partial results mode */
public static final String PROP_PARTIAL_RESULTS_MODE = "partialResultsMode"; //$NON-NLS-1$
@@ -52,22 +50,18 @@
/** Transaction auto wrap constant - never wrap a command execution in a transaction
* and allow multi-source updates to occur outside of a transaction. */
- public static final String AUTO_WRAP_OFF = "OFF"; //$NON-NLS-1$
+ public static final String TXN_WRAP_OFF = "OFF"; //$NON-NLS-1$
/** Transaction auto wrap constant - always wrap every non-transactional command
* execution in a transaction. */
- public static final String AUTO_WRAP_ON = "ON"; //$NON-NLS-1$
+ public static final String TXN_WRAP_ON = "ON"; //$NON-NLS-1$
- /** Transaction auto wrap constant - pessimistic mode assumes that any command
- * execution might require a transaction to be wrapped around it. To determine
- * this an extra server call is made to check whether the command requires
- * a transaction and a transaction will be automatically started. This is most
- * accurate and safe, but has a performance impact. */
- public static final String AUTO_WRAP_PESSIMISTIC = "PESSIMISTIC"; //$NON-NLS-1$
+ /**
+ * Transaction auto wrap constant - checks if a command
+ * requires a transaction and will be automatically wrap it.
+ */
+ public static final String TXN_WRAP_AUTO = "AUTO"; //$NON-NLS-1$
- /** Transaction auto wrap constant */
- public static final String AUTO_WRAP_OPTIMISTIC = "OPTIMISTIC"; //$NON-NLS-1$
-
/**
* Whether to use result set cache if it is available
* @since 4.2
@@ -104,6 +98,5 @@
*/
public static final String SQL_OPTION_SHOWPLAN = "SHOWPLAN"; //$NON-NLS-1$
- public static final String PLAN_NOT_ALLOWED = "planNotAllowed"; //$NON-NLS-1$
}
\ No newline at end of file
Modified: trunk/client/src/test/java/com/metamatrix/dqp/message/TestRequestMessage.java
===================================================================
--- trunk/client/src/test/java/com/metamatrix/dqp/message/TestRequestMessage.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/client/src/test/java/com/metamatrix/dqp/message/TestRequestMessage.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -60,7 +60,7 @@
message.setStyleSheet("myStyleSheet"); //$NON-NLS-1$
message.setExecutionPayload("myExecutionPayload"); //$NON-NLS-1$
try {
- message.setTxnAutoWrapMode(ExecutionProperties.AUTO_WRAP_ON);
+ message.setTxnAutoWrapMode(ExecutionProperties.TXN_WRAP_ON);
} catch (MetaMatrixProcessingException e) {
throw new RuntimeException(e);
}
@@ -89,7 +89,7 @@
assertEquals(new Date(12345678L), copy.getProcessingTimestamp());
assertEquals("myStyleSheet", copy.getStyleSheet()); //$NON-NLS-1$
assertEquals("myExecutionPayload", copy.getExecutionPayload()); //$NON-NLS-1$
- assertEquals(ExecutionProperties.AUTO_WRAP_ON, copy.getTxnAutoWrapMode()); //$NON-NLS-1$
+ assertEquals(ExecutionProperties.TXN_WRAP_ON, copy.getTxnAutoWrapMode()); //$NON-NLS-1$
assertTrue(copy.getValidationMode());
assertEquals("xMLFormat", copy.getXMLFormat()); //$NON-NLS-1$
assertTrue(copy.getShowPlan());
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/BaseDataSource.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/BaseDataSource.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/BaseDataSource.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -201,38 +201,6 @@
private String disableLocalTxn;
- /**
- * A setting that controls how connections created by this DataSource manage transactions for client
- * requests when client applications do not use transactions. Because a Teiid virtual database
- * will likely deal with multiple underlying information sources, Teiid will execute
- * all client requests within the contexts of transactions. This method determines the semantics
- * of creating such transactions when the client does not explicitly do so.
- * <p>
- * The allowable values for this property are:
- * <ul>
- * <li>"<code>OFF</code>" - Nothing is ever wrapped in a transaction and the server will execute
- * multi-source updates happily but outside a transaction. This is least safe but highest performance.
- * The {@link #TXN_AUTO_WRAP_OFF} constant value is provided for convenience.</li>
- * <li>"<code>ON</code>" - Always wrap every command in a transaction. This is most safe but lowest
- * performance.
- * The {@link #TXN_AUTO_WRAP_ON} constant value is provided for convenience.</li>
- * <li>"<code>PESSIMISTIC</code>" - Assume that any command might require a transaction. Make a server
- * call to check whether the command being executed needs a transaction and wrap the command in a
- * transaction if necessary. This will auto wrap in exactly the cases where it is needed but requires
- * an extra server call on every command execution (including queries). This is as safe as ON, but
- * lower performance than OFF for cases where no transaction is actually needed (like queries).
- * This is the default value.
- * The {@link #TXN_AUTO_WRAP_PESSIMISTIC} constant value is provided for convenience.</li>
- * <li>"<code>OPTIMISTIC</code>" - same as OFF but assume that no command not in a transaction actually
- * needs one. In other words, we're letting the user decide when to use and not use a transaction and
- * assuming they are doing it correctly. Only difference from OFF is that if the user executes a command
- * that requires a transaction but they don't use one, we will detect this and throw an exception. This
- * provides the safety of ON or PESSIMISTIC mode but better performance in the common case of queries
- * that are not multi-source.
- * The {@link #TXN_AUTO_WRAP_OPTIMISTIC} constant value is provided for convenience.</li>
- * </ul>
- * </p>
- */
private String transactionAutoWrap;
private boolean ansiQuotedIdentifiers = true;
@@ -252,35 +220,21 @@
* Transaction auto wrap constant - never wrap a command execution in a transaction
* and allow multi-source updates to occur outside of a transaction.
*/
- public static final String TXN_AUTO_WRAP_OFF = "OFF"; //$NON-NLS-1$
+ public static final String TXN_WRAP_OFF = ExecutionProperties.TXN_WRAP_OFF;
/**
* Transaction auto wrap constant - always wrap every non-transactional command
* execution in a transaction.
*/
- public static final String TXN_AUTO_WRAP_ON = "ON"; //$NON-NLS-1$
+ public static final String TXN_WRAP_ON = ExecutionProperties.TXN_WRAP_ON;
/**
- * Transaction auto wrap constant - pessimistic mode assumes that any command
- * execution might require a transaction to be wrapped around it. To determine
- * this an extra server call is made to check whether the command requires
- * a transaction and a transaction will be automatically started. This is most
- * accurate and safe, but has a performance impact.
+ * Transaction auto wrap constant - checks if a command
+ * requires a transaction and will be automatically wrap it.
*/
- public static final String TXN_AUTO_WRAP_PESSIMISTIC = "PESSIMISTIC"; //$NON-NLS-1$
+ public static final String TXN_WRAP_AUTO = ExecutionProperties.TXN_WRAP_AUTO;
/**
- * Transaction auto wrap constant - optimistic mode assumes that non-transactional
- * commands typically do not require a transaction due to a multi-source update,
- * so no transaction is created. In this respect, this mode is identical to
- * {@link #TXN_AUTO_WRAP_OFF}. However, these modes differ because if we
- * discover during server execution that multiple sources will be updated by
- * a particular command, an exception is thrown to indicate that the command
- * cannot be executed. This is the default mode.
- */
- public static final String TXN_AUTO_WRAP_OPTIMISTIC = "OPTIMISTIC"; //$NON-NLS-1$
-
- /**
* String to hold additional properties that are not represented with an explicit getter/setter
*/
private String additionalProperties;
@@ -733,7 +687,8 @@
}
/**
- * @see #getTxnAutoWrap()
+ * @deprecated
+ * @see #getAutoCommitTxn()
* @return
*/
public String getTransactionAutoWrap() {
@@ -741,7 +696,8 @@
}
/**
- * @see #setTxnAutoWrap(String)
+ * @deprecated
+ * @see #setAutoCommitTxn(String)
* @param transactionAutoWrap
*/
public void setTransactionAutoWrap(String transactionAutoWrap) {
@@ -758,13 +714,13 @@
* @return the current setting, or null if the property has not been set and the default mode will
* be used.
*/
- public String getTxnAutoWrap() {
+ public String getAutoCommitTxn() {
return this.transactionAutoWrap;
}
/**
* Sets the setting for how connections are created by this DataSource manage transactions
- * for client requests when client applications do not use transactions.
+ * for client requests with autoCommit = true.
* Because a virtual database will likely deal with multiple underlying information sources,
* Teiid will execute all client requests within the contexts of transactions.
* This method determines the semantics of creating such transactions when the client does not
@@ -774,28 +730,18 @@
* <ul>
* <li>"<code>OFF</code>" - Nothing is ever wrapped in a transaction and the server will execute
* multi-source updates happily but outside a transaction. This is least safe but highest performance.
- * The {@link #TXN_AUTO_WRAP_OFF} constant value is provided for convenience.</li>
+ * The {@link #TXN_WRAP_OFF} constant value is provided for convenience.</li>
* <li>"<code>ON</code>" - Always wrap every command in a transaction. This is most safe but lowest
* performance.
- * The {@link #TXN_AUTO_WRAP_ON} constant value is provided for convenience.</li>
- * <li>"<code>PESSIMISTIC</code>" - Assume that any command might require a transaction. Make a server
- * call to check whether the command being executed needs a transaction and wrap the command in a
- * transaction if necessary. This will auto wrap in exactly the cases where it is needed but requires
- * an extra server call on every command execution (including queries). This is as safe as ON, but
- * lower performance than OFF for cases where no transaction is actually needed (like queries).
- * The {@link #TXN_AUTO_WRAP_PESSIMISTIC} constant value is provided for convenience.</li>
- * <li>"<code>OPTIMISTIC</code>" - same as OFF but assume that no command not in a transaction actually
- * needs one. In other words, we're letting the user decide when to use and not use a transaction and
- * assuming they are doing it correctly. Only difference from OFF is that if the user executes a command
- * that requires a transaction but they don't use one, we will detect this and throw an exception. This
- * provides the safety of ON or PESSIMISTIC mode but better performance in the common case of queries
- * that are not multi-source.
- * The {@link #TXN_AUTO_WRAP_OPTIMISTIC} constant value is provided for convenience.</li>
+ * The {@link #TXN_WRAP_ON} constant value is provided for convenience.</li>
+ * <li>"<code>AUTO</code>" - checks if a command requires a transaction and will be automatically wrap it.
+ * This is the default mode.
+ * The {@link #TXN_WRAP_AUTO} constant value is provided for convenience.</li>
* </ul>
* </p>
* @param transactionAutoWrap The transactionAutoWrap to set
*/
- public void setTxnAutoWrap(String transactionAutoWrap) {
+ public void setAutoCommitTxn(String transactionAutoWrap) {
this.transactionAutoWrap = transactionAutoWrap;
}
@@ -865,21 +811,18 @@
return null; // no longer require an app server name, 'cause will look on classpath
}
final String trimmedAutoWrap = autoWrap.trim();
- if( TXN_AUTO_WRAP_ON.equals(trimmedAutoWrap) ) {
+ if( TXN_WRAP_ON.equals(trimmedAutoWrap) ) {
return null;
}
- if( TXN_AUTO_WRAP_OFF.equals(trimmedAutoWrap) ) {
+ if( TXN_WRAP_OFF.equals(trimmedAutoWrap) ) {
return null;
}
- if( TXN_AUTO_WRAP_OPTIMISTIC.equals(trimmedAutoWrap) ) {
+ if( TXN_WRAP_AUTO.equals(trimmedAutoWrap) ) {
return null;
}
- if( TXN_AUTO_WRAP_PESSIMISTIC.equals(trimmedAutoWrap) ) {
- return null;
- }
Object[] params = new Object[] {
- TXN_AUTO_WRAP_ON, TXN_AUTO_WRAP_OFF, TXN_AUTO_WRAP_OPTIMISTIC, TXN_AUTO_WRAP_PESSIMISTIC };
+ TXN_WRAP_ON, TXN_WRAP_OFF, TXN_WRAP_AUTO };
return JDBCPlugin.Util.getString("MMDataSource.Invalid_trans_auto_wrap_mode", params); //$NON-NLS-1$
}
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDriver.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDriver.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDriver.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -74,7 +74,7 @@
/**
* Returns true if the driver thinks that it can open a connection to the given URL. Typically drivers will return true if
* they understand the subprotocol specified in the URL and false if they don't. Expected URL format is
- * jdbc:metamatrix:VDB@pathToPropertyFile;version=1;logFile=<logFile.log>;logLevel=<logLevel>;txnAutoWrap=<?>
+ * jdbc:metamatrix:VDB@pathToPropertyFile;version=1;logFile=<logFile.log>;logLevel=<logLevel>;property=<?>
*
* @param The URL used to establish a connection.
* @return A boolean value indicating whether the driver understands the subprotocol.
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -134,7 +134,7 @@
// set default properties if not overridden
String overrideProp = info.getProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP);
if ( overrideProp == null || overrideProp.trim().length() == 0 ) {
- info.put(ExecutionProperties.PROP_TXN_AUTO_WRAP, ExecutionProperties.AUTO_WRAP_OPTIMISTIC);
+ info.put(ExecutionProperties.PROP_TXN_AUTO_WRAP, ExecutionProperties.TXN_WRAP_AUTO);
}
// Get default fetch size
@@ -177,6 +177,10 @@
this.disableLocalTransactions = Boolean.valueOf(this.propInfo.getProperty(ExecutionProperties.DISABLE_LOCAL_TRANSACTIONS)).booleanValue();
}
+ protected Properties getConnectionProperties() {
+ return this.propInfo;
+ }
+
ClientSideDQP getDQP() {
return this.dqp;
}
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDriver.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDriver.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDriver.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -152,7 +152,7 @@
* These include required and any optional properties specified in the URL.
* Expected URL format -- jdbc:metamatrix:local:VDB@server:port;version=1;user=logon;
* password=pw;logFile=<logFile.log>;
- * logLevel=<logLevel>;txnAutoWrap=<?>;credentials=mycredentials
+ * logLevel=<logLevel>;credentials=mycredentials
* @param The URL needed to be parsed.
* @param The properties object which is to be updated with properties in the URL.
* @throws SQLException if the URL is not in the expected format.
@@ -195,7 +195,7 @@
* Typically drivers will return true if they understand the subprotocol specified
* in the URL and false if they don't.
* Expected URL format is
- * jdbc:metamatrix:subprotocol:VDB@server:port;version=1;logFile=<logFile.log>;logLevel=<logLevel>;txnAutoWrap=<?>
+ * jdbc:metamatrix:subprotocol:VDB@server:port;version=1;logFile=<logFile.log>;logLevel=<logLevel>;
* @param The URL used to establish a connection.
* @return A boolean value indicating whether the driver understands the subprotocol.
* @throws SQLException, should never occur
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -45,12 +45,13 @@
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.comm.exception.CommunicationException;
-import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.common.util.SqlUtil;
import com.metamatrix.dqp.client.ClientSideDQP;
import com.metamatrix.dqp.message.ParameterInfo;
@@ -154,6 +155,8 @@
//Map<out/inout/return param index --> index in results>
protected Map outParamIndexMap = new HashMap();
+ private Pattern setStatement = Pattern.compile("\\s*set\\s*(\\w+)\\s*=\\s*(\\w*)", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
+
/**
* Factory Constructor
* @param driverConnection
@@ -174,7 +177,7 @@
this.driverConnection = driverConnection;
this.resultSetType = resultSetType;
this.resultSetConcurrency = resultSetConcurrency;
- this.execProps = PropertiesUtils.clone(getConnectionProperties());
+ this.execProps = new Properties(this.driverConnection.getConnectionProperties());
// Set initial fetch size
String fetchSizeStr = this.execProps.getProperty(ExecutionProperties.PROP_FETCH_SIZE);
@@ -403,8 +406,20 @@
throws SQLException, MMSQLException {
checkStatement();
resetExecutionState();
- RequestMessage reqMessage = createRequestMessage(commands,
- isBatchedCommand, requiresResultSet);
+
+ //handle set statement
+ if (commands.length == 1 && requiresResultSet != Boolean.TRUE) {
+ Matcher match = setStatement.matcher(commands[0]);
+ if (match.matches()) {
+ String key = match.group(1);
+ String value = match.group(2);
+ this.driverConnection.getConnectionProperties().setProperty(key, value);
+ this.updateCounts = new int[] {1};
+ return;
+ }
+ }
+
+ RequestMessage reqMessage = createRequestMessage(commands, isBatchedCommand, requiresResultSet);
ResultsMessage resultsMsg = null;
try {
resultsMsg = sendRequestMessageAndWait(reqMessage);
@@ -704,17 +719,12 @@
}
}
- protected Properties getConnectionProperties() {
- return driverConnection.propInfo;
- }
-
/**
* Helper method for copy the connection properties to request message.
* @param res Request message that these properties to be copied to.
- * @param props Connection properties.
* @throws MMSQLException
*/
- protected void copyPropertiesToRequest(RequestMessage res, Properties props) throws MMSQLException {
+ protected void copyPropertiesToRequest(RequestMessage res) throws MMSQLException {
// Get partial mode
String partial = getExecutionProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE);
res.setPartialResults(Boolean.valueOf(partial).booleanValue());
@@ -748,8 +758,6 @@
// Get result set cache mode
String rsCache = getExecutionProperty(ExecutionProperties.RESULT_SET_CACHE_MODE);
res.setUseResultSetCache(Boolean.valueOf(rsCache).booleanValue());
-
- res.setQueryPlanAllowed(!Boolean.valueOf(getExecutionProperty(ExecutionProperties.PLAN_NOT_ALLOWED)).booleanValue());
}
/**
@@ -844,7 +852,7 @@
reqMsg.setRowLimit(this.maxRows);
// Get connection properties and set them onto request message
- copyPropertiesToRequest(reqMsg, getConnectionProperties());
+ copyPropertiesToRequest(reqMsg);
reqMsg.setExecutionId(this.currentRequestID);
Modified: trunk/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java
===================================================================
--- trunk/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -178,7 +178,7 @@
* This method parses the URL and adds properties to the the properties object. These include required and any optional
* properties specified in the URL.
* Expected URL format --
- * jdbc:metamatrix:local:VDB@<pathToConfigFile>logFile=<logFile.log>; logLevel=<logLevel>;txnAutoWrap=<?>;credentials=mycredentials;
+ * jdbc:metamatrix:local:VDB@<pathToConfigFile>logFile=<logFile.log>; logLevel=<logLevel>;credentials=mycredentials;
*
* @param The URL needed to be parsed.
* @param The properties object which is to be updated with properties in the URL.
Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDataSource.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDataSource.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDataSource.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -46,7 +46,7 @@
protected static final int STD_PORT_NUMBER = 7001;
protected static final String STD_LOG_FILE = UnitTestUtil.getTestScratchPath() + "/unitTestLogFile"; //$NON-NLS-1$
protected static final int STD_LOG_LEVEL = 2;
- protected static final String STD_TXN_AUTO_WRAP = MMDataSource.TXN_AUTO_WRAP_PESSIMISTIC;
+ protected static final String STD_TXN_WRAP = MMDataSource.TXN_WRAP_AUTO;
protected static final String STD_PARTIAL_MODE = "false"; //$NON-NLS-1$
protected static final String STD_CONFIG_FILE = UnitTestUtil.getTestDataPath() + "/bqt/bqt.properties"; //$NON-NLS-1$
protected static final String STD_ALTERNATE_SERVERS = "unitTestServerName2:7001,unitTestServerName2:7002,unitTestServerName3:7001"; //$NON-NLS-1$
@@ -70,7 +70,7 @@
dataSource.setDatabaseName(STD_DATABASE_NAME);
dataSource.setPortNumber(STD_PORT_NUMBER);
dataSource.setDataSourceName(STD_DATA_SOURCE_NAME);
- dataSource.setTransactionAutoWrap(STD_TXN_AUTO_WRAP);
+ dataSource.setTransactionAutoWrap(STD_TXN_WRAP);
dataSource.setPartialResultsMode(STD_PARTIAL_MODE);
dataSource.setSecure(true);
dataSource.setAlternateServers(STD_ALTERNATE_SERVERS);
@@ -280,7 +280,7 @@
public void testGetTransactionAutoWrap() {
final String result = dataSource.getTransactionAutoWrap();
- assertEquals(result,STD_TXN_AUTO_WRAP);
+ assertEquals(result,STD_TXN_WRAP);
}
public void testGetShowPlan() {
@@ -393,17 +393,14 @@
public void testReasonWhyInvalidTransactionAutoWrap1() {
- helpTestReasonWhyInvalid("TransactionAutoWrap", MMDataSource.TXN_AUTO_WRAP_OFF, VALID); //$NON-NLS-1$
+ helpTestReasonWhyInvalid("TransactionAutoWrap", MMDataSource.TXN_WRAP_OFF, VALID); //$NON-NLS-1$
}
public void testReasonWhyInvalidTransactionAutoWrap2() {
- helpTestReasonWhyInvalid("TransactionAutoWrap", MMDataSource.TXN_AUTO_WRAP_ON, VALID); //$NON-NLS-1$
+ helpTestReasonWhyInvalid("TransactionAutoWrap", MMDataSource.TXN_WRAP_ON, VALID); //$NON-NLS-1$
}
public void testReasonWhyInvalidTransactionAutoWrap3() {
- helpTestReasonWhyInvalid("TransactionAutoWrap", MMDataSource.TXN_AUTO_WRAP_OPTIMISTIC, VALID); //$NON-NLS-1$
+ helpTestReasonWhyInvalid("TransactionAutoWrap", MMDataSource.TXN_WRAP_AUTO, VALID); //$NON-NLS-1$
}
- public void testReasonWhyInvalidTransactionAutoWrap4() {
- helpTestReasonWhyInvalid("TransactionAutoWrap", MMDataSource.TXN_AUTO_WRAP_PESSIMISTIC, VALID); //$NON-NLS-1$
- }
public void testReasonWhyInvalidTransactionAutoWrap5() {
helpTestReasonWhyInvalid("TransactionAutoWrap", "off", INVALID); // lowercase value //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -523,11 +520,11 @@
final String vdbName = "vdbName"; //$NON-NLS-1$
final String vdbVersion = ""; //$NON-NLS-1$
final int portNumber = 7001;
- final String transactionAutoWrap = MMDataSource.TXN_AUTO_WRAP_PESSIMISTIC;
+ final String transactionAutoWrap = MMDataSource.TXN_WRAP_AUTO;
final String partialMode = "false"; //$NON-NLS-1$
final boolean secure = false;
helpTestBuildingURL(vdbName,vdbVersion,serverName,portNumber,null,transactionAutoWrap, partialMode, -1, false, secure,
- "jdbc:teiid:vdbName@mm://hostname:7001;ApplicationName=JDBC;serverURL=mm://hostname:7001;txnAutoWrap=PESSIMISTIC;partialResultsMode=false;VirtualDatabaseName=vdbName"); //$NON-NLS-1$
+ "jdbc:teiid:vdbName@mm://hostname:7001;ApplicationName=JDBC;serverURL=mm://hostname:7001;partialResultsMode=false;autoCommitTxn=AUTO;VirtualDatabaseName=vdbName"); //$NON-NLS-1$
}
public void testBuildURL3() {
@@ -535,11 +532,11 @@
final String vdbName = "vdbName"; //$NON-NLS-1$
final String vdbVersion = ""; //$NON-NLS-1$
final int portNumber = 7001;
- final String transactionAutoWrap = MMDataSource.TXN_AUTO_WRAP_PESSIMISTIC;
+ final String transactionAutoWrap = MMDataSource.TXN_WRAP_AUTO;
final String partialMode = "false"; //$NON-NLS-1$
final boolean secure = false;
helpTestBuildingURL(vdbName,vdbVersion,serverName,portNumber,null,transactionAutoWrap, partialMode, -1, true, secure,
- "jdbc:teiid:vdbName@mm://hostname:7001;ApplicationName=JDBC;serverURL=mm://hostname:7001;txnAutoWrap=PESSIMISTIC;partialResultsMode=false;VirtualDatabaseName=vdbName;sqlOptions=SHOWPLAN"); //$NON-NLS-1$
+ "jdbc:teiid:vdbName@mm://hostname:7001;ApplicationName=JDBC;serverURL=mm://hostname:7001;partialResultsMode=false;autoCommitTxn=AUTO;VirtualDatabaseName=vdbName;sqlOptions=SHOWPLAN"); //$NON-NLS-1$
}
// Test secure protocol
@@ -548,11 +545,11 @@
final String vdbName = "vdbName"; //$NON-NLS-1$
final String vdbVersion = ""; //$NON-NLS-1$
final int portNumber = 7001;
- final String transactionAutoWrap = MMDataSource.TXN_AUTO_WRAP_PESSIMISTIC;
+ final String transactionAutoWrap = MMDataSource.TXN_WRAP_AUTO;
final String partialMode = "false"; //$NON-NLS-1$
final boolean secure = true;
helpTestBuildingURL(vdbName,vdbVersion,serverName,portNumber,null,transactionAutoWrap, partialMode, -1, true, secure,
- "jdbc:teiid:vdbName@mms://hostname:7001;ApplicationName=JDBC;serverURL=mms://hostname:7001;txnAutoWrap=PESSIMISTIC;partialResultsMode=false;VirtualDatabaseName=vdbName;sqlOptions=SHOWPLAN"); //$NON-NLS-1$
+ "jdbc:teiid:vdbName@mms://hostname:7001;ApplicationName=JDBC;serverURL=mms://hostname:7001;partialResultsMode=false;autoCommitTxn=AUTO;VirtualDatabaseName=vdbName;sqlOptions=SHOWPLAN"); //$NON-NLS-1$
}
/*
@@ -566,11 +563,11 @@
final String vdbVersion = ""; //$NON-NLS-1$
final int portNumber = 7001;
final String alternateServers = "hostName:7002,hostName2:7001,hostName2:7002"; //$NON-NLS-1$
- final String transactionAutoWrap = MMDataSource.TXN_AUTO_WRAP_PESSIMISTIC;
+ final String transactionAutoWrap = MMDataSource.TXN_WRAP_AUTO;
final String partialMode = "false"; //$NON-NLS-1$
final boolean secure = false;
helpTestBuildingURL(vdbName,vdbVersion,serverName,portNumber,alternateServers,transactionAutoWrap, partialMode, -1, true, secure,
- "jdbc:teiid:vdbName@mm://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;ApplicationName=JDBC;serverURL=mm://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;txnAutoWrap=PESSIMISTIC;partialResultsMode=false;VirtualDatabaseName=vdbName;sqlOptions=SHOWPLAN"); //$NON-NLS-1$
+ "jdbc:teiid:vdbName@mm://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;ApplicationName=JDBC;serverURL=mm://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;partialResultsMode=false;autoCommitTxn=AUTO;VirtualDatabaseName=vdbName;sqlOptions=SHOWPLAN"); //$NON-NLS-1$
}
/*
@@ -584,11 +581,11 @@
final String vdbVersion = ""; //$NON-NLS-1$
final int portNumber = 7001;
final String alternateServers = "hostName:7002,hostName2:7001,hostName2:7002"; //$NON-NLS-1$
- final String transactionAutoWrap = MMDataSource.TXN_AUTO_WRAP_PESSIMISTIC;
+ final String transactionAutoWrap = MMDataSource.TXN_WRAP_AUTO;
final String partialMode = "false"; //$NON-NLS-1$
final boolean secure = true;
helpTestBuildingURL(vdbName,vdbVersion,serverName,portNumber,alternateServers,transactionAutoWrap, partialMode, -1, true, secure,
- "jdbc:teiid:vdbName@mms://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;ApplicationName=JDBC;serverURL=mms://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;txnAutoWrap=PESSIMISTIC;partialResultsMode=false;VirtualDatabaseName=vdbName;sqlOptions=SHOWPLAN"); //$NON-NLS-1$
+ "jdbc:teiid:vdbName@mms://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;ApplicationName=JDBC;serverURL=mms://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;partialResultsMode=false;autoCommitTxn=AUTO;VirtualDatabaseName=vdbName;sqlOptions=SHOWPLAN"); //$NON-NLS-1$
}
/*
@@ -603,11 +600,11 @@
final String vdbVersion = ""; //$NON-NLS-1$
final int portNumber = 7001;
final String alternateServers = "hostName:7002,hostName2,hostName2:7002"; //$NON-NLS-1$
- final String transactionAutoWrap = MMDataSource.TXN_AUTO_WRAP_PESSIMISTIC;
+ final String transactionAutoWrap = MMDataSource.TXN_WRAP_AUTO;
final String partialMode = "false"; //$NON-NLS-1$
final boolean secure = false;
helpTestBuildingURL(vdbName,vdbVersion,serverName,portNumber,alternateServers,transactionAutoWrap, partialMode, -1, true, secure,
- "jdbc:teiid:vdbName@mm://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;ApplicationName=JDBC;serverURL=mm://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;txnAutoWrap=PESSIMISTIC;partialResultsMode=false;VirtualDatabaseName=vdbName;sqlOptions=SHOWPLAN"); //$NON-NLS-1$
+ "jdbc:teiid:vdbName@mm://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;ApplicationName=JDBC;serverURL=mm://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;partialResultsMode=false;autoCommitTxn=AUTO;VirtualDatabaseName=vdbName;sqlOptions=SHOWPLAN"); //$NON-NLS-1$
}
public void testBuildURL_AdditionalProperties() {
Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDriver.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDriver.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDriver.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -54,12 +54,12 @@
assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://localhost:1234,localhost2:12342,localhost3:12343;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mms://localhost:1234;logLevel=1;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
assertTrue(!drv.acceptsURL("jdbc:metamatrix:@mm://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;txnAutoWrap=OFF;paritalResultsMode=true")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;autoCommitTxn=OFF;paritalResultsMode=true")); //$NON-NLS-1$
assertTrue(drv.acceptsURL("jdbc:metamatrix:jvdb@mms://localhost:1234")); //$NON-NLS-1$
assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://localhost:1234;version=x")); //$NON-NLS-1$
assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://localhost:1234,localhost2:12342,localhost3:12343")); //$NON-NLS-1$
assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mms://localhost:1234,localhost2:12342,localhost3:12343;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mms://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;txnAutoWrap=OFF;paritalResultsMode=true")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mms://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;autoCommitTxn=OFF;paritalResultsMode=true")); //$NON-NLS-1$
assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://127.0.0.1:1234;logLevel=2")); //$NON-NLS-1$
assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mms://127.0.0.1:1234")); //$NON-NLS-1$
assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://127.0.0.1:1234,localhost.mydomain.com:63636;logLevel=2")); //$NON-NLS-1$
@@ -79,7 +79,7 @@
assertTrue(!drv.acceptsURL("jdbc:metamatrix:@localhost:1234,localhost2:12342,localhost3:12343;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
assertTrue(!drv.acceptsURL("jdbc:metamatrix:@localhost:1234;logLevel=1;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
assertTrue(!drv.acceptsURL("jdbc:metamatrix:@localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
- assertTrue(!drv.acceptsURL("jdbc:metamatrix:@localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;txnAutoWrap=OFF;paritalResultsMode=true")); //$NON-NLS-1$
+ assertTrue(!drv.acceptsURL("jdbc:metamatrix:@localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;autoCommitTxn=OFF;paritalResultsMode=true")); //$NON-NLS-1$
assertTrue(!drv.acceptsURL("jdbc:metamatrix:@localhost:1234;stickyConnections=false;socketsPerVM=4")); //$NON-NLS-1$
assertTrue(!drv.acceptsURL("jdbc:metamatrix:vdb@mm://my_host.mydomain.com:53535,127.0.0.1:1234")); //$NON-NLS-1$
}
@@ -114,7 +114,7 @@
public void testParseURL3() throws SQLException{
Properties p = new Properties();
- MMDriver.getInstance().parseURL("jdbc:metamatrix:BQT@mm://slwxp157:1234,slntmm01:43401,sluxmm09:43302;version=4;txnAutoWrap=ON;partialResultsMode=YES;ApplicationName=Client", p); //$NON-NLS-1$
+ MMDriver.getInstance().parseURL("jdbc:metamatrix:BQT@mm://slwxp157:1234,slntmm01:43401,sluxmm09:43302;version=4;autoCommitTxn=ON;partialResultsMode=YES;ApplicationName=Client", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("4")); //$NON-NLS-1$
assertTrue(p.getProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP).equals("ON")); //$NON-NLS-1$
Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMStatement.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMStatement.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMStatement.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -27,6 +27,7 @@
import java.sql.ResultSet;
import java.util.Arrays;
import java.util.List;
+import java.util.Properties;
import org.junit.Test;
import org.mockito.Mockito;
@@ -59,4 +60,13 @@
assertTrue(Arrays.equals(new int[] {1, 2}, statement.executeBatch()));
}
+ @Test public void testSetStatement() throws Exception {
+ MMConnection conn = Mockito.mock(MMConnection.class);
+ Properties p = new Properties();
+ Mockito.stub(conn.getConnectionProperties()).toReturn(p);
+ MMStatement statement = new MMStatement(conn, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
+ assertFalse(statement.execute("set foo = bar")); //$NON-NLS-1$
+ assertEquals("bar", p.get("foo")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
}
Modified: trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java
===================================================================
--- trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -48,22 +48,22 @@
// // Windows Path
assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@c:\\metamatrix\\dqp\\dqp.properties")); //$NON-NLS-1$
assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@c:\\metamatrix\\dqp\\dqp.properties;version=1")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@c:\\metamatrix\\dqp\\dqp.properties;version=1;txnAutoWrap=ON;partialResultsMode=YES")); //$NON-NLS-1$
+ assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@c:\\metamatrix\\dqp\\dqp.properties;version=1;autoCommitTxn=ON;partialResultsMode=YES")); //$NON-NLS-1$
// Alternative windows path
assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@c:/metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@c:/metamatrix/dqp/dqp.properties;version=1")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@c:/metamatrix/dqp/dqp.properties;version=1;txnAutoWrap=ON;partialResultsMode=YES")); //$NON-NLS-1$
+ assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@c:/metamatrix/dqp/dqp.properties;version=1;autoCommitTxn=ON;partialResultsMode=YES")); //$NON-NLS-1$
// Abosolute path (Unix or windows)
assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=1")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=1;txnAutoWrap=ON;partialResultsMode=YES")); //$NON-NLS-1$
+ assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=1;autoCommitTxn=ON;partialResultsMode=YES")); //$NON-NLS-1$
// relative path
assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@../../metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@../../metamatrix/dqp/dqp.properties;version=1")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@../../metamatrix/dqp/dqp.properties;version=1;txnAutoWrap=ON;partialResultsMode=YES")); //$NON-NLS-1$
+ assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@../../metamatrix/dqp/dqp.properties;version=1;autoCommitTxn=ON;partialResultsMode=YES")); //$NON-NLS-1$
// File URL should be supported (not sure)
assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@file:///c:/metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
@@ -103,7 +103,7 @@
@Test public void testParseURL3() throws SQLException{
Properties p = new Properties();
- org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=4;txnAutoWrap=ON;partialResultsMode=YES;", p); //$NON-NLS-1$
+ org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=4;autoCommitTxn=ON;partialResultsMode=YES;", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("4")); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VERSION).equals("4")); //$NON-NLS-1$
Modified: trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestSocketProfile.java
===================================================================
--- trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestSocketProfile.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestSocketProfile.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -48,12 +48,12 @@
assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mm://localhost:1234,localhost2:12342,localhost3:12343;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mms://localhost:1234;logLevel=1;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:@mm://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
- assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mm://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;txnAutoWrap=OFF;paritalResultsMode=true")); //$NON-NLS-1$
+ assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mm://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;autoCommitTxn=OFF;paritalResultsMode=true")); //$NON-NLS-1$
assertTrue(SocketProfile.acceptsURL("jdbc:teiid:jvdb@mms://localhost:1234")); //$NON-NLS-1$
assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mm://localhost:1234;version=x")); //$NON-NLS-1$
assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mm://localhost:1234,localhost2:12342,localhost3:12343")); //$NON-NLS-1$
assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mms://localhost:1234,localhost2:12342,localhost3:12343;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
- assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mms://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;txnAutoWrap=OFF;paritalResultsMode=true")); //$NON-NLS-1$
+ assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mms://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;autoCommitTxn=OFF;paritalResultsMode=true")); //$NON-NLS-1$
assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mm://127.0.0.1:1234;logLevel=2")); //$NON-NLS-1$
assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mms://127.0.0.1:1234")); //$NON-NLS-1$
assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mm://127.0.0.1:1234,localhost.mydomain.com:63636;logLevel=2")); //$NON-NLS-1$
@@ -76,7 +76,7 @@
assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:@localhost:1234,localhost2:12342,localhost3:12343;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:@localhost:1234;logLevel=1;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:@localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
- assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:@localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;txnAutoWrap=OFF;paritalResultsMode=true")); //$NON-NLS-1$
+ assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:@localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;autoCommitTxn=OFF;paritalResultsMode=true")); //$NON-NLS-1$
assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:@localhost:1234;stickyConnections=false;socketsPerVM=4")); //$NON-NLS-1$
assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:vdb@mm://my_host.mydomain.com:53535,127.0.0.1:1234")); //$NON-NLS-1$
}
@@ -110,7 +110,7 @@
@Test public void testParseURL3() throws SQLException{
Properties p = new Properties();
- SocketProfile.parseURL("jdbc:teiid:BQT@mm://slwxp157:1234,slntmm01:43401,sluxmm09:43302;version=4;txnAutoWrap=ON;partialResultsMode=YES;ApplicationName=Client", p); //$NON-NLS-1$
+ SocketProfile.parseURL("jdbc:teiid:BQT@mm://slwxp157:1234,slntmm01:43401,sluxmm09:43302;version=4;autoCommitTxn=ON;partialResultsMode=YES;ApplicationName=Client", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("4")); //$NON-NLS-1$
assertTrue(p.getProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP).equals("ON")); //$NON-NLS-1$
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/transaction_support.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/transaction_support.xml 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/transaction_support.xml 2009-12-14 18:48:26 UTC (rev 1662)
@@ -26,7 +26,7 @@
<entry>
Treats the user command as if all source commands are executed
within the scope of the same transaction. The
- <link linkend="autowrap">AutoWrap</link>
+ <link linkend="autowrap">AutoCommitTxn</link>
execution property controls the behavior of command level
transactions.
</entry>
@@ -45,13 +45,13 @@
</tgroup>
</table>
<sect1 id="autowrap">
- <title>AutoWrap Execution Property</title>
+ <title>AutoCommitTxn Execution Property</title>
<para>Since user level commands may execute multiple source
- commands, users can specify the AutoWrap execution property to
+ commands, users can specify the AutoCommitTxn execution property to
control the transactional behavior of a user command when not in a
local or global transaction.</para>
<table>
- <title>AutoWrap Settings</title>
+ <title>AutoCommitTxn Settings</title>
<tgroup cols="2">
<colspec colwidth="1*" />
<colspec colwidth="3*" />
@@ -74,19 +74,9 @@
safest, but may be burdonsome on performance.</entry>
</row>
<row>
- <entry>OPTIMISTIC</entry>
+ <entry>AUTO</entry>
<entry>
- <emphasis>This is the default setting.</emphasis>
- Will not automatically wrap a command in a transaction, instead
- throw an exception if the command executed is
- <link linkend="updating_model_count">transactionally unsafe.</link>
- to execute outside of a transaction.
- </entry>
- </row>
- <row>
- <entry>PESSIMISTIC</entry>
- <entry>
- Will automatically wrap commands in a transaction, but only if
+ This is the default setting. Will automatically wrap commands in a transaction, but only if
the command seems to be
<link linkend="updating_model_count">transactionally unsafe.</link>
</entry>
Modified: trunk/engine/src/main/java/com/metamatrix/query/parser/QueryParser.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/parser/QueryParser.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/engine/src/main/java/com/metamatrix/query/parser/QueryParser.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -32,9 +32,6 @@
import com.metamatrix.query.sql.lang.Criteria;
import com.metamatrix.query.sql.lang.Option;
import com.metamatrix.query.sql.lang.XQuery;
-import com.metamatrix.query.sql.proc.Block;
-import com.metamatrix.query.sql.proc.CriteriaSelector;
-import com.metamatrix.query.sql.proc.Statement;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.xquery.XQueryExpression;
import com.metamatrix.query.xquery.saxon.SaxonXQueryExpression;
@@ -44,9 +41,6 @@
* QueryParser can be reused but is NOT thread-safe as the parser uses an
* input stream. Putting multiple queries into the same stream will result
* in unpredictable and most likely incorrect behavior.</p>
- *
- * <p>In the future this class may hide a single- or multi-thread cache
- * of parsed queries. </p>
*/
public class QueryParser {
@@ -66,7 +60,7 @@
private static final String XQUERY_DECLARE = "declare"; //$NON-NLS-1$
private static final String XML_OPEN_BRACKET = "<"; //$NON-NLS-1$
- private static final String BOGUS_SELECT = "select x "; //$NON-NLS-1$
+ private static final String XML_CLOSE_BRACKET = ">"; //$NON-NLS-1$
private SQLParser parser;
@@ -119,37 +113,39 @@
throw new QueryParserException(QueryPlugin.Util.getString("QueryParser.emptysql")); //$NON-NLS-1$
}
- // For XQueries
- int type = getCommandType(sql);
- if (type == Command.TYPE_XQUERY || type == Command.TYPE_UNKNOWN){
+ QueryParserException qpe = null;
+ try {
+ Command result = parseCommandWithParser(sql, parseInfo);
+ return result;
+ } catch (QueryParserException e) {
+ qpe = e;
+ }
+
+ try {
+ // Check for OPTION
+ Option option = null;
+ int closeBracket = sql.lastIndexOf(XML_CLOSE_BRACKET);
+ int optionIndex = sql.toUpperCase().lastIndexOf(ReservedWords.OPTION);
+ if (optionIndex != -1 && optionIndex > closeBracket){
+ String optionSQL = sql.substring(optionIndex);
+ option = getOption(optionSQL, parseInfo);
+ sql = sql.substring(0, optionIndex-1);
+ }
- try {
-
- // Check for OPTION
- Option option = null;
- int optionIndex = sql.toUpperCase().lastIndexOf(ReservedWords.OPTION);
- if (optionIndex != -1){
- String optionSQL = sql.substring(optionIndex);
- option = getOption(optionSQL);
- sql = sql.substring(0, optionIndex-1);
- }
-
- XQueryExpression expr = new SaxonXQueryExpression();
- expr.compileXQuery(sql);
- XQuery xquery = new XQuery(sql, expr);
- if (option != null){
- xquery.setOption(option);
- }
- return xquery;
- } catch (MetaMatrixProcessingException e) {
- if (type == Command.TYPE_XQUERY){
- throw new QueryParserException(QueryPlugin.Util.getString("QueryParser.xqueryCompilation", e.getMessage())); //$NON-NLS-1$
- } // else let unknown query type fall through to code below for better error handling
+ XQueryExpression expr = new SaxonXQueryExpression();
+ expr.compileXQuery(sql);
+ XQuery xquery = new XQuery(sql, expr);
+ if (option != null){
+ xquery.setOption(option);
}
+ return xquery;
+ } catch (MetaMatrixProcessingException e) {
+ if(sql.startsWith(XML_OPEN_BRACKET) || sql.startsWith(XQUERY_DECLARE)) {
+ throw new QueryParserException(e, QueryPlugin.Util.getString("QueryParser.xqueryCompilation")); //$NON-NLS-1$
+ }
}
- Command result = parseCommandWithParser(sql, parseInfo);
- return result;
+ throw qpe;
}
/**
@@ -157,10 +153,18 @@
* @param optionSQL option SQL
* @return Option object
*/
- private Option getOption(String optionSQL) throws QueryParserException {
- String sql = BOGUS_SELECT + optionSQL;
- Command command = parseCommandWithParser(sql, new ParseInfo());
- return command.getOption();
+ private Option getOption(String optionSQL, ParseInfo parseInfo) throws QueryParserException {
+ Option result = null;
+ try{
+ result = getSqlParser(optionSQL).option(parseInfo);
+
+ } catch(ParseException pe) {
+ throw convertParserException(pe);
+
+ } catch(TokenMgrError tme) {
+ handleTokenMgrError(tme);
+ }
+ return result;
}
/**
@@ -184,35 +188,6 @@
}
/**
- * Takes a SQL string representing an SQL statement
- * and returns the procedure object representation.
- * @param stmt SQL statement string
- * @return Statement Procedure object representation
- * @throws QueryParserException if parsing fails
- * @throws IllegalArgumentException if stmt is null
- */
- Statement parseStatement(String stmt) throws QueryParserException {
- if(stmt == null) {
- throw new IllegalArgumentException(QueryPlugin.Util.getString("QueryParser.nullSqlCrit")); //$NON-NLS-1$
- }
-
- ParseInfo dummyInfo = new ParseInfo();
-
- Statement result = null;
- try{
- result = getSqlParser(stmt).statement(dummyInfo);
-
- } catch(ParseException pe) {
- throw convertParserException(pe);
-
- } catch(TokenMgrError tme) {
- handleTokenMgrError(tme);
- }
- return result;
- }
-
-
- /**
* Takes a SQL string representing an SQL criteria (i.e. just the WHERE
* clause) and returns the object representation.
* @param sql SQL criteria (WHERE clause) string
@@ -240,65 +215,11 @@
return result;
}
- /**
- * Takes a SQL string representing a block
- * and returns the object representation.
- * @param block Block string
- * @return Block Block object representation
- * @throws QueryParserException if parsing fails
- * @throws IllegalArgumentException if sql is null
- */
- Block parseBlock(String block) throws QueryParserException {
- if(block == null) {
- throw new IllegalArgumentException(QueryPlugin.Util.getString("QueryParser.nullBlock")); //$NON-NLS-1$
- }
-
- ParseInfo dummyInfo = new ParseInfo();
-
- Block result = null;
- try{
- result = getSqlParser(block).block(dummyInfo);
-
- } catch(ParseException pe) {
- throw convertParserException(pe);
-
- } catch(TokenMgrError tme) {
- handleTokenMgrError(tme);
- }
- return result;
- }
-
private QueryParserException convertParserException(ParseException pe) {
return new QueryParserException(QueryPlugin.Util.getString("QueryParser.parsingError", pe.getMessage())); //$NON-NLS-1$
}
/**
- * Takes a SQL string representing a criteria selector
- * and returns the object representation.
- * @param selector criteria selector string
- * @return CriteriaSelector CriteriaSelector object representation
- * @throws QueryParserException if parsing fails
- * @throws IllegalArgumentException if sql is null
- */
- CriteriaSelector parseCriteriaSelector(String selector) throws QueryParserException {
- if(selector == null) {
- throw new IllegalArgumentException(QueryPlugin.Util.getString("QueryParser.nullSqlCrit")); //$NON-NLS-1$
- }
-
- CriteriaSelector result = null;
- try{
- result = getSqlParser(selector).criteriaSelector();
-
- } catch(ParseException pe) {
- throw convertParserException(pe);
-
- } catch(TokenMgrError tme) {
- handleTokenMgrError(tme);
- }
- return result;
- }
-
- /**
* Takes a SQL string representing an SQL expression
* and returns the object representation.
* @param sql SQL expression string
@@ -363,54 +284,4 @@
throw new QueryParserException(QueryPlugin.Util.getString("QueryParser.parsingError", tme.getMessage())); //$NON-NLS-1$
}
- /**
- * Takes a SQL string and determines the command type, as defined in the constants
- * of {@link com.metamatrix.query.sql.lang.Command}.
- * @param sql SQL string
- * @return Command type code, as defined in {@link com.metamatrix.query.sql.lang.Command}.
- * Note: not all XQuery queries will necessarily be detected - if type UNKNOWN is indicated
- * it's possible it is an XQuery.
- * @throws IllegalArgumentException if sql is null
- */
- public static int getCommandType(String sql) {
- if(sql == null) {
- throw new IllegalArgumentException(QueryPlugin.Util.getString("QueryParser.emptysql")); //$NON-NLS-1$
- }
-
- // Shortcut for most XQuery commands
- if(sql.startsWith(XML_OPEN_BRACKET) || sql.startsWith(XQUERY_DECLARE)) {
- return Command.TYPE_XQUERY;
- }
-
- int startCommand = -1;
- for(int index = 0; index < sql.length(); index++) {
- char c = sql.charAt(index);
- if(Character.isLetter(c) || c == '{') {
- startCommand = index;
- break;
- }
- }
-
- if(startCommand == -1) {
- return Command.TYPE_UNKNOWN;
- }
-
- String commandWord = sql.substring(startCommand, Math.min(startCommand+6, sql.length())).toUpperCase();
- if(commandWord.startsWith(ReservedWords.SELECT)) {
- return Command.TYPE_QUERY;
- } else if(commandWord.startsWith(ReservedWords.INSERT)) {
- return Command.TYPE_INSERT;
- } else if(commandWord.startsWith(ReservedWords.UPDATE)) {
- return Command.TYPE_UPDATE;
- } else if(commandWord.startsWith(ReservedWords.DELETE)) {
- return Command.TYPE_DELETE;
- } else if(commandWord.startsWith(ReservedWords.EXEC) || commandWord.startsWith("{")) { //$NON-NLS-1$
- return Command.TYPE_STORED_PROCEDURE;
- } else if(commandWord.startsWith(ReservedWords.CREATE)) {
- return Command.TYPE_UPDATE_PROCEDURE;
- } else {
- return Command.TYPE_UNKNOWN;
- }
- }
-
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecDynamicSqlInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecDynamicSqlInstruction.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecDynamicSqlInstruction.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -310,20 +310,6 @@
}
}
- // validate the updating model count if transaction is optimistic
- // Error if orig = 0 and command > 0 OR if orig = 1 and command <> 1
- if (procEnv.getContext().isOptimisticTransaction()) {
- final int origModelCount = dynamicCommand.getUpdatingModelCount();
- final int newModelCount = command.updatingModelCount(metadata);
- if ((origModelCount == 0 || origModelCount == 1)
- && newModelCount > origModelCount) {
- Object[] params = new Object[] { new Integer(newModelCount),
- new Integer(origModelCount) };
- throw new QueryProcessingException(QueryExecPlugin.Util
- .getString("ExecDynamicSqlInstruction.1", params)); //$NON-NLS-1$
- }
- }
-
// do a recursion check
// Add group to recursion stack
CommandContext context = procEnv.getContext();
Modified: trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -82,8 +82,6 @@
private Stack<String> recursionStack = null;
- private boolean optimisticTransaction = false;
-
private SecurityFunctionEvaluator securityFunctionEvaluator;
private Object tempTableStore;
@@ -148,7 +146,6 @@
if (context.recursionStack != null) {
this.recursionStack = (Stack)context.recursionStack.clone();
}
- setOptimisticTransaction(context.isOptimisticTransaction());
this.setSecurityFunctionEvaluator(context.getSecurityFunctionEvaluator());
this.planToProcessConverter = context.planToProcessConverter;
this.queryProcessorFactory = context.queryProcessorFactory;
@@ -373,20 +370,6 @@
}
/**
- * @param optimisticTransaction The optimisticTransaction to set.
- */
- public void setOptimisticTransaction(boolean optimisticTransaction) {
- this.optimisticTransaction = optimisticTransaction;
- }
-
- /**
- * @return Returns the optimisticTransaction.
- */
- public boolean isOptimisticTransaction() {
- return optimisticTransaction;
- }
-
- /**
* @return Returns the securityFunctionEvaluator.
*/
public SecurityFunctionEvaluator getSecurityFunctionEvaluator() {
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -359,21 +359,15 @@
boolean startAutoWrapTxn = false;
- if(ExecutionProperties.AUTO_WRAP_ON.equals(requestMsg.getTxnAutoWrapMode())){
+ if(ExecutionProperties.TXN_WRAP_ON.equals(requestMsg.getTxnAutoWrapMode())){
startAutoWrapTxn = true;
} else if ( processingCommand.updatingModelCount(metadata) > 1) {
- if (ExecutionProperties.AUTO_WRAP_OPTIMISTIC.equals(requestMsg.getTxnAutoWrapMode())){
- String msg = DQPPlugin.Util.getString("Request.txn_needed_wrong_mode", requestId); //$NON-NLS-1$
- throw new MetaMatrixComponentException(msg);
- } else if (ExecutionProperties.AUTO_WRAP_PESSIMISTIC.equals(requestMsg.getTxnAutoWrapMode())){
+ if (ExecutionProperties.TXN_WRAP_AUTO.equals(requestMsg.getTxnAutoWrapMode())){
startAutoWrapTxn = true;
- } else if (ExecutionProperties.AUTO_WRAP_OFF.equals(requestMsg.getTxnAutoWrapMode())) {
+ } else if (ExecutionProperties.TXN_WRAP_OFF.equals(requestMsg.getTxnAutoWrapMode())) {
LogManager.logDetail(LogConstants.CTX_DQP, DQPPlugin.Util.getString("Request.potentially_unsafe")); //$NON-NLS-1$
}
}
- if(ExecutionProperties.AUTO_WRAP_OPTIMISTIC.equals(requestMsg.getTxnAutoWrapMode())){
- this.context.setOptimisticTransaction(true);
- }
if (startAutoWrapTxn) {
if (transactionService == null) {
@@ -542,7 +536,7 @@
}
}
- private void createAnalysisRecord(Command command) throws QueryValidatorException{
+ private void createAnalysisRecord(Command command) {
Option option = command.getOption();
boolean getPlan = requestMsg.getShowPlan();
boolean debug = false;
@@ -551,11 +545,6 @@
debug = option.getDebug();
}
- if (getPlan && !requestMsg.isQueryPlanAllowed()){
- final String message = DQPPlugin.Util.getString("Request.query_plan_not_allowed"); //$NON-NLS-1$
- throw new QueryValidatorException(message);
- }
-
this.analysisRecord = new AnalysisRecord(getPlan, getPlan, debug);
}
Modified: trunk/engine/src/main/resources/com/metamatrix/dqp/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/com/metamatrix/dqp/i18n.properties 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/engine/src/main/resources/com/metamatrix/dqp/i18n.properties 2009-12-14 18:48:26 UTC (rev 1662)
@@ -371,9 +371,8 @@
Request.txn.info.resume=Resumed transaction "{0}".
Request.txn.info.export=Exported transaction "{0}".
Request.txn.info.suspend=Suspended transaction "{0}".
-Request.txn_needed_wrong_mode=Detected request "{0}" with multiple updates when using txnAutoWrap=OPTIMISTIC. If you are using MetaMatrix Enterprise, you can set txnAutoWrap=OFF to avoid using a transaction or txnAutoWrap=PESSIMISTIC to automatically create a transaction when needed. If you are not using MetaMatrix Enterprise, no transaction manager is provided and transactions are not supported. In that case, you can set txnAutoWrap=OFF to allow transaction methods to be called and ignored without actual transaction support. WARNING: Setting txnAutowrap=OFF and using transaction methods is risky because transactions will not be executed atomically and rollback will not occur!
Request.transaction_not_supported=Autowrap transaction required, but transaction support is disabled
-Request.potentially_unsafe=The request is modifying more than 1 model without any containing transaction (txnAutoWrap = OFF). This is potentially unsafe as the updates cannot be rolled back as a single unit.
+Request.potentially_unsafe=The request is modifying more than 1 model without any containing transaction (autoCommitTxn = OFF). This is potentially unsafe as the updates cannot be rolled back as a single unit.
Request.no_result_set=Statement does not return a result set.
Request.result_set=Statement returns a result set, not an update count.
Request.wsdl_user_not_authorized=The anonymous user is not authorized for this action.
@@ -405,28 +404,9 @@
ResultBatch.update_count_unavailable=Unable to retrieve an update count from this batch.
ServerConnectionInfo.invalid_context=Invalid portable context string. Unable to reinstantiate a ServerConnectionInfo from the string :{0}
ServerConnectionInfo.invalid_url=The url "{0}" is invalid and could not be parsed. The url should be of the form mm[s]://host[,host2,host3...]:port[,port2,port3...]
-ServerFacadeImpl.invalid_txnautowrap=Invalid transaction autowrap mode "{0}"
-ServerFacadeImpl.invalid_beginRow=Invalid beginRow {0}: beginRow must be >= 1
-ServerFacadeImpl.invalid_endRow=Invalid maxEndRow {0}: beginRow must be <= maxEndRow
-ServerFacadeImpl.invalid_waitTime=Invalid waitTime {0}: waitTime must be >= 0
-ServerFacadeImpl.invalid_connInfo=The server facade expects an instance of ServerConnectionInfo.
-ServerFacadeImpl.null_requestInfo=The request info must not be null.
-ServerFacadeImpl.invalid_requestInfo=The server facade expects an instance of ServerRequest.
-ServerFacadeImpl.invalid_cursorType=The cursor type must be one of {ResultSet.TYPE_FORWARD_ONLY,ResultSet.TYPE_SCROLL_INSENSITIVE}.
-ServerFacadeImpl.invalid_fetchSize=The fetch size must be >= 0
-ServerFacadeImpl.invalid_requestType=The request type must be one of {RequestInfo.REQUEST_TYPE_STATEMENT,RequestInfo.REQUEST_TYPE_PREPARED_STATEMENT,RequestInfo.REQUEST_TYPE_CALLABLE_STATEMENT}.
-ServerFacadeImpl.invalid_sql=The SQL command must not be null.
-ServerFacadeImpl.invalid_txnAutowrap=The transaction autowrap mode must be one of {RequestInfo.AUTOWRAP_OFF,RequestInfo.AUTOWRAP_ON,RequestInfo.AUTOWRAP_OPTIMISTIC,RequestInfo.AUTOWRAP_PESSIMISTIC}.
ServerSessionContext.invalid_context=Invalid portable context string. Unable to reinstantiate a server session context from the string :{0}
ServerSessionContext.null_context=The portable session context should not be null.
ServerConnectionInfo.invalid_encoding=Invalid encoded object within the portable string. Unable to reinstantiate an object from the encoded string :{0}
-ServerFacadeImpl.timeout=Timed out while waiting for a response.
-ServerFacadeImpl.null_connInfo=The connection info must not be null.
-ServerFacadeImpl.null_URL=The server URL must not be null.
-ServerFacadeImpl.null_user=The user name must not be null.
-ServerFacadeImpl.null_pwd=The password must not be null.
-ServerFacadeImpl.null_vdb=The VDB name must not be null.
-ServerFacadeImpl.updates_not_supported=The server facade does not support metadata requests for INSERT, UPDATE, DELETE, or SELECT...INTO statements.
ResultBatch.not_last_batch=This method can only be called on the last batch of results.
ResultBatch.not_out_param=The parameter at index {0} must be of type RETURN, OUT, or INOUT
CacheResults.Trying_to_cache_unexpected_results=Trying to cache unexpected results. Expected request ID "{0}"; Got request ID "{1}"
Deleted: trunk/engine/src/test/java/com/metamatrix/query/parser/TestParseCommandType.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/parser/TestParseCommandType.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/engine/src/test/java/com/metamatrix/query/parser/TestParseCommandType.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -1,92 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.parser;
-
-import com.metamatrix.query.sql.lang.*;
-import junit.framework.*;
-
-public class TestParseCommandType extends TestCase {
-
- // ################################## FRAMEWORK ################################
-
- public TestParseCommandType(String name) {
- super(name);
- }
-
- // ################################## TEST HELPERS ################################
-
- private void helpTest(String sql, int expectedType) {
- int actualType = QueryParser.getCommandType(sql);
- assertEquals("Did not get expected type", expectedType, actualType); //$NON-NLS-1$
- }
-
- // ################################## ACTUAL TESTS ################################
-
- public void testQuery1() {
- helpTest("SELECT a FROM g", Command.TYPE_QUERY); //$NON-NLS-1$
- }
-
- public void testQuery2() {
- helpTest("select a FROM g", Command.TYPE_QUERY); //$NON-NLS-1$
- }
-
- public void testQuery3() {
- helpTest("select", Command.TYPE_QUERY); //$NON-NLS-1$
- }
-
- public void testSetQuery1() {
- helpTest("SELECT a FROM g UNION SELECT b from z", Command.TYPE_QUERY); //$NON-NLS-1$
- }
-
- public void testSetQuery2() {
- helpTest("(Select a FROM g UNION SELECT b from z) union select c from r order by s", Command.TYPE_QUERY); //$NON-NLS-1$
- }
-
- public void testInsert() {
- helpTest("insert g (b) values (1)", Command.TYPE_INSERT); //$NON-NLS-1$
- }
-
- public void testUpdate() {
- helpTest("update g set b=1", Command.TYPE_UPDATE); //$NON-NLS-1$
- }
-
- public void testDelete() {
- helpTest("delete from g where x=1", Command.TYPE_DELETE); //$NON-NLS-1$
- }
-
- public void testUnknown1() {
- helpTest("", Command.TYPE_UNKNOWN); //$NON-NLS-1$
- }
-
- public void testUnknown2() {
- helpTest("abc select", Command.TYPE_UNKNOWN); //$NON-NLS-1$
- }
-
- public void testUnknown3() {
- helpTest("selec", Command.TYPE_UNKNOWN); //$NON-NLS-1$
- }
-
- public void testUnknown4() {
- helpTest("selec ", Command.TYPE_UNKNOWN); //$NON-NLS-1$
- }
-}
Modified: trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -24,6 +24,7 @@
import static org.junit.Assert.*;
+import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.util.ArrayList;
@@ -139,66 +140,30 @@
}
}
- private void helpBlockTest(String block, String expectedString, Block expectedBlock) {
- Block actualBlock = null;
- String actualString = null;
- try {
- actualBlock = QueryParser.getQueryParser().parseBlock(block);
- actualString = actualBlock.toString();
-
- } catch(Throwable e) {
- fail("Exception during parsing (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
+ private void helpBlockTest(String block, String expectedString, Block expectedBlock) throws ParseException {
+ Block actualBlock = new SQLParser(new StringReader(block)).block(new ParseInfo());
+ String actualString = actualBlock.toString();
assertEquals("Parse string does not match: ", expectedString, actualString); //$NON-NLS-1$
assertEquals("Block does not match: ", expectedBlock, actualBlock); //$NON-NLS-1$
}
- private void helpCriteriaSelectorTest(String selector, String expectedString, CriteriaSelector expectedSelector) {
-
- CriteriaSelector actualSelector = null;
- String actualString = null;
- try {
- actualSelector = QueryParser.getQueryParser().parseCriteriaSelector(selector);
- actualString = actualSelector.toString();
-
- } catch(Throwable e) {
- fail("Exception during parsing (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
+ private void helpCriteriaSelectorTest(String selector, String expectedString, CriteriaSelector expectedSelector) throws ParseException {
+ CriteriaSelector actualSelector = new SQLParser(new StringReader(selector)).criteriaSelector();
+ String actualString = actualSelector.toString();
assertEquals("Parse string does not match: ", expectedString, actualString); //$NON-NLS-1$
assertEquals("CriteriaSelector does not match: ", expectedSelector, actualSelector); //$NON-NLS-1$
}
- private void helpCriteriaTest(String crit, String expectedString, Criteria expectedCrit) {
-
- Criteria actualCrit = null;
- String actualString = null;
- try {
- //actualCrit = QueryParser.getQueryParser().parsePredicateCriteria(crit);
- actualCrit = QueryParser.getQueryParser().parseCriteria(crit);
- actualString = actualCrit.toString();
-
- } catch(Throwable e) {
- fail("Exception during parsing (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
+ private void helpCriteriaTest(String crit, String expectedString, Criteria expectedCrit) throws QueryParserException {
+ Criteria actualCrit = QueryParser.getQueryParser().parseCriteria(crit);
+ String actualString = actualCrit.toString();
assertEquals("Parse string does not match: ", expectedString, actualString); //$NON-NLS-1$
assertEquals("Criteria does not match: ", expectedCrit, actualCrit); //$NON-NLS-1$
-
}
- private void helpStmtTest(String stmt, String expectedString, Statement expectedStmt) {
- Statement actualStmt = null;
- String actualString = null;
- try {
- actualStmt = QueryParser.getQueryParser().parseStatement(stmt);
- actualString = actualStmt.toString();
-
- } catch(Throwable e) {
- fail("Exception during parsing (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
+ private void helpStmtTest(String stmt, String expectedString, Statement expectedStmt) throws ParseException {
+ Statement actualStmt = new SQLParser(new StringReader(stmt)).statement(new ParseInfo());
+ String actualString = actualStmt.toString();
assertEquals("Parse string does not match: ", expectedString, actualString); //$NON-NLS-1$
assertEquals("Language objects do not match: ", expectedStmt, actualStmt); //$NON-NLS-1$
}
@@ -3184,10 +3149,8 @@
/**
* Try nesting subquery in double parentheses - parsing fails. 'exec' is not handled as
* robustly as other types of commands that can appear in a from clause subquery.
- *
- * deferred, not important enough
*/
- public void DEFERRED_testStoredQuerySubqueryMultipleParens(){
+ public void testStoredQuerySubqueryMultipleParens(){
StoredProcedure storedQuery = new StoredProcedure();
storedQuery.setProcedureName("proc1"); //$NON-NLS-1$
SPParameter parameter = new SPParameter(1, new Constant("param1")); //$NON-NLS-1$
@@ -3205,14 +3168,14 @@
helpTest("SELECT X.A FROM ((exec proc1('param1'))) AS X", "SELECT X.A FROM (EXEC proc1('param1')) AS X", query); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testErrorStatement(){
+ @Test public void testErrorStatement() throws Exception {
RaiseErrorStatement errStmt = new RaiseErrorStatement(new Constant("Test only")); //$NON-NLS-1$
helpStmtTest("ERROR 'Test only';", "ERROR 'Test only';", //$NON-NLS-1$ //$NON-NLS-2$
errStmt);
}
- @Test public void testIfStatement(){
+ @Test public void testIfStatement() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
String shortType = new String("short"); //$NON-NLS-1$
Statement ifStmt = new DeclareStatement(a, shortType);
@@ -3264,7 +3227,7 @@
stmt);
}*/
- @Test public void testCriteriaSelector0(){
+ @Test public void testCriteriaSelector0() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3274,7 +3237,7 @@
helpCriteriaSelectorTest("IS NULL CRITERIA ON (a)", "IS NULL CRITERIA ON (a)", critSelector); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testCriteriaSelector1(){
+ @Test public void testCriteriaSelector1() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3284,7 +3247,7 @@
helpCriteriaSelectorTest("= CRITERIA ON (a)", "= CRITERIA ON (a)", critSelector); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testCriteriaSelector2(){
+ @Test public void testCriteriaSelector2() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3294,7 +3257,7 @@
helpCriteriaSelectorTest("<> CRITERIA ON (a)", "<> CRITERIA ON (a)", critSelector); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testCriteriaSelector3(){
+ @Test public void testCriteriaSelector3() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3304,7 +3267,7 @@
helpCriteriaSelectorTest("< CRITERIA ON (a)", "< CRITERIA ON (a)", critSelector); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testCriteriaSelector4(){
+ @Test public void testCriteriaSelector4() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3314,7 +3277,7 @@
helpCriteriaSelectorTest("> CRITERIA ON (a)", "> CRITERIA ON (a)", critSelector); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testCriteriaSelector5(){
+ @Test public void testCriteriaSelector5() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3324,7 +3287,7 @@
helpCriteriaSelectorTest(">= CRITERIA ON (a)", ">= CRITERIA ON (a)", critSelector); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testCriteriaSelector6(){
+ @Test public void testCriteriaSelector6() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3334,7 +3297,7 @@
helpCriteriaSelectorTest("<= CRITERIA ON (a)", "<= CRITERIA ON (a)", critSelector); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testCriteriaSelector7(){
+ @Test public void testCriteriaSelector7() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3345,7 +3308,7 @@
}
- @Test public void testCriteriaSelector8(){
+ @Test public void testCriteriaSelector8() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3355,7 +3318,7 @@
helpCriteriaSelectorTest("IN CRITERIA ON (a)", "IN CRITERIA ON (a)", critSelector); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testCriteriaSelector9(){
+ @Test public void testCriteriaSelector9() throws Exception {
//ElementSymbol a = new ElementSymbol("a");
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3365,7 +3328,7 @@
helpCriteriaSelectorTest("CRITERIA", "CRITERIA", critSelector); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testCriteriaSelector10(){
+ @Test public void testCriteriaSelector10() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
CriteriaSelector critSelector = new CriteriaSelector();
@@ -3376,7 +3339,7 @@
}
/**HAS IS NULL CRITERIA ON (a)*/
- @Test public void testHasIsNullCriteria(){
+ @Test public void testHasIsNullCriteria() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3393,7 +3356,7 @@
}
/**HAS LIKE CRITERIA ON (a)*/
- @Test public void testHasLikeCriteria(){
+ @Test public void testHasLikeCriteria() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3409,7 +3372,7 @@
hasSelector);
}
- @Test public void testHasEQCriteria(){
+ @Test public void testHasEQCriteria() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3425,7 +3388,7 @@
hasSelector);
}
- @Test public void testHasNECriteria(){
+ @Test public void testHasNECriteria() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3442,7 +3405,7 @@
}
/**HAS IN CRITERIA ON (a)*/
- @Test public void testHasInCriteria(){
+ @Test public void testHasInCriteria() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3459,7 +3422,7 @@
}
/**HAS COMPARE_LT CRITERIA ON (a)*/
- @Test public void testHasLTCriteria(){
+ @Test public void testHasLTCriteria() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3476,7 +3439,7 @@
}
/**HAS COMPARE_LE CRITERIA ON (a)*/
- @Test public void testHasLECriteria(){
+ @Test public void testHasLECriteria() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3493,7 +3456,7 @@
}
/**HAS COMPARE_GT CRITERIA ON (a)*/
- @Test public void testHasGTCriteria(){
+ @Test public void testHasGTCriteria() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3510,7 +3473,7 @@
}
/**HAS COMPARE_GE CRITERIA ON (a)*/
- @Test public void testHasGECriteria(){
+ @Test public void testHasGECriteria() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3527,7 +3490,7 @@
}
/**HAS BETWEEN CRITERIA ON (a)*/
- @Test public void testHasBetweenCriteria(){
+ @Test public void testHasBetweenCriteria() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3543,7 +3506,7 @@
hasSelector);
}
- @Test public void testTranslateCriteria(){
+ @Test public void testTranslateCriteria() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List elements = new ArrayList();
elements.add(a);
@@ -3569,7 +3532,7 @@
}
- @Test public void testAssignStatement(){
+ @Test public void testAssignStatement() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
List symbols = new ArrayList();
@@ -3600,7 +3563,7 @@
helpStmtTest("a = 'aString';", "a = 'aString';", exprStmt); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testAssignStatement2(){
+ @Test public void testAssignStatement2() throws Exception {
Insert insert = new Insert();
insert.setGroup(new GroupSymbol("g")); //$NON-NLS-1$
List vars = new ArrayList();
@@ -3619,7 +3582,7 @@
}
- @Test public void testDeclareStatement(){
+ @Test public void testDeclareStatement() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
String type = new String("short"); //$NON-NLS-1$
DeclareStatement stmt = new DeclareStatement(a, type);
@@ -3627,7 +3590,7 @@
helpStmtTest("DECLARE short a;","DECLARE short a;", stmt); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testDeclareStatementWithAssignment(){
+ @Test public void testDeclareStatementWithAssignment() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
String type = new String("short"); //$NON-NLS-1$
DeclareStatement stmt = new DeclareStatement(a, type, new Constant(null));
@@ -3635,7 +3598,7 @@
helpStmtTest("DECLARE short a = null;","DECLARE short a = null;", stmt); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testDeclareStatementWithAssignment1(){
+ @Test public void testDeclareStatementWithAssignment1() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
String type = new String("string"); //$NON-NLS-1$
DeclareStatement stmt = new DeclareStatement(a, type, sampleQuery());
@@ -3643,7 +3606,7 @@
helpStmtTest("DECLARE string a = SELECT a1 FROM g WHERE a2 = 5;","DECLARE string a = SELECT a1 FROM g WHERE a2 = 5;", stmt); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testStatement() {
+ @Test public void testStatement() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
String type = new String("short"); //$NON-NLS-1$
DeclareStatement declStmt = new DeclareStatement(a, type);
@@ -3653,7 +3616,7 @@
stmt);
}
- @Test public void testBlock() {
+ @Test public void testBlock() throws Exception {
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
String type = new String("short"); //$NON-NLS-1$
DeclareStatement declStmt = new DeclareStatement(a, type);
@@ -3664,7 +3627,7 @@
block);
}
- @Test public void testCommandStatement(){
+ @Test public void testCommandStatement() throws Exception {
Query query = sampleQuery();
Command sqlCmd = query;
@@ -3695,7 +3658,7 @@
return query;
}
- @Test public void testDynamicCommandStatement(){
+ @Test public void testDynamicCommandStatement() throws Exception {
List symbols = new ArrayList();
ElementSymbol a1 = new ElementSymbol("a1"); //$NON-NLS-1$
@@ -3718,7 +3681,7 @@
}
//sql is a variable, also uses the as, into, and update clauses
- @Test public void testDynamicCommandStatement1(){
+ @Test public void testDynamicCommandStatement1() throws Exception {
List symbols = new ArrayList();
ElementSymbol a1 = new ElementSymbol("a1"); //$NON-NLS-1$
@@ -3746,7 +3709,7 @@
cmdStmt);
}
- @Test public void testDynamicCommandStatementWithUsing(){
+ @Test public void testDynamicCommandStatementWithUsing() throws Exception {
SetClauseList using = new SetClauseList();
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
@@ -5478,7 +5441,7 @@
helpTest(sql, sqlExpected, query);
}
- @Test public void testLoopStatement(){
+ @Test public void testLoopStatement() throws Exception {
GroupSymbol g = new GroupSymbol("m.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -5510,7 +5473,7 @@
+"\n"+"END", loopStmt); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testLoopStatementWithOrderBy(){
+ @Test public void testLoopStatementWithOrderBy() throws Exception {
GroupSymbol g = new GroupSymbol("m.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -5546,7 +5509,7 @@
+"\n"+"END", loopStmt); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testWhileStatement(){
+ @Test public void testWhileStatement() throws Exception {
ElementSymbol x = new ElementSymbol("x", false); //$NON-NLS-1$
Function f = new Function("+", new Expression[] { x, new Constant(new Integer(1)) }); //$NON-NLS-1$
Statement assignmentStmt = new AssignmentStatement(x, f);
@@ -5560,12 +5523,12 @@
+"\n"+"END", whileStmt); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testBreakStatement(){
+ @Test public void testBreakStatement() throws Exception {
Statement breakStmt = new BreakStatement();
helpStmtTest("break;", "BREAK;", breakStmt); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testContinueStatement(){
+ @Test public void testContinueStatement() throws Exception {
Statement contStmt = new ContinueStatement();
helpStmtTest("continue;", "CONTINUE;", contStmt); //$NON-NLS-1$ //$NON-NLS-2$
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -109,14 +109,12 @@
}
}
- static void helpTestProcess(boolean optimistic, ProcessorPlan procPlan, int rowsUpdated, List[] expectedResults, boolean shouldFail,
- ProcessorDataManager dataMgr) throws SQLException, MetaMatrixCoreException {
+ static void helpTestProcess(ProcessorPlan procPlan, int rowsUpdated, List[] expectedResults, boolean shouldFail, ProcessorDataManager dataMgr) throws SQLException, MetaMatrixCoreException {
// Process twice, testing reset and clone method of Processor plan
for (int i=1; i<=2; i++) {
BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
CommandContext context = new CommandContext("pID", null, null, null, null); //$NON-NLS-1$
context.getNextRand(0);
- context.setOptimisticTransaction(optimistic);
context.setProcessDebug(DEBUG);
QueryProcessor processor = new QueryProcessor(procPlan, context, bufferMgr, dataMgr);
TupleSourceID tsID = processor.getResultsID();
@@ -194,12 +192,12 @@
}
private void helpTestProcess(ProcessorPlan procPlan, int expectedRows, FakeDataManager dataMgr) throws SQLException, MetaMatrixCoreException {
- helpTestProcess(false, procPlan, expectedRows, null, false, dataMgr);
+ helpTestProcess(procPlan, expectedRows, null, false, dataMgr);
}
static void helpTestProcess(boolean optimistic, ProcessorPlan procPlan, List[] expectedResults,
ProcessorDataManager dataMgr, boolean shouldFail) throws SQLException, MetaMatrixCoreException {
- helpTestProcess(optimistic, procPlan, 0, expectedResults, shouldFail, dataMgr);
+ helpTestProcess(procPlan, 0, expectedResults, shouldFail, dataMgr);
}
// Helper to create a list of elements - used in creating sample data
@@ -1654,38 +1652,7 @@
helpTestProcessFailure(false, plan, dataMgr, "Couldn't execute the dynamic SQL command \"EXECUTE STRING 'select e1 from pm1.g1'\" with the SQL statement \"'select e1 from pm1.g1'\" due to: The datatype 'string' for element 'E1' in the dynamic SQL cannot be implicitly converted to 'integer'."); //$NON-NLS-1$
}
-
- @Test public void testDynamicCommandInvalidModelUpdateCountEqualOne() throws Exception {
- //Test invalid update model count
- //Set update model count to 1 while actual is 2
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
-
- FakeMetadataObject pm1 = metadata.getStore().findObject("pm1",FakeMetadataObject.MODEL); //$NON-NLS-1$
-
- FakeMetadataObject rs2 = FakeMetadataFactory.createResultSet("pm1.rs1", pm1, new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject rs2p1 = FakeMetadataFactory.createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs2); //$NON-NLS-1$
- FakeMetadataObject rs2p2 = FakeMetadataFactory.createParameter("in", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
- QueryNode sq2n1 = new QueryNode("pm1.sq1", "CREATE VIRTUAL PROCEDURE BEGIN\n" //$NON-NLS-1$ //$NON-NLS-2$
- + "INSERT INTO pm1.g1 (e1) VALUES (pm1.sq1.in);UPDATE pm1.g2 SET e1 = 'Next'; END"); //$NON-NLS-1$
- FakeMetadataObject sq1 = FakeMetadataFactory.createVirtualProcedure("pm1.sq1", pm1, Arrays.asList(new FakeMetadataObject[] { rs2p1, rs2p2 }), sq2n1); //$NON-NLS-1$
-
- QueryNode sq2n2 = new QueryNode("pm1.sq2", "CREATE VIRTUAL PROCEDURE BEGIN\n" //$NON-NLS-1$ //$NON-NLS-2$
- + "execute string 'EXEC pm1.sq1(''First'')' as e1 string UPDATE 1; END"); //$NON-NLS-1$
- FakeMetadataObject sq2 = FakeMetadataFactory.createVirtualProcedure("pm1.sq2", pm1, Arrays.asList(new FakeMetadataObject[] { rs2p1, rs2p2 }), sq2n2); //$NON-NLS-1$
-
- metadata.getStore().addObject(rs2);
- metadata.getStore().addObject(sq1);
- metadata.getStore().addObject(sq2);
-
- String userUpdateStr = "EXEC pm1.sq2('test')"; //$NON-NLS-1$
-
- FakeDataManager dataMgr = exampleDataManager(metadata);
-
- ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
-
- helpTestProcessFailure(true, plan, dataMgr, "Couldn't execute the dynamic SQL command \"EXECUTE STRING 'EXEC pm1.sq1(''First'')' AS e1 string UPDATE 1\" with the SQL statement \"'EXEC pm1.sq1(''First'')'\" due to: The actual model update count '2' is greater than the expected value of '1'. This is potentially unsafe in OPTIMISTIC transaction mode. Please adjust the UPDATE clause of the dynamic SQL statement."); //$NON-NLS-1$
- }
-
+
@Test public void testDynamicCommandWithTwoDynamicStatements() throws Exception {
//Tests dynamic query with two consecutive DynamicCommands. The first without an AS clause and returning different results.
FakeMetadataFacade metadata = FakeMetadataFactory.example1();
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2009-12-14 18:21:21 UTC (rev 1661)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2009-12-14 18:48:26 UTC (rev 1662)
@@ -209,7 +209,7 @@
public void helpTestVisibilityFails(String sql) throws Exception {
RequestMessage reqMsg = exampleRequestMessage(sql);
- reqMsg.setTxnAutoWrapMode(ExecutionProperties.AUTO_WRAP_OFF);
+ reqMsg.setTxnAutoWrapMode(ExecutionProperties.TXN_WRAP_OFF);
Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
ResultsMessage results = message.get(50000, TimeUnit.MILLISECONDS);
assertEquals("[QueryValidatorException]Group does not exist: BQT3.SmallA", results.getException().toString()); //$NON-NLS-1$
@@ -235,7 +235,7 @@
RequestMessage reqMsg = exampleRequestMessage(sql);
DQPWorkContext.getWorkContext().setSessionToken(new SessionToken(new MetaMatrixSessionID(sessionid), userName));
if (txnAutoWrap) {
- reqMsg.setTxnAutoWrapMode(ExecutionProperties.AUTO_WRAP_ON);
+ reqMsg.setTxnAutoWrapMode(ExecutionProperties.TXN_WRAP_ON);
}
Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
15 years, 1 month