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>