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.core; 018 019import javax.resource.ResourceException; 020import javax.resource.cci.Record; 021import javax.resource.cci.RecordFactory; 022 023import org.springframework.dao.DataAccessException; 024 025/** 026 * Callback interface for creating a CCI Record instance, 027 * usually based on the passed-in CCI RecordFactory. 028 * 029 * <p>Used for input Record creation in CciTemplate. Alternatively, 030 * Record instances can be passed into CciTemplate's corresponding 031 * {@code execute} methods directly, either instantiated manually 032 * or created through CciTemplate's Record factory methods. 033 * 034 * <P>Also used for creating default output Records in CciTemplate. 035 * This is useful when the JCA connector needs an explicit output Record 036 * instance, but no output Records should be passed into CciTemplate's 037 * {@code execute} methods. 038 * 039 * @author Thierry Templier 040 * @author Juergen Hoeller 041 * @since 1.2 042 * @see CciTemplate#execute(javax.resource.cci.InteractionSpec, RecordCreator) 043 * @see CciTemplate#execute(javax.resource.cci.InteractionSpec, RecordCreator, RecordExtractor) 044 * @see CciTemplate#createIndexedRecord(String) 045 * @see CciTemplate#createMappedRecord(String) 046 * @see CciTemplate#setOutputRecordCreator(RecordCreator) 047 */ 048public interface RecordCreator { 049 050 /** 051 * Create a CCI Record instance, usually based on the passed-in CCI RecordFactory. 052 * <p>For use as <i>input</i> creator with CciTemplate's {@code execute} methods, 053 * this method should create a <i>populated</i> Record instance. For use as 054 * <i>output</i> Record creator, it should return an <i>empty</i> Record instance. 055 * @param recordFactory the CCI RecordFactory (never {@code null}, but not guaranteed to be 056 * supported by the connector: its create methods might throw NotSupportedException) 057 * @return the Record instance 058 * @throws ResourceException if thrown by a CCI method, to be auto-converted 059 * to a DataAccessException 060 * @throws DataAccessException in case of custom exceptions 061 */ 062 Record createRecord(RecordFactory recordFactory) throws ResourceException, DataAccessException; 063 064}