001/*
002 * Copyright 2002-2012 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.jca.cci.object;
018
019import javax.resource.cci.ConnectionFactory;
020import javax.resource.cci.InteractionSpec;
021import javax.resource.cci.Record;
022
023import org.springframework.dao.DataAccessException;
024
025/**
026 * EIS operation object that accepts a passed-in CCI input Record
027 * and returns a corresponding CCI output Record.
028 *
029 * @author Juergen Hoeller
030 * @since 1.2
031 */
032public class SimpleRecordOperation extends EisOperation {
033
034        /**
035         * Constructor that allows use as a JavaBean.
036         */
037        public SimpleRecordOperation() {
038        }
039
040        /**
041         * Convenient constructor with ConnectionFactory and specifications
042         * (connection and interaction).
043         * @param connectionFactory ConnectionFactory to use to obtain connections
044         */
045        public SimpleRecordOperation(ConnectionFactory connectionFactory, InteractionSpec interactionSpec) {
046                getCciTemplate().setConnectionFactory(connectionFactory);
047                setInteractionSpec(interactionSpec);
048        }
049
050        /**
051         * Execute the CCI interaction encapsulated by this operation object.
052         * <p>This method will call CCI's {@code Interaction.execute} variant
053         * that returns an output Record.
054         * @param inputRecord the input record
055         * @return the output record
056         * @throws DataAccessException if there is any problem
057         * @see javax.resource.cci.Interaction#execute(javax.resource.cci.InteractionSpec, Record)
058         */
059        public Record execute(Record inputRecord) throws DataAccessException {
060                return getCciTemplate().execute(getInteractionSpec(), inputRecord);
061        }
062
063        /**
064         * Execute the CCI interaction encapsulated by this operation object.
065         * <p>This method will call CCI's {@code Interaction.execute} variant
066         * with a passed-in output Record.
067         * @param inputRecord the input record
068         * @param outputRecord the output record
069         * @throws DataAccessException if there is any problem
070         * @see javax.resource.cci.Interaction#execute(javax.resource.cci.InteractionSpec, Record, Record)
071         */
072        public void execute(Record inputRecord, Record outputRecord) throws DataAccessException {
073                getCciTemplate().execute(getInteractionSpec(), inputRecord, outputRecord);
074        }
075
076}