001: /*
002: * Copyright 2002-2005 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: * http://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:
017: package org.springframework.jca.cci.core;
018:
019: import javax.resource.cci.InteractionSpec;
020: import javax.resource.cci.Record;
021:
022: import org.springframework.dao.DataAccessException;
023:
024: /**
025: * Interface that specifies a basic set of CCI operations on an EIS.
026: * Implemented by CciTemplate. Not often used, but a useful option
027: * to enhance testability, as it can easily be mocked or stubbed.
028: *
029: * <p>Alternatively, the standard CCI infrastructure can be mocked.
030: * However, mocking this interface constitutes significantly less work.
031: *
032: * @author Juergen Hoeller
033: * @since 1.2
034: * @see CciTemplate
035: */
036: public interface CciOperations {
037:
038: /**
039: * Execute a request on an EIS with CCI, implemented as callback action
040: * working on a CCI Connection. This allows for implementing arbitrary
041: * data access operations, within Spring's managed CCI environment:
042: * that is, participating in Spring-managed transactions and converting
043: * JCA ResourceExceptions into Spring's DataAccessException hierarchy.
044: * <p>The callback action can return a result object, for example a
045: * domain object or a collection of domain objects.
046: * @param action the callback object that specifies the action
047: * @return the result object returned by the action, if any
048: * @throws DataAccessException if there is any problem
049: */
050: Object execute(ConnectionCallback action)
051: throws DataAccessException;
052:
053: /**
054: * Execute a request on an EIS with CCI, implemented as callback action
055: * working on a CCI Interaction. This allows for implementing arbitrary
056: * data access operations on a single Interaction, within Spring's managed
057: * CCI environment: that is, participating in Spring-managed transactions
058: * and converting JCA ResourceExceptions into Spring's DataAccessException
059: * hierarchy.
060: * <p>The callback action can return a result object, for example a
061: * domain object or a collection of domain objects.
062: * @param action the callback object that specifies the action
063: * @return the result object returned by the action, if any
064: * @throws DataAccessException if there is any problem
065: */
066: Object execute(InteractionCallback action)
067: throws DataAccessException;
068:
069: /**
070: * Execute the specified interaction on an EIS with CCI.
071: * @param spec the CCI InteractionSpec instance that defines
072: * the interaction (connector-specific)
073: * @param inputRecord the input record
074: * @return the output record
075: * @throws DataAccessException if there is any problem
076: */
077: Record execute(InteractionSpec spec, Record inputRecord)
078: throws DataAccessException;
079:
080: /**
081: * Execute the specified interaction on an EIS with CCI.
082: * @param spec the CCI InteractionSpec instance that defines
083: * the interaction (connector-specific)
084: * @param inputRecord the input record
085: * @param outputRecord the output record
086: * @throws DataAccessException if there is any problem
087: */
088: void execute(InteractionSpec spec, Record inputRecord,
089: Record outputRecord) throws DataAccessException;
090:
091: /**
092: * Execute the specified interaction on an EIS with CCI.
093: * @param spec the CCI InteractionSpec instance that defines
094: * the interaction (connector-specific)
095: * @param inputCreator object that creates the input record to use
096: * @return the output record
097: * @throws DataAccessException if there is any problem
098: */
099: Record execute(InteractionSpec spec, RecordCreator inputCreator)
100: throws DataAccessException;
101:
102: /**
103: * Execute the specified interaction on an EIS with CCI.
104: * @param spec the CCI InteractionSpec instance that defines
105: * the interaction (connector-specific)
106: * @param inputRecord the input record
107: * @param outputExtractor object to convert the output record to a result object
108: * @return the output data extracted with the RecordExtractor object
109: * @throws DataAccessException if there is any problem
110: */
111: Object execute(InteractionSpec spec, Record inputRecord,
112: RecordExtractor outputExtractor) throws DataAccessException;
113:
114: /**
115: * Execute the specified interaction on an EIS with CCI.
116: * @param spec the CCI InteractionSpec instance that defines
117: * the interaction (connector-specific)
118: * @param inputCreator object that creates the input record to use
119: * @param outputExtractor object to convert the output record to a result object
120: * @return the output data extracted with the RecordExtractor object
121: * @throws DataAccessException if there is any problem
122: */
123: Object execute(InteractionSpec spec, RecordCreator inputCreator,
124: RecordExtractor outputExtractor) throws DataAccessException;
125:
126: }
|