KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > jca > cci > core > InteractionCallback


1 /*
2  * Copyright 2002-2005 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.core;
18
19 import java.sql.SQLException JavaDoc;
20
21 import javax.resource.ResourceException JavaDoc;
22 import javax.resource.cci.ConnectionFactory JavaDoc;
23 import javax.resource.cci.Interaction JavaDoc;
24
25 import org.springframework.dao.DataAccessException;
26
27 /**
28  * Generic callback interface for code that operates on a CCI Interaction.
29  * Allows to execute any number of operations on a single Interaction, for
30  * example a single execute call or repeated execute calls with varying
31  * parameters.
32  *
33  * <p>This is particularly useful for delegating to existing data access code
34  * that expects an Interaction to work on and throws ResourceException. For newly
35  * written code, it is strongly recommended to use CciTemplate's more specific
36  * <code>execute</code> variants.
37  *
38  * @author Thierry Templier
39  * @author Juergen Hoeller
40  * @since 1.2
41  * @see CciTemplate#execute(InteractionCallback)
42  * @see CciTemplate#execute(javax.resource.cci.InteractionSpec, javax.resource.cci.Record)
43  * @see CciTemplate#execute(javax.resource.cci.InteractionSpec, RecordCreator, RecordExtractor)
44  */

45 public interface InteractionCallback {
46
47     /**
48      * Gets called by <code>CciTemplate.execute</code> with an active CCI Interaction.
49      * Does not need to care about activating or closing the Interaction, or
50      * handling transactions.
51      *
52      * <p>If called without a thread-bound CCI transaction (initiated by
53      * CciLocalTransactionManager), the code will simply get executed on the CCI
54      * Interaction with its transactional semantics. If CciTemplate is configured
55      * to use a JTA-aware ConnectionFactory, the CCI Interaction and thus the callback
56      * code will be transactional if a JTA transaction is active.
57      *
58      * <p>Allows for returning a result object created within the callback, i.e.
59      * a domain object or a collection of domain objects. Note that there's special
60      * support for single step actions: see the <code>CciTemplate.execute</code>
61      * variants. A thrown RuntimeException is treated as application exception:
62      * it gets propagated to the caller of the template.
63      *
64      * @param interaction active CCI Interaction
65      * @param connectionFactory the CCI ConnectionFactory that the Connection was
66      * created with (gives access to RecordFactory and ResourceAdapterMetaData)
67      * @return a result object, or <code>null</code> if none
68      * @throws ResourceException if thrown by a CCI method, to be auto-converted
69      * to a DataAccessException
70      * @throws SQLException if thrown by a ResultSet method, to be auto-converted
71      * to a DataAccessException
72      * @throws DataAccessException in case of custom exceptions
73      * @see javax.resource.cci.ConnectionFactory#getRecordFactory()
74      * @see javax.resource.cci.ConnectionFactory#getMetaData()
75      * @see CciTemplate#execute(javax.resource.cci.InteractionSpec, RecordCreator, RecordExtractor)
76      */

77     Object JavaDoc doInInteraction(Interaction JavaDoc interaction, ConnectionFactory JavaDoc connectionFactory)
78             throws ResourceException JavaDoc, SQLException JavaDoc, DataAccessException;
79
80 }
81
Popular Tags