|
|
|
@ -36,12 +36,6 @@ import org.apache.commons.logging.LogFactory; |
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.dao.DataAccessException; |
|
|
|
import org.springframework.dao.DataAccessException; |
|
|
|
import org.springframework.dao.DataAccessResourceFailureException; |
|
|
|
import org.springframework.dao.DataAccessResourceFailureException; |
|
|
|
import org.springframework.jca.cci.CannotCreateRecordException; |
|
|
|
|
|
|
|
import org.springframework.jca.cci.CciOperationNotSupportedException; |
|
|
|
|
|
|
|
import org.springframework.jca.cci.InvalidResultSetAccessException; |
|
|
|
|
|
|
|
import org.springframework.jca.cci.RecordTypeNotSupportedException; |
|
|
|
|
|
|
|
import org.springframework.jca.cci.connection.ConnectionFactoryUtils; |
|
|
|
|
|
|
|
import org.springframework.jca.cci.connection.NotSupportedRecordFactory; |
|
|
|
|
|
|
|
import org.springframework.lang.Nullable; |
|
|
|
import org.springframework.lang.Nullable; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
|
|
|
|
|
|
|
|
@ -68,7 +62,10 @@ import org.springframework.util.Assert; |
|
|
|
* @since 1.2 |
|
|
|
* @since 1.2 |
|
|
|
* @see RecordCreator |
|
|
|
* @see RecordCreator |
|
|
|
* @see RecordExtractor |
|
|
|
* @see RecordExtractor |
|
|
|
|
|
|
|
* @deprecated as of 5.3, in favor of specific data access APIs |
|
|
|
|
|
|
|
* (or native CCI usage if there is no alternative) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
public class CciTemplate implements CciOperations { |
|
|
|
public class CciTemplate implements CciOperations { |
|
|
|
|
|
|
|
|
|
|
|
private final Log logger = LogFactory.getLog(getClass()); |
|
|
|
private final Log logger = LogFactory.getLog(getClass()); |
|
|
|
@ -209,21 +206,25 @@ public class CciTemplate implements CciOperations { |
|
|
|
public <T> T execute(ConnectionCallback<T> action) throws DataAccessException { |
|
|
|
public <T> T execute(ConnectionCallback<T> action) throws DataAccessException { |
|
|
|
Assert.notNull(action, "Callback object must not be null"); |
|
|
|
Assert.notNull(action, "Callback object must not be null"); |
|
|
|
ConnectionFactory connectionFactory = obtainConnectionFactory(); |
|
|
|
ConnectionFactory connectionFactory = obtainConnectionFactory(); |
|
|
|
Connection con = ConnectionFactoryUtils.getConnection(connectionFactory, getConnectionSpec()); |
|
|
|
Connection con = org.springframework.jca.cci.connection.ConnectionFactoryUtils.getConnection( |
|
|
|
|
|
|
|
connectionFactory, getConnectionSpec()); |
|
|
|
try { |
|
|
|
try { |
|
|
|
return action.doInConnection(con, connectionFactory); |
|
|
|
return action.doInConnection(con, connectionFactory); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (NotSupportedException ex) { |
|
|
|
catch (NotSupportedException ex) { |
|
|
|
throw new CciOperationNotSupportedException("CCI operation not supported by connector", ex); |
|
|
|
throw new org.springframework.jca.cci.CciOperationNotSupportedException( |
|
|
|
|
|
|
|
"CCI operation not supported by connector", ex); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (ResourceException ex) { |
|
|
|
catch (ResourceException ex) { |
|
|
|
throw new DataAccessResourceFailureException("CCI operation failed", ex); |
|
|
|
throw new DataAccessResourceFailureException("CCI operation failed", ex); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (SQLException ex) { |
|
|
|
catch (SQLException ex) { |
|
|
|
throw new InvalidResultSetAccessException("Parsing of CCI ResultSet failed", ex); |
|
|
|
throw new org.springframework.jca.cci.InvalidResultSetAccessException( |
|
|
|
|
|
|
|
"Parsing of CCI ResultSet failed", ex); |
|
|
|
} |
|
|
|
} |
|
|
|
finally { |
|
|
|
finally { |
|
|
|
ConnectionFactoryUtils.releaseConnection(con, getConnectionFactory()); |
|
|
|
org.springframework.jca.cci.connection.ConnectionFactoryUtils.releaseConnection( |
|
|
|
|
|
|
|
con, getConnectionFactory()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -329,10 +330,12 @@ public class CciTemplate implements CciOperations { |
|
|
|
return recordFactory.createIndexedRecord(name); |
|
|
|
return recordFactory.createIndexedRecord(name); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (NotSupportedException ex) { |
|
|
|
catch (NotSupportedException ex) { |
|
|
|
throw new RecordTypeNotSupportedException("Creation of indexed Record not supported by connector", ex); |
|
|
|
throw new org.springframework.jca.cci.RecordTypeNotSupportedException( |
|
|
|
|
|
|
|
"Creation of indexed Record not supported by connector", ex); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (ResourceException ex) { |
|
|
|
catch (ResourceException ex) { |
|
|
|
throw new CannotCreateRecordException("Creation of indexed Record failed", ex); |
|
|
|
throw new org.springframework.jca.cci.CannotCreateRecordException( |
|
|
|
|
|
|
|
"Creation of indexed Record failed", ex); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -350,10 +353,12 @@ public class CciTemplate implements CciOperations { |
|
|
|
return recordFactory.createMappedRecord(name); |
|
|
|
return recordFactory.createMappedRecord(name); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (NotSupportedException ex) { |
|
|
|
catch (NotSupportedException ex) { |
|
|
|
throw new RecordTypeNotSupportedException("Creation of mapped Record not supported by connector", ex); |
|
|
|
throw new org.springframework.jca.cci.RecordTypeNotSupportedException( |
|
|
|
|
|
|
|
"Creation of mapped Record not supported by connector", ex); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (ResourceException ex) { |
|
|
|
catch (ResourceException ex) { |
|
|
|
throw new CannotCreateRecordException("Creation of mapped Record failed", ex); |
|
|
|
throw new org.springframework.jca.cci.CannotCreateRecordException( |
|
|
|
|
|
|
|
"Creation of mapped Record failed", ex); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -372,11 +377,12 @@ public class CciTemplate implements CciOperations { |
|
|
|
return recordCreator.createRecord(recordFactory); |
|
|
|
return recordCreator.createRecord(recordFactory); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (NotSupportedException ex) { |
|
|
|
catch (NotSupportedException ex) { |
|
|
|
throw new RecordTypeNotSupportedException( |
|
|
|
throw new org.springframework.jca.cci.RecordTypeNotSupportedException( |
|
|
|
"Creation of the desired Record type not supported by connector", ex); |
|
|
|
"Creation of the desired Record type not supported by connector", ex); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (ResourceException ex) { |
|
|
|
catch (ResourceException ex) { |
|
|
|
throw new CannotCreateRecordException("Creation of the desired Record failed", ex); |
|
|
|
throw new org.springframework.jca.cci.CannotCreateRecordException( |
|
|
|
|
|
|
|
"Creation of the desired Record failed", ex); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -396,7 +402,7 @@ public class CciTemplate implements CciOperations { |
|
|
|
return connectionFactory.getRecordFactory(); |
|
|
|
return connectionFactory.getRecordFactory(); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (NotSupportedException ex) { |
|
|
|
catch (NotSupportedException ex) { |
|
|
|
return new NotSupportedRecordFactory(); |
|
|
|
return new org.springframework.jca.cci.connection.NotSupportedRecordFactory(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|