MappingRecordOperation (Spring Framework 3.2.1.RELEASE API)
Date: 2013-01-24

org.springframework.jca.cci.object

## Class MappingRecordOperation

- java.lang.Object
- - org.springframework.jca.cci.object.EisOperation
  - - org.springframework.jca.cci.object.MappingRecordOperation

- All Implemented Interfaces:
    InitializingBean
  Direct Known Subclasses:
    MappingCommAreaOperation

      public abstract class MappingRecordOperation
      extends EisOperation

  EIS operation object that expects mapped input and output objects, converting to and from CCI Records.

  Concrete subclasses must implement the abstract `createInputRecord(RecordFactory, Object)` and `extractOutputData(Record)` methods, to create an input Record from an object and to convert an output Record into an object, respectively.

  Since:
    1.2
  Author:
    Thierry Templier, Juergen Hoeller
  See Also:
    `createInputRecord(javax.resource.cci.RecordFactory, Object)`, `extractOutputData(javax.resource.cci.Record)`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected class` | `MappingRecordOperation.RecordCreatorImpl` Implementation of RecordCreator that calls the enclosing class's `createInputRecord` method.
    `protected class` | `MappingRecordOperation.RecordExtractorImpl` Implementation of RecordExtractor that calls the enclosing class's `extractOutputData` method.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MappingRecordOperation()` Constructor that allows use as a JavaBean.
    `MappingRecordOperation(ConnectionFactory connectionFactory, InteractionSpec interactionSpec)` Convenient constructor with ConnectionFactory and specifications (connection and interaction).

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract Record` | `createInputRecord(RecordFactory recordFactory, Object inputObject)` Subclasses must implement this method to generate an input Record from an input object passed into the `execute` method.
    `Object` | `execute(Object inputObject)` Execute the interaction encapsulated by this operation object.
    `protected abstract Object` | `extractOutputData(Record outputRecord)` Subclasses must implement this method to convert the Record returned by CCI execution into a result object for the `execute` method.
    `void` | `setOutputRecordCreator(RecordCreator creator)` Set a RecordCreator that should be used for creating default output Records.

    - ### Methods inherited from class org.springframework.jca.cci.object.EisOperation

      `afterPropertiesSet, getCciTemplate, getInteractionSpec, setCciTemplate, setConnectionFactory, setInteractionSpec`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### MappingRecordOperation

          public MappingRecordOperation()

      Constructor that allows use as a JavaBean.

    - #### MappingRecordOperation

          public MappingRecordOperation(ConnectionFactory connectionFactory,
                                InteractionSpec interactionSpec)

      Convenient constructor with ConnectionFactory and specifications (connection and interaction).
      Parameters:
        `connectionFactory` - ConnectionFactory to use to obtain connections

  - ### Method Detail

    - #### setOutputRecordCreator

          public void setOutputRecordCreator(RecordCreator creator)

      Set a RecordCreator that should be used for creating default output Records.

      Default is none: CCI's `Interaction.execute` variant that returns an output Record will be called.

      Specify a RecordCreator here if you always need to call CCI's `Interaction.execute` variant with a passed-in output Record. This RecordCreator will then be invoked to create a default output Record instance.

      See Also:
        `Interaction.execute(javax.resource.cci.InteractionSpec, Record)`, `Interaction.execute(javax.resource.cci.InteractionSpec, Record, Record)`, `CciTemplate.setOutputRecordCreator(org.springframework.jca.cci.core.RecordCreator)`

    - #### execute

          public Object execute(Object inputObject)
                         throws DataAccessException

      Execute the interaction encapsulated by this operation object.
      Parameters:
        `inputObject` - the input data, to be converted to a Record by the `createInputRecord` method
      Returns:
        the output data extracted with the `extractOutputData` method
      Throws:
        `DataAccessException` - if there is any problem
      See Also:
        `createInputRecord(javax.resource.cci.RecordFactory, java.lang.Object)`, `extractOutputData(javax.resource.cci.Record)`

    - #### createInputRecord

          protected abstract Record createInputRecord(RecordFactory recordFactory,
                                 Object inputObject)
                                               throws ResourceException,
                                                      DataAccessException

      Subclasses must implement this method to generate an input Record from an input object passed into the `execute` method.
      Parameters:
        `inputObject` - the passed-in input object
      Returns:
        the CCI input Record
      Throws:
        `ResourceException` - if thrown by a CCI method, to be auto-converted to a DataAccessException
        `DataAccessException`
      See Also:
        `execute(Object)`

    - #### extractOutputData

          protected abstract Object extractOutputData(Record outputRecord)
                                               throws ResourceException,
                                                      SQLException,
                                                      DataAccessException

      Subclasses must implement this method to convert the Record returned by CCI execution into a result object for the `execute` method.
      Parameters:
        `outputRecord` - the Record returned by CCI execution
      Returns:
        the result object
      Throws:
        `ResourceException` - if thrown by a CCI method, to be auto-converted to a DataAccessException
        `SQLException`
        `DataAccessException`
      See Also:
        `execute(Object)`