teiid SVN: r1672 - in trunk/test-integration/db/src: main/java/org/teiid/test/framework and 4 other directories.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-12-15 19:07:07 -0500 (Tue, 15 Dec 2009)
New Revision: 1672
Added:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/AutoWrapTransaction.java
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/AutoWrapTransactionTests.java
Removed:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OptimisticWrapTransactionTests.java
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/PessimisticWrapTransactionTests.java
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/client/TransactionFactory.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.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/ConnectionStrategy.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/util/PropUtils.java
Log:
Teiid 897 - changes to autowrap mode
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/TransactionFactory.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/TransactionFactory.java 2009-12-15 23:28:12 UTC (rev 1671)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/TransactionFactory.java 2009-12-16 00:07:07 UTC (rev 1672)
@@ -25,12 +25,11 @@
import org.teiid.test.framework.TransactionContainer;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
+import org.teiid.test.framework.transaction.AutoWrapTransaction;
import org.teiid.test.framework.transaction.JNDITransaction;
import org.teiid.test.framework.transaction.LocalTransaction;
import org.teiid.test.framework.transaction.OffWrapTransaction;
import org.teiid.test.framework.transaction.OnWrapTransaction;
-import org.teiid.test.framework.transaction.OptimisticWrapTransaction;
-import org.teiid.test.framework.transaction.PessimisticWrapTransaction;
import org.teiid.test.framework.transaction.XATransaction;
@@ -58,8 +57,7 @@
public static final String JNDI_TRANSACTION = "jndi"; //$NON-NLS-1$
public static final String OFFWRAP_TRANSACTION = "offwrap"; //$NON-NLS-1$
public static final String ONWRAP_TRANSACTION = "onwrap"; //$NON-NLS-1$
- public static final String OPTIMISTICWRAP_TRANSACTION = "optwrap"; //$NON-NLS-1$
- public static final String PESSIMISTICWRAP_TRANSACTION = "pesswrap"; //$NON-NLS-1$
+ public static final String AUTOWRAP_TRANSACTION = "autowrap"; //$NON-NLS-1$
}
@@ -92,13 +90,9 @@
else if (type.equalsIgnoreCase(TRANSACTION_TYPES.ONWRAP_TRANSACTION)) {
transacton = new OnWrapTransaction();
}
- else if (type.equalsIgnoreCase(TRANSACTION_TYPES.OPTIMISTICWRAP_TRANSACTION)) {
- transacton = new OptimisticWrapTransaction();
- }
- else if (type.equalsIgnoreCase(TRANSACTION_TYPES.PESSIMISTICWRAP_TRANSACTION)) {
- transacton = new PessimisticWrapTransaction();
+ else if (type.equalsIgnoreCase(TRANSACTION_TYPES.AUTOWRAP_TRANSACTION)) {
+ transacton = new AutoWrapTransaction();
-
} else {
throw new TransactionRuntimeException("Invalid property value of " + type + " for " + TRANSACTION_TYPE );
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java 2009-12-15 23:28:12 UTC (rev 1671)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java 2009-12-16 00:07:07 UTC (rev 1672)
@@ -60,12 +60,10 @@
}
_instance = new ConfigPropertyLoader();
- try {
- _instance.initialize();
- } catch (TransactionRuntimeException e) {
- throw e;
- }
+ _instance.initialize();
+
+
return _instance;
}
@@ -148,8 +146,12 @@
Properties p = new Properties();
p.putAll(System.getProperties());
- p.putAll(props);
- p.putAll(overrides);
+ if (props != null) {
+ p.putAll(props);
+ }
+ if (overrides != null) {
+ p.putAll(overrides);
+ }
return p;
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java 2009-12-15 23:28:12 UTC (rev 1671)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java 2009-12-16 00:07:07 UTC (rev 1672)
@@ -120,11 +120,10 @@
}
public interface TXN_AUTO_WRAP_OPTIONS {
- public static final String AUTO_WRAP_OFF = "OFF"; //$NON-NLS-1$
- public static final String AUTO_WRAP_ON = "ON"; //$NON-NLS-1$
- public static final String AUTO_WRAP_PESSIMISTIC = "PESSIMISTIC"; //$NON-NLS-1$
- public static final String AUTO_WRAP_OPTIMISTIC = "OPTIMISTIC"; //$NON-NLS-1$
-
+ public static final String AUTO_WRAP_OFF = ExecutionProperties.TXN_WRAP_OFF; //$NON-NLS-1$
+ public static final String AUTO_WRAP_ON = ExecutionProperties.TXN_WRAP_ON; //$NON-NLS-1$
+ public static final String AUTO_WRAP_AUTO = ExecutionProperties.TXN_WRAP_AUTO; //$NON-NLS-1$
+
}
}
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 23:28:12 UTC (rev 1671)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TestLogger.java 2009-12-16 00:07:07 UTC (rev 1672)
@@ -38,17 +38,17 @@
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 {
BasicConfigurator.configure(new ConsoleAppender());
- LOGGER.setLevel(INFO);
+// LOGGER.setLevel(INFO);
}
public static final void setLogLevel(Level level) {
- LOGGER.setLevel(level);
+// LOGGER.setLevel(level);
}
public static final void logDebug(String msg) {
@@ -75,11 +75,11 @@
}
private static final void log(Level javaLevel, Object msg, Throwable t) {
-// System.out.println(msg);
- if (LOGGER.isLoggable(javaLevel)) {
-
- LOGGER.log(javaLevel, msg.toString(), t);
- }
+ System.out.println(msg);
+// if (LOGGER.isLoggable(javaLevel)) {
+//
+// LOGGER.log(javaLevel, msg.toString(), t);
+// }
}
}
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 23:28:12 UTC (rev 1671)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java 2009-12-16 00:07:07 UTC (rev 1672)
@@ -130,26 +130,28 @@
if (this.isDataStoreDisabled()) {
return;
}
-
- 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
-
+ Admin admin = null;
+
java.sql.Connection conn = getConnection();
+
if ( conn instanceof com.metamatrix.jdbc.MMConnection) {
- c = (com.metamatrix.jdbc.MMConnection) conn;
+ com.metamatrix.jdbc.MMConnection c = (com.metamatrix.jdbc.MMConnection) conn;
+ admin = (Admin)c.getAdminAPI();
+ } else if (conn instanceof com.metamatrix.jdbc.api.Connection) {
+ com.metamatrix.jdbc.api.Connection c = (com.metamatrix.jdbc.api.Connection) conn;
+ admin = (Admin)c.getAdminAPI();
} else {
TestLogger.log("ConnectionStrategy configuration: connection is not of type MMConnection and therefore no vdb setup will be performed");
return;
}
+
+ setupVDBConnectorBindings(admin);
- Admin admin = (Admin)c.getAdminAPI();
-
- setupVDBConnectorBindings(admin);
-
-
// admin.restart();
int sleep = 5;
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 23:28:12 UTC (rev 1671)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java 2009-12-16 00:07:07 UTC (rev 1672)
@@ -107,7 +107,7 @@
public Connection getConnection() throws QueryTestFailedException {
try {
- return getXAConnection().getConnection();
+ return getXAConnection().getConnection();
} catch (QueryTestFailedException qtf) {
throw qtf;
} catch (Exception e) {
@@ -137,9 +137,9 @@
DataSource ds = (DataSource)Class.forName(this.driver).newInstance();
if (ds instanceof BaseDataSource) {
+
BaseDataSource dataSource = (BaseDataSource) ds;
- //Class.forName(this.driver).newInstance();
-
+
dataSource.setDatabaseName(this.databaseName);
if (this.applName != null) {
dataSource.setApplicationName(this.applName);
@@ -158,6 +158,7 @@
dataSource.setPassword(this.pwd);
}
+
return ((XADataSource) dataSource).getXAConnection(this.username,
this.pwd);
} else {
Added: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/AutoWrapTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/AutoWrapTransaction.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/AutoWrapTransaction.java 2009-12-16 00:07:07 UTC (rev 1672)
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.framework.transaction;
+
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.TransactionQueryTestCase;
+import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
+import org.teiid.test.framework.ConfigPropertyNames.TXN_AUTO_WRAP_OPTIONS;
+
+
+/**
+ * This transction is only valid when
+ * AutoCommit = ON
+ * txnAutoWrap = Optimistic.
+ */
+public class AutoWrapTransaction extends TransactionContainer {
+ public AutoWrapTransaction() {
+ super();
+ }
+
+ public void before(TransactionQueryTestCase test) {
+ test.getConnectionStrategy().setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_AUTO);
+
+ }
+
+ public void after(TransactionQueryTestCase test) {
+
+ }
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/AutoWrapTransaction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java 2009-12-15 23:28:12 UTC (rev 1671)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java 2009-12-16 00:07:07 UTC (rev 1672)
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2000-2007 MetaMatrix, Inc.
- * All rights reserved.
- */
-package org.teiid.test.framework.transaction;
-
-import org.teiid.test.framework.TransactionContainer;
-import org.teiid.test.framework.TransactionQueryTestCase;
-import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
-import org.teiid.test.framework.ConfigPropertyNames.TXN_AUTO_WRAP_OPTIONS;
-
-
-/**
- * This transction is only valid when
- * AutoCommit = ON
- * txnAutoWrap = Optimistic.
- */
-public class OptimisticWrapTransaction extends TransactionContainer {
- public OptimisticWrapTransaction() {
- super();
- }
-
- public void before(TransactionQueryTestCase test) {
- test.getConnectionStrategy().setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_OPTIMISTIC);
-
- }
-
- public void after(TransactionQueryTestCase test) {
-
- }
-}
Deleted: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java 2009-12-15 23:28:12 UTC (rev 1671)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java 2009-12-16 00:07:07 UTC (rev 1672)
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2000-2007 MetaMatrix, Inc.
- * All rights reserved.
- */
-package org.teiid.test.framework.transaction;
-
-import org.teiid.test.framework.TransactionContainer;
-import org.teiid.test.framework.TransactionQueryTestCase;
-import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
-import org.teiid.test.framework.ConfigPropertyNames.TXN_AUTO_WRAP_OPTIONS;
-
-
-/**
- * This transaction type only is valid when
- * AutoCommit = ON
- * txnAutoWrap = PESSIMISTIC
- */
-public class PessimisticWrapTransaction extends TransactionContainer {
- public PessimisticWrapTransaction() {
- super();
- }
-
- public void before(TransactionQueryTestCase test) {
- test.getConnectionStrategy().setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_PESSIMISTIC);
-
- }
-
- public void after(TransactionQueryTestCase test) {
-
- }
-
-
-}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/util/PropUtils.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/util/PropUtils.java 2009-12-15 23:28:12 UTC (rev 1671)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/util/PropUtils.java 2009-12-16 00:07:07 UTC (rev 1672)
@@ -5,6 +5,7 @@
import java.util.Properties;
import org.teiid.test.framework.ConfigPropertyLoader;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
public class PropUtils {
@@ -25,10 +26,10 @@
}
else {
- throw new RuntimeException("Failed to load properties from file '"+filename+ "' configuration file");
+ throw new TransactionRuntimeException("Failed to load properties from file '"+filename+ "' configuration file");
}
} catch (IOException e) {
- throw new RuntimeException("Error loading properties from file '"+filename+ "'" + e.getMessage());
+ throw new TransactionRuntimeException("Error loading properties from file '"+filename+ "'" + e.getMessage());
} finally {
try {
in.close();
Added: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/AutoWrapTransactionTests.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/AutoWrapTransactionTests.java (rev 0)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/AutoWrapTransactionTests.java 2009-12-16 00:07:07 UTC (rev 1672)
@@ -0,0 +1,492 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.testcases;
+
+import java.util.ArrayList;
+
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.query.AbstractQueryTransactionTest;
+import org.teiid.test.framework.query.QueryExecution;
+import org.teiid.test.framework.transaction.AutoWrapTransaction;
+
+import com.metamatrix.jdbc.api.AbstractQueryTest;
+
+
+
+/**
+ * The main thing to test in this is, when the single source should is involved it should work
+ * fine, when multiple sources involved it should fail.
+ */
+public class AutoWrapTransactionTests extends BaseAbstractTransactionTestCase {
+
+ public AutoWrapTransactionTests(String testName) {
+ super(testName);
+ }
+
+ protected TransactionContainer getTransactionContainter() {
+ return new AutoWrapTransaction();
+ }
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////
+ // Single Source - Rows below 500 (for insert/update/delete)
+ ///////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Sources = 1
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourceSelect() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("select * from pm1.g1 where pm1.g1.e1 < 100");
+ assertRowCount(100);
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 1
+ * Commands = 1, Update(prepared statement)
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourcePreparedUpdate() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("insert into pm1.g1 (e1, e2) values(?, ?)", new Object[] {new Integer(102), "102"});
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 = 102");
+ test.assertRowCount(1);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourceMultipleCommands() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("delete from pm1.g2 where pm1.g2.e1 >= ?", new Object[] {new Integer(100)});
+ execute("delete from pm1.g1 where pm1.g1.e1 >= ?", new Object[] {new Integer(100)});
+
+ execute("select * from pm1.g1");
+ assertRowCount(100);
+ for (int i = 100; i < 120; i++) {
+ Integer val = new Integer(i);
+ execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ }
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 100 and e1 < 120");
+ test.assertRowCount(20);
+ test.execute("select * from g2 where e1 >= 100 and e1 < 120");
+ test.assertRowCount(20);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourceBatchCommand() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ ArrayList list = new ArrayList();
+ list.add("delete from pm1.g2 where pm1.g2.e1 >= 100");
+ list.add("delete from pm1.g1 where pm1.g1.e1 >= 100");
+
+ for (int i = 200; i < 205; i++) {
+ list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
+ list.add("insert into pm1.g2 (e1, e2) values("+i+",'"+i+"')");
+ }
+ executeBatch((String[])list.toArray(new String[list.size()]));
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 200 and e1 < 205");
+ test.assertRowCount(5);
+ test.execute("select * from g2 where e1 >= 200 and e1 < 205");
+ test.assertRowCount(5);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 1
+ * Commands = 1, Update(prepared statement)
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourcePreparedUpdateRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("insert into pm1.g2 (e1, e2) values(?, ?)", new Object[] {new Integer(9999), "9999"});
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g2 where e1 = 9999");
+ test.assertRowCount(0);
+ test.closeConnection();
+ }
+
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourceMultipleCommandsRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("delete from pm1.g2 where pm1.g2.e1 >= ?", new Object[] {new Integer(100)});
+ execute("delete from pm1.g1 where pm1.g1.e1 >= ?", new Object[] {new Integer(100)});
+
+ execute("select * from pm1.g1");
+ assertRowCount(100);
+
+ for (int i = 300; i < 310; i++) {
+ Integer val = new Integer(i);
+ execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ }
+
+ // this will make it rollback
+ execute("insert into pm1.g2 (e1, e2) values(?, ?)", new Object[] {new Integer(9999), "9999"});
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results (since they are not bundled in single command they should be treated individually)
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 300 and e1 < 310");
+ test.assertRowCount(10);
+ test.execute("select * from g2 where e1 >= 300 and e1 < 310");
+ test.assertRowCount(10);
+ test.execute("select * from g2 where e1 = 9999");
+ test.assertRowCount(0);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourceBatchCommandRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ ArrayList list = new ArrayList();
+ list.add("delete from pm1.g2 where pm1.g2.e1 >= 100");
+ list.add("delete from pm1.g1 where pm1.g1.e1 >= 100");
+
+ for (int i = 400; i < 410; i++) {
+ list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
+ list.add("insert into pm1.g2 (e1, e2) values("+i+",'"+i+"')");
+ }
+
+ // this will make it rollback
+ list.add("insert into pm1.g2 (e1, e2) values(9999, '9999')");
+
+ executeBatch((String[])list.toArray(new String[list.size()]));
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results (all commands will trated as single under single transaction)
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 400 and e1 < 410");
+ test.assertRowCount(0);
+ test.execute("select * from g2 where e1 >= 400 and e1 < 410");
+ test.assertRowCount(0);
+ test.execute("select * from g2 where e1 = 9999");
+ test.assertRowCount(0);
+ test.closeConnection();
+ }
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////
+ // Multiple Sources - Rows from 500
+ ///////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceSelect() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("select * from pm1.g1 join pm2.g1 on pm1.g1.e1 = pm2.g1.e1 where pm1.g1.e1 < 100");
+ assertRowCount(100);
+ }
+
+ public void after() {
+ // selects are special case as they will not fail to use multiple sources. The transaction
+ // source count only starts when there are updates to db, so this is OK
+ if (exceptionOccurred()) {
+ fail("should not have failed to involve multiple sources under optimistic txn");
+ }
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceUpdate() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ Integer value = new Integer(500);
+ execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {value, value.toString(), value, value.toString()});
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ public void after() {
+ if (!exceptionOccurred()) {
+ fail("should have failed to involve multiple sources under optimistic txn");
+ }
+ else {
+ assertTrue(getLastException().getMessage(), getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
+ }
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 2
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourcesBatchCommand() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ ArrayList list = new ArrayList();
+ list.add("delete from pm1.g2 where pm1.g2.e1 >= 100");
+ list.add("delete from pm1.g1 where pm1.g1.e1 >= 100");
+
+ list.add("delete from pm2.g2 where pm2.g2.e1 >= 100");
+ list.add("delete from pm2.g1 where pm2.g1.e1 >= 100");
+
+ for (int i = 200; i < 210; i++) {
+ list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
+ list.add("insert into pm1.g2 (e1, e2) values("+i+",'"+i+"')");
+
+ list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
+ list.add("insert into pm1.g2 (e1, e2) values("+i+",'"+i+"')");
+ }
+ executeBatch((String[])list.toArray(new String[list.size()]));
+ }
+
+ public void after() {
+ if (!exceptionOccurred()) {
+ fail("should have failed to involve multiple sources under optimistic txn");
+ }
+ else {
+ assertTrue(getLastException().getMessage(), getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
+ }
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ };
+
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceVirtualSelect() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("select * from vm.g1");
+ }
+
+ public void after() {
+ if (exceptionOccurred()) {
+ fail("should not have failed to involve multiple sources under optimistic txn");
+ }
+ }
+ };
+
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceVirtualProceduralSelect() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("select * from vm.p1");
+ }
+ // if vm.p1 needs a transaction, depends on transformation
+ //
+ public void after() {
+ if (exceptionOccurred()) {
+ fail("should have failed to involve multiple sources under optimistic txn");
+ }
+ }
+ };
+
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceVirtualProcedure() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("select * from vm.p2 where vm.p2.e1 = ? and vm.p2.e2 = ?", new Object[] {new Integer(200), "200"});
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ public void after() {
+ if (!exceptionOccurred()) {
+ fail("should have failed to involve multiple sources under optimistic txn");
+ }
+ else {
+ assertTrue(getLastException().getMessage(), getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
+ }
+ }
+ };
+
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ public void testMultipleSourceVirtualProceduralSelectWithUpdate() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("exec vm.p2(?, ?)", new Object[] {new Integer(200), "200"});
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ public void after() {
+ if (!exceptionOccurred()) {
+ fail("should have failed to involve multiple sources under optimistic txn");
+ }
+ else {
+ assertTrue(getLastException().getMessage(), getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
+ }
+ }
+ };
+
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceVirtualUpdate() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("delete from vm.g1 where vm.g1.pm1e1 > 100");
+ }
+
+ public void after() {
+ if (!exceptionOccurred()) {
+ fail("should have failed to involve multiple sources under optimistic txn");
+ }
+ else {
+ assertTrue(getLastException().getMessage(), getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
+ }
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ };
+
+ getTransactionContainter().runTransaction(userTxn);
+ }
+}
Property changes on: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/AutoWrapTransactionTests.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OptimisticWrapTransactionTests.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OptimisticWrapTransactionTests.java 2009-12-15 23:28:12 UTC (rev 1671)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OptimisticWrapTransactionTests.java 2009-12-16 00:07:07 UTC (rev 1672)
@@ -1,491 +0,0 @@
-/*
- * Copyright (c) 2000-2007 MetaMatrix, Inc.
- * All rights reserved.
- */
-package org.teiid.test.testcases;
-
-import java.util.ArrayList;
-
-import org.teiid.test.framework.TransactionContainer;
-import org.teiid.test.framework.query.AbstractQueryTransactionTest;
-import org.teiid.test.framework.query.QueryExecution;
-import org.teiid.test.framework.transaction.OptimisticWrapTransaction;
-
-import com.metamatrix.jdbc.api.AbstractQueryTest;
-
-
-
-/**
- * The main thing to test in this is, when the single source should is involved it should work
- * fine, when multiple sources involved it should fail.
- */
-public class OptimisticWrapTransactionTests extends BaseAbstractTransactionTestCase {
-
- public OptimisticWrapTransactionTests(String testName) {
- super(testName);
- }
-
- protected TransactionContainer getTransactionContainter() {
- return new OptimisticWrapTransaction();
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////////////
- // Single Source - Rows below 500 (for insert/update/delete)
- ///////////////////////////////////////////////////////////////////////////////////////////////
-
- /**
- * Sources = 1
- * Commands = 1, Select
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testSingleSourceSelect() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- execute("select * from pm1.g1 where pm1.g1.e1 < 100");
- assertRowCount(100);
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
- }
-
- /**
- * Sources = 1
- * Commands = 1, Update(prepared statement)
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testSingleSourcePreparedUpdate() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- execute("insert into pm1.g1 (e1, e2) values(?, ?)", new Object[] {new Integer(102), "102"});
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- // now verify the results
- AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
- test.execute("select * from g1 where e1 = 102");
- test.assertRowCount(1);
- test.closeConnection();
- }
-
- /**
- * Sources = 1
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testSingleSourceMultipleCommands() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- execute("delete from pm1.g2 where pm1.g2.e1 >= ?", new Object[] {new Integer(100)});
- execute("delete from pm1.g1 where pm1.g1.e1 >= ?", new Object[] {new Integer(100)});
-
- execute("select * from pm1.g1");
- assertRowCount(100);
- for (int i = 100; i < 120; i++) {
- Integer val = new Integer(i);
- execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
- execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
- }
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- // now verify the results
- AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
- test.execute("select * from g1 where e1 >= 100 and e1 < 120");
- test.assertRowCount(20);
- test.execute("select * from g2 where e1 >= 100 and e1 < 120");
- test.assertRowCount(20);
- test.closeConnection();
- }
-
- /**
- * Sources = 1
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testSingleSourceBatchCommand() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- ArrayList list = new ArrayList();
- list.add("delete from pm1.g2 where pm1.g2.e1 >= 100");
- list.add("delete from pm1.g1 where pm1.g1.e1 >= 100");
-
- for (int i = 200; i < 205; i++) {
- list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
- list.add("insert into pm1.g2 (e1, e2) values("+i+",'"+i+"')");
- }
- executeBatch((String[])list.toArray(new String[list.size()]));
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- // now verify the results
- AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
- test.execute("select * from g1 where e1 >= 200 and e1 < 205");
- test.assertRowCount(5);
- test.execute("select * from g2 where e1 >= 200 and e1 < 205");
- test.assertRowCount(5);
- test.closeConnection();
- }
-
- /**
- * Sources = 1
- * Commands = 1, Update(prepared statement)
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testSingleSourcePreparedUpdateRollback() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- execute("insert into pm1.g2 (e1, e2) values(?, ?)", new Object[] {new Integer(9999), "9999"});
- }
-
- public boolean exceptionExpected() {
- return true;
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- // now verify the results
- AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
- test.execute("select * from g2 where e1 = 9999");
- test.assertRowCount(0);
- test.closeConnection();
- }
-
-
- /**
- * Sources = 1
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testSingleSourceMultipleCommandsRollback() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- execute("delete from pm1.g2 where pm1.g2.e1 >= ?", new Object[] {new Integer(100)});
- execute("delete from pm1.g1 where pm1.g1.e1 >= ?", new Object[] {new Integer(100)});
-
- execute("select * from pm1.g1");
- assertRowCount(100);
-
- for (int i = 300; i < 310; i++) {
- Integer val = new Integer(i);
- execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
- execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
- }
-
- // this will make it rollback
- execute("insert into pm1.g2 (e1, e2) values(?, ?)", new Object[] {new Integer(9999), "9999"});
- }
-
- public boolean exceptionExpected() {
- return true;
- }
-
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- // now verify the results (since they are not bundled in single command they should be treated individually)
- AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
- test.execute("select * from g1 where e1 >= 300 and e1 < 310");
- test.assertRowCount(10);
- test.execute("select * from g2 where e1 >= 300 and e1 < 310");
- test.assertRowCount(10);
- test.execute("select * from g2 where e1 = 9999");
- test.assertRowCount(0);
- test.closeConnection();
- }
-
- /**
- * Sources = 1
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testSingleSourceBatchCommandRollback() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- ArrayList list = new ArrayList();
- list.add("delete from pm1.g2 where pm1.g2.e1 >= 100");
- list.add("delete from pm1.g1 where pm1.g1.e1 >= 100");
-
- for (int i = 400; i < 410; i++) {
- list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
- list.add("insert into pm1.g2 (e1, e2) values("+i+",'"+i+"')");
- }
-
- // this will make it rollback
- list.add("insert into pm1.g2 (e1, e2) values(9999, '9999')");
-
- executeBatch((String[])list.toArray(new String[list.size()]));
- }
-
- public boolean exceptionExpected() {
- return true;
- }
-
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- // now verify the results (all commands will trated as single under single transaction)
- AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
- test.execute("select * from g1 where e1 >= 400 and e1 < 410");
- test.assertRowCount(0);
- test.execute("select * from g2 where e1 >= 400 and e1 < 410");
- test.assertRowCount(0);
- test.execute("select * from g2 where e1 = 9999");
- test.assertRowCount(0);
- test.closeConnection();
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////////////
- // Multiple Sources - Rows from 500
- ///////////////////////////////////////////////////////////////////////////////////////////////
-
- /**
- * Sources = 2
- * Commands = 1, Select
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceSelect() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- execute("select * from pm1.g1 join pm2.g1 on pm1.g1.e1 = pm2.g1.e1 where pm1.g1.e1 < 100");
- assertRowCount(100);
- }
-
- public void after() {
- // selects are special case as they will not fail to use multiple sources. The transaction
- // source count only starts when there are updates to db, so this is OK
- if (exceptionOccurred()) {
- fail("should not have failed to involve multiple sources under optimistic txn");
- }
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
- }
-
- /**
- * Sources = 2
- * Commands = 1, Select
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceUpdate() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- Integer value = new Integer(500);
- execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {value, value.toString(), value, value.toString()});
- }
-
- public boolean exceptionExpected() {
- return true;
- }
-
- public void after() {
- if (!exceptionOccurred()) {
- fail("should have failed to involve multiple sources under optimistic txn");
- }
- else {
- assertTrue(getLastException().getMessage(), getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
- }
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
- }
-
- /**
- * Sources = 2
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourcesBatchCommand() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- ArrayList list = new ArrayList();
- list.add("delete from pm1.g2 where pm1.g2.e1 >= 100");
- list.add("delete from pm1.g1 where pm1.g1.e1 >= 100");
-
- list.add("delete from pm2.g2 where pm2.g2.e1 >= 100");
- list.add("delete from pm2.g1 where pm2.g1.e1 >= 100");
-
- for (int i = 200; i < 210; i++) {
- list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
- list.add("insert into pm1.g2 (e1, e2) values("+i+",'"+i+"')");
-
- list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
- list.add("insert into pm1.g2 (e1, e2) values("+i+",'"+i+"')");
- }
- executeBatch((String[])list.toArray(new String[list.size()]));
- }
-
- public void after() {
- if (!exceptionOccurred()) {
- fail("should have failed to involve multiple sources under optimistic txn");
- }
- else {
- assertTrue(getLastException().getMessage(), getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
- }
- }
-
- public boolean exceptionExpected() {
- return true;
- }
-
- };
-
- getTransactionContainter().runTransaction(userTxn);
- }
-
- /**
- * Sources = 2
- * Commands = 1, Select
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceVirtualSelect() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- execute("select * from vm.g1");
- }
-
- public void after() {
- if (exceptionOccurred()) {
- fail("should not have failed to involve multiple sources under optimistic txn");
- }
- }
- };
-
- getTransactionContainter().runTransaction(userTxn);
- }
-
- /**
- * Sources = 2
- * Commands = 1, Select
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceVirtualProceduralSelect() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- execute("select * from vm.p1");
- }
-
- public void after() {
- if (exceptionOccurred()) {
- fail("should have failed to involve multiple sources under optimistic txn");
- }
- }
- };
-
- getTransactionContainter().runTransaction(userTxn);
- }
-
- /**
- * Sources = 2
- * Commands = 1, Select
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceVirtualProcedure() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- execute("select * from vm.p2 where vm.p2.e1 = ? and vm.p2.e2 = ?", new Object[] {new Integer(200), "200"});
- }
-
- public boolean exceptionExpected() {
- return true;
- }
-
- public void after() {
- if (!exceptionOccurred()) {
- fail("should have failed to involve multiple sources under optimistic txn");
- }
- else {
- assertTrue(getLastException().getMessage(), getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
- }
- }
- };
-
- getTransactionContainter().runTransaction(userTxn);
- }
-
- public void testMultipleSourceVirtualProceduralSelectWithUpdate() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- execute("exec vm.p2(?, ?)", new Object[] {new Integer(200), "200"});
- }
-
- public boolean exceptionExpected() {
- return true;
- }
-
- public void after() {
- if (!exceptionOccurred()) {
- fail("should have failed to involve multiple sources under optimistic txn");
- }
- else {
- assertTrue(getLastException().getMessage(), getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
- }
- }
- };
-
- getTransactionContainter().runTransaction(userTxn);
- }
-
- /**
- * Sources = 2
- * Commands = 1, Select
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceVirtualUpdate() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- execute("delete from vm.g1 where vm.g1.pm1e1 > 100");
- }
-
- public void after() {
- if (!exceptionOccurred()) {
- fail("should have failed to involve multiple sources under optimistic txn");
- }
- else {
- assertTrue(getLastException().getMessage(), getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
- }
- }
-
- public boolean exceptionExpected() {
- return true;
- }
-
- };
-
- getTransactionContainter().runTransaction(userTxn);
- }
-}
Deleted: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/PessimisticWrapTransactionTests.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/PessimisticWrapTransactionTests.java 2009-12-15 23:28:12 UTC (rev 1671)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/PessimisticWrapTransactionTests.java 2009-12-16 00:07:07 UTC (rev 1672)
@@ -1,141 +0,0 @@
-/*
- * Copyright (c) 2000-2007 MetaMatrix, Inc.
- * All rights reserved.
- */
-package org.teiid.test.testcases;
-
-import java.util.ArrayList;
-
-import org.teiid.test.framework.TransactionContainer;
-import org.teiid.test.framework.query.AbstractQueryTransactionTest;
-import org.teiid.test.framework.query.QueryExecution;
-import org.teiid.test.framework.transaction.PessimisticWrapTransaction;
-
-import com.metamatrix.jdbc.api.AbstractQueryTest;
-
-
-public class PessimisticWrapTransactionTests extends CommonTransactionTests {
-
- public PessimisticWrapTransactionTests(String testName) {
- super(testName);
- }
-
- protected TransactionContainer getTransactionContainter() {
- return new PessimisticWrapTransaction();
- }
-
- /**
- * Sources = 1
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = rollback
- */
- public void testSingleSourceMultipleCommandsReferentialIntegrityRollback() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- for (int i = 200; i < 210; i++) {
- Integer val = new Integer(i);
- execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
- execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
- }
-
- // try to rollback, however since this pessimistic above two are already commited
- execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {new Integer(9999), "9999"});
- }
-
- public boolean exceptionExpected() {
- return true;
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- // now verify the results
- AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
- test.execute("select * from g1 where e1 >= 200 and e1 < 210");
- test.assertRowCount(10);
- test.execute("select * from g2 where e1 = 9999");
- test.assertRowCount(0);
- test.closeConnection();
- }
-
- /**
- * Sources = 1
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = rollback
- */
- public void testSingleSourceBatchCommandReferentialIntegrityRollback() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- ArrayList list = new ArrayList();
- for (int i = 200; i < 210; i++) {
- list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
- }
-
- // try to rollback, since we are in single batch it must rollback
- list.add("insert into pm1.g2 (e1, e2) values(9999,'9999')");
- executeBatch((String[])list.toArray(new String[list.size()]));
- }
-
- public boolean exceptionExpected() {
- return true;
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- // now verify the results
- AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
- test.execute("select * from g1 where e1 >= 200 and e1 < 210");
- test.assertRowCount(0);
- test.execute("select * from g2 where e1 = 9999");
- test.assertRowCount(0);
- test.closeConnection();
- }
-
- /**
- * Sources = 2
- * Commands = 1, Update
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceBulkRowInsertRollback() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- ArrayList list = new ArrayList();
- public void testCase() throws Exception {
- for (int i = 100; i < 120; i++) {
- list.add("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values("+i+",'"+i+"',"+i+",'"+i+"')");
- }
- list.add("select pm1.g1.e1, pm1.g1.e2 into pm2.g2 from pm1.g1 where pm1.g1.e1 >= 100");
-
- // force the rollback by trying to insert an invalid row.
- list.add("insert into pm1.g2 (e1, e2) values(9999,'9999')");
-
- executeBatch((String[])list.toArray(new String[list.size()]));
- }
-
- public boolean exceptionExpected() {
- return true;
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- // now verify the results
- AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
- test.execute("select * from g1 where e1 >= 100 and e1 < 120");
- test.assertRowCount(0);
- test.closeConnection();
-
- test = new QueryExecution(userTxn.getSource("pm2"));
- test.execute("select * from g1 where e1 >= 100 and e1 < 120");
- test.assertRowCount(0);
- test.execute("select * from g2 where e1 >= 100 and e1 < 120");
- test.assertRowCount(0);
- test.closeConnection();
- }
-}
16 years, 4 months
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
16 years, 4 months
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>
16 years, 4 months
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;
}
16 years, 4 months
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) {
16 years, 4 months
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
16 years, 4 months
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>
16 years, 4 months
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
16 years, 4 months
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>
16 years, 4 months
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);
-}
16 years, 4 months