Example usage for org.springframework.jca.cci.core RecordExtractor extractData

List of usage examples for org.springframework.jca.cci.core RecordExtractor extractData

Introduction

In this page you can find the example usage for org.springframework.jca.cci.core RecordExtractor extractData.

Prototype

@Nullable
T extractData(Record record) throws ResourceException, SQLException, DataAccessException;

Source Link

Document

Process the data in the given Record, creating a corresponding result object.

Usage

From source file:org.springframework.jca.cci.core.CciTemplate.java

/**
 * Execute the specified interaction on an EIS with CCI.
 * All other interaction execution methods go through this.
 * @param spec the CCI InteractionSpec instance that defines
 * the interaction (connector-specific)/*from  w w w . j av  a 2  s.c o  m*/
 * @param inputRecord the input record
 * @param outputRecord output record (can be {@code null})
 * @param outputExtractor object to convert the output record to a result object
 * @return the output data extracted with the RecordExtractor object
 * @throws DataAccessException if there is any problem
 */
@Nullable
protected <T> T doExecute(final InteractionSpec spec, final Record inputRecord,
        @Nullable final Record outputRecord, @Nullable final RecordExtractor<T> outputExtractor)
        throws DataAccessException {

    return execute((InteractionCallback<T>) (interaction, connectionFactory) -> {
        Record outputRecordToUse = outputRecord;
        try {
            if (outputRecord != null || getOutputRecordCreator() != null) {
                // Use the CCI execute method with output record as parameter.
                if (outputRecord == null) {
                    RecordFactory recordFactory = getRecordFactory(connectionFactory);
                    outputRecordToUse = getOutputRecordCreator().createRecord(recordFactory);
                }
                interaction.execute(spec, inputRecord, outputRecordToUse);
            } else {
                outputRecordToUse = interaction.execute(spec, inputRecord);
            }
            return (outputExtractor != null ? outputExtractor.extractData(outputRecordToUse) : null);
        } finally {
            if (outputRecordToUse instanceof ResultSet) {
                closeResultSet((ResultSet) outputRecordToUse);
            }
        }
    });
}