Author: rareddy
Date: 2010-09-03 18:20:34 -0400 (Fri, 03 Sep 2010)
New Revision: 2531
Modified:
branches/7.1.x/api/src/main/java/org/teiid/resource/spi/BasicManagedConnectionFactory.java
branches/7.1.x/api/src/main/java/org/teiid/resource/spi/WrappedConnection.java
branches/7.1.x/connectors/connector-file/src/main/java/org/teiid/resource/adapter/file/FileManagedConnectionFactory.java
branches/7.1.x/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesForceManagedConnectionFactory.java
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManager.java
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java
branches/7.1.x/engine/src/main/resources/org/teiid/dqp/i18n.properties
Log:
TEIID-1244: The Teiid based connection factories were not correctly wired in for the
managed connection, as seems to be regression at some point in the past, thus the issue.
The error is fixed now the connection management is done through the pool.
Modified:
branches/7.1.x/api/src/main/java/org/teiid/resource/spi/BasicManagedConnectionFactory.java
===================================================================
---
branches/7.1.x/api/src/main/java/org/teiid/resource/spi/BasicManagedConnectionFactory.java 2010-09-03
16:14:36 UTC (rev 2530)
+++
branches/7.1.x/api/src/main/java/org/teiid/resource/spi/BasicManagedConnectionFactory.java 2010-09-03
22:20:34 UTC (rev 2531)
@@ -47,11 +47,11 @@
private BasicResourceAdapter ra;
@Override
- public abstract Object createConnectionFactory() throws ResourceException;
+ public abstract BasicConnectionFactory createConnectionFactory() throws
ResourceException;
@Override
- public Object createConnectionFactory(ConnectionManager arg0) throws ResourceException
{
- return createConnectionFactory();
+ public Object createConnectionFactory(ConnectionManager cm) throws ResourceException {
+ return new WrappedConnectionFactory(createConnectionFactory(), cm, this);
}
@Override
Modified: branches/7.1.x/api/src/main/java/org/teiid/resource/spi/WrappedConnection.java
===================================================================
---
branches/7.1.x/api/src/main/java/org/teiid/resource/spi/WrappedConnection.java 2010-09-03
16:14:36 UTC (rev 2530)
+++
branches/7.1.x/api/src/main/java/org/teiid/resource/spi/WrappedConnection.java 2010-09-03
22:20:34 UTC (rev 2531)
@@ -69,5 +69,9 @@
public ResultSetInfo getResultSetInfo() throws ResourceException {
return this.mc.getConnection().getResultSetInfo();
}
+
+ public Connection unwrap() throws ResourceException {
+ return this.mc.getConnection();
+ }
}
Modified:
branches/7.1.x/connectors/connector-file/src/main/java/org/teiid/resource/adapter/file/FileManagedConnectionFactory.java
===================================================================
---
branches/7.1.x/connectors/connector-file/src/main/java/org/teiid/resource/adapter/file/FileManagedConnectionFactory.java 2010-09-03
16:14:36 UTC (rev 2530)
+++
branches/7.1.x/connectors/connector-file/src/main/java/org/teiid/resource/adapter/file/FileManagedConnectionFactory.java 2010-09-03
22:20:34 UTC (rev 2531)
@@ -37,7 +37,7 @@
private String parentDirectory;
@Override
- public Object createConnectionFactory() throws ResourceException {
+ public BasicConnectionFactory createConnectionFactory() throws ResourceException {
if (this.parentDirectory == null) {
throw new
InvalidPropertyException(UTIL.getString("parentdirectory_not_set"));
//$NON-NLS-1$
}
Modified:
branches/7.1.x/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesForceManagedConnectionFactory.java
===================================================================
---
branches/7.1.x/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesForceManagedConnectionFactory.java 2010-09-03
16:14:36 UTC (rev 2530)
+++
branches/7.1.x/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesForceManagedConnectionFactory.java 2010-09-03
22:20:34 UTC (rev 2531)
@@ -95,7 +95,7 @@
}
@Override
- public Object createConnectionFactory() throws ResourceException {
+ public BasicConnectionFactory createConnectionFactory() throws ResourceException {
return new BasicConnectionFactory() {
@Override
public SalesforceConnectionImpl getConnection() throws ResourceException {
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManager.java
===================================================================
---
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManager.java 2010-09-03
16:14:36 UTC (rev 2530)
+++
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManager.java 2010-09-03
22:20:34 UTC (rev 2531)
@@ -33,6 +33,7 @@
import javax.naming.InitialContext;
import javax.naming.NamingException;
+import javax.resource.ResourceException;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.util.Assertion;
@@ -51,6 +52,7 @@
import org.teiid.query.optimizer.capabilities.SourceCapabilities;
import org.teiid.query.optimizer.capabilities.SourceCapabilities.Scope;
import org.teiid.query.sql.lang.Command;
+import org.teiid.resource.spi.WrappedConnection;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.ExecutionFactory;
import org.teiid.translator.TranslatorException;
@@ -102,8 +104,18 @@
MetadataFactory factory = new MetadataFactory(modelName, datatypes, importProperties);
Object connectionFactory = getConnectionFactory();
Object connection = executionFactory.getConnection(connectionFactory);
+ Object unwrapped = null;
+
+ if (connection instanceof WrappedConnection) {
+ try {
+ unwrapped = ((WrappedConnection)connection).unwrap();
+ } catch (ResourceException e) {
+ throw new
TranslatorException(DQPPlugin.Util.getString("failed_to_unwrap_connection"));
//$NON-NLS-1$
+ }
+ }
+
try {
- executionFactory.getMetadata(factory, connection);
+ executionFactory.getMetadata(factory, (unwrapped == null) ? connection:unwrapped);
} finally {
executionFactory.closeConnection(connection, connectionFactory);
}
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java
===================================================================
---
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java 2010-09-03
16:14:36 UTC (rev 2530)
+++
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java 2010-09-03
22:20:34 UTC (rev 2531)
@@ -27,6 +27,8 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
+import javax.resource.ResourceException;
+
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.common.buffer.BlockedException;
import org.teiid.common.buffer.TupleBuffer;
@@ -47,6 +49,7 @@
import org.teiid.query.metadata.TempMetadataStore;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.resource.spi.WrappedConnection;
import org.teiid.translator.DataNotAvailableException;
import org.teiid.translator.Execution;
import org.teiid.translator.ExecutionFactory;
@@ -193,6 +196,16 @@
try {
this.connectionFactory = this.manager.getConnectionFactory();
this.connection = this.connector.getConnection(this.connectionFactory);
+
+ Object unwrapped = null;
+ if (connection instanceof WrappedConnection) {
+ try {
+ unwrapped = ((WrappedConnection)connection).unwrap();
+ } catch (ResourceException e) {
+ throw new
TranslatorException(DQPPlugin.Util.getString("failed_to_unwrap_connection"));
//$NON-NLS-1$
+ }
+ }
+
// Translate the command
Command command = this.requestMsg.getCommand();
this.expectedColumns = command.getProjectedSymbols().size();
@@ -202,7 +215,7 @@
RuntimeMetadata rmd = new RuntimeMetadataImpl(queryMetadata);
// Create the execution based on mode
- final Execution exec = connector.createExecution(this.translatedCommand,
this.securityContext, rmd, this.connection);
+ final Execution exec = connector.createExecution(this.translatedCommand,
this.securityContext, rmd, (unwrapped == null) ? this.connection:unwrapped);
if (this.translatedCommand instanceof Call) {
this.execution = Assertion.isInstanceOf(exec, ProcedureExecution.class,
"Call Executions are expected to be ProcedureExecutions"); //$NON-NLS-1$
StoredProcedure proc = (StoredProcedure)command;
Modified: branches/7.1.x/engine/src/main/resources/org/teiid/dqp/i18n.properties
===================================================================
--- branches/7.1.x/engine/src/main/resources/org/teiid/dqp/i18n.properties 2010-09-03
16:14:36 UTC (rev 2530)
+++ branches/7.1.x/engine/src/main/resources/org/teiid/dqp/i18n.properties 2010-09-03
22:20:34 UTC (rev 2531)
@@ -524,4 +524,5 @@
RequestWorkItem.cache_nondeterministic=Caching command '{0}'' at a session
level, but less deterministic functions were evaluated.
not_found_cache=Results not found in cache
-failed_to_put_in_cache=Failed to put results in the cache
\ No newline at end of file
+failed_to_put_in_cache=Failed to put results in the cache
+failed_to_unwrap_connection=Failed to unwrap the source connection.
\ No newline at end of file
Show replies by date