01: /*
02: * Copyright 2002-2005 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.jca.cci.object;
18:
19: import javax.resource.cci.ConnectionFactory;
20: import javax.resource.cci.InteractionSpec;
21: import javax.resource.cci.Record;
22:
23: import org.springframework.dao.DataAccessException;
24:
25: /**
26: * EIS operation object that accepts a passed-in CCI input Record
27: * and returns a corresponding CCI output Record.
28: *
29: * @author Juergen Hoeller
30: * @since 1.2
31: */
32: public class SimpleRecordOperation extends EisOperation {
33:
34: /**
35: * Constructor that allows use as a JavaBean.
36: */
37: public SimpleRecordOperation() {
38: }
39:
40: /**
41: * Convenient constructor with ConnectionFactory and specifications
42: * (connection and interaction).
43: * @param connectionFactory ConnectionFactory to use to obtain connections
44: */
45: public SimpleRecordOperation(ConnectionFactory connectionFactory,
46: InteractionSpec interactionSpec) {
47: getCciTemplate().setConnectionFactory(connectionFactory);
48: setInteractionSpec(interactionSpec);
49: }
50:
51: /**
52: * Execute the CCI interaction encapsulated by this operation object.
53: * <p>This method will call CCI's <code>Interaction.execute</code> variant
54: * that returns an output Record.
55: * @param inputRecord the input record
56: * @return the output record
57: * @throws DataAccessException if there is any problem
58: * @see javax.resource.cci.Interaction#execute(javax.resource.cci.InteractionSpec, Record)
59: */
60: public Record execute(Record inputRecord)
61: throws DataAccessException {
62: return getCciTemplate().execute(getInteractionSpec(),
63: inputRecord);
64: }
65:
66: /**
67: * Execute the CCI interaction encapsulated by this operation object.
68: * <p>This method will call CCI's <code>Interaction.execute</code> variant
69: * with a passed-in output Record.
70: * @param inputRecord the input record
71: * @param outputRecord the output record
72: * @throws DataAccessException if there is any problem
73: * @see javax.resource.cci.Interaction#execute(javax.resource.cci.InteractionSpec, Record, Record)
74: */
75: public void execute(Record inputRecord, Record outputRecord)
76: throws DataAccessException {
77: getCciTemplate().execute(getInteractionSpec(), inputRecord,
78: outputRecord);
79: }
80:
81: }
|