Author: rareddy
Date: 2010-09-14 11:15:57 -0400 (Tue, 14 Sep 2010)
New Revision: 2568
Modified:
branches/7.1.x/api/src/main/java/org/teiid/resource/spi/BasicManagedConnection.java
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/ConnectionRequestInfoWrapper.java
branches/7.1.x/api/src/main/java/org/teiid/resource/spi/WrappedConnectionFactory.java
Log:
TEIID-1244: The NPE was still occurring because in SOA, during the test connection
because, AS asking for a managed connection instead of the regular connection, thus it
does not take the same path as for getting connection. Fixed connection factory to handle
this method of calling.
Modified:
branches/7.1.x/api/src/main/java/org/teiid/resource/spi/BasicManagedConnection.java
===================================================================
---
branches/7.1.x/api/src/main/java/org/teiid/resource/spi/BasicManagedConnection.java 2010-09-14
15:01:53 UTC (rev 2567)
+++
branches/7.1.x/api/src/main/java/org/teiid/resource/spi/BasicManagedConnection.java 2010-09-14
15:15:57 UTC (rev 2568)
@@ -88,9 +88,6 @@
@Override
public Object getConnection(Subject arg0, ConnectionRequestInfo arg1) throws
ResourceException {
- if(!(arg1 instanceof ConnectionRequestInfoWrapper)) {
- throw new ResourceException("Un-recognized Connection Request Info object
received"); //$NON-NLS-1$
- }
ConnectionContext.setSubject(arg0);
WrappedConnection wc = new WrappedConnection(this);
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-14
15:01:53 UTC (rev 2567)
+++
branches/7.1.x/api/src/main/java/org/teiid/resource/spi/BasicManagedConnectionFactory.java 2010-09-14
15:15:57 UTC (rev 2568)
@@ -37,6 +37,7 @@
import javax.security.auth.Subject;
import org.teiid.core.TeiidException;
+import org.teiid.core.util.Assertion;
import org.teiid.core.util.ReflectionHelper;
@@ -45,20 +46,29 @@
private static final long serialVersionUID = -7302713800883776790L;
private PrintWriter log;
private BasicResourceAdapter ra;
+ private BasicConnectionFactory cf;
@Override
public abstract BasicConnectionFactory createConnectionFactory() throws
ResourceException;
@Override
public Object createConnectionFactory(ConnectionManager cm) throws ResourceException {
- return new WrappedConnectionFactory(createConnectionFactory(), cm, this);
+ this.cf = createConnectionFactory();
+ return new WrappedConnectionFactory(this.cf, cm, this);
}
@Override
public ManagedConnection createManagedConnection(Subject arg0, ConnectionRequestInfo
arg1) throws ResourceException {
- ConnectionRequestInfoWrapper criw = (ConnectionRequestInfoWrapper)arg1;
+ Assertion.isNotNull(this.cf);
ConnectionContext.setSubject(arg0);
- BasicConnection connection = criw.cf.getConnection();
+
+ BasicConnection connection = null;
+ if (arg1 instanceof ConnectionRequestInfoWrapper) {
+ connection = this.cf.getConnection(((ConnectionRequestInfoWrapper)arg1).cs);
+ }
+ else {
+ connection = this.cf.getConnection();
+ }
ConnectionContext.setSubject(null);
return new BasicManagedConnection(connection);
}
Modified:
branches/7.1.x/api/src/main/java/org/teiid/resource/spi/ConnectionRequestInfoWrapper.java
===================================================================
---
branches/7.1.x/api/src/main/java/org/teiid/resource/spi/ConnectionRequestInfoWrapper.java 2010-09-14
15:01:53 UTC (rev 2567)
+++
branches/7.1.x/api/src/main/java/org/teiid/resource/spi/ConnectionRequestInfoWrapper.java 2010-09-14
15:15:57 UTC (rev 2568)
@@ -21,12 +21,13 @@
*/
package org.teiid.resource.spi;
+import javax.resource.cci.ConnectionSpec;
import javax.resource.spi.ConnectionRequestInfo;
class ConnectionRequestInfoWrapper implements ConnectionRequestInfo {
- BasicConnectionFactory cf;
+ ConnectionSpec cs;
- public ConnectionRequestInfoWrapper(BasicConnectionFactory cf) {
- this.cf = cf;
+ public ConnectionRequestInfoWrapper(ConnectionSpec cs) {
+ this.cs = cs;
}
}
Modified:
branches/7.1.x/api/src/main/java/org/teiid/resource/spi/WrappedConnectionFactory.java
===================================================================
---
branches/7.1.x/api/src/main/java/org/teiid/resource/spi/WrappedConnectionFactory.java 2010-09-14
15:01:53 UTC (rev 2567)
+++
branches/7.1.x/api/src/main/java/org/teiid/resource/spi/WrappedConnectionFactory.java 2010-09-14
15:15:57 UTC (rev 2568)
@@ -50,7 +50,7 @@
@Override
public Connection getConnection() throws ResourceException {
- return (Connection)cm.allocateConnection(mcf, new
ConnectionRequestInfoWrapper(this.delegate));
+ return (Connection)cm.allocateConnection(mcf, null);
}
@@ -66,7 +66,7 @@
@Override
public Connection getConnection(ConnectionSpec arg0) throws ResourceException {
- return getConnection();
+ return (Connection)cm.allocateConnection(mcf, new ConnectionRequestInfoWrapper(arg0));
}
@Override
Show replies by date