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.araneaframework.backend.list.helper;
18:
19: import java.sql.Connection;
20: import java.sql.SQLException;
21:
22: /**
23: * Generic callback interface for code that operates on a CCI Connection.
24: * Allows to execute any number of operations on a single Connection,
25: * using any type and number of Interaction.
26: *
27: * <p>This is particularly useful for delegating to existing data access code
28: * that expects a Connection to work on and throws ResourceException. For newly
29: * written code, it is strongly recommended to use CciTemplate's more specific
30: * <code>execute</code> variants.
31: *
32: * @author Thierry Templier
33: * @author Juergen Hoeller
34: */
35: public interface ConnectionCallback {
36: /**
37: * Gets called by <code>CciTemplate.execute</code> with an active CCI Connection.
38: * Does not need to care about activating or closing the Connection, or handling
39: * transactions.
40: *
41: * <p>If called without a thread-bound CCI transaction (initiated by
42: * CciLocalTransactionManager), the code will simply get executed on the CCI
43: * Connection with its transactional semantics. If CciTemplate is configured
44: * to use a JTA-aware ConnectionFactory, the CCI Connection and thus the callback
45: * code will be transactional if a JTA transaction is active.
46: *
47: * <p>Allows for returning a result object created within the callback, i.e.
48: * a domain object or a collection of domain objects. Note that there's special
49: * support for single step actions: see the <code>CciTemplate.execute</code>
50: * variants. A thrown RuntimeException is treated as application exception:
51: * it gets propagated to the caller of the template.
52: *
53: * @param con active CCI Connection
54: */
55: Object doInConnection(Connection con) throws SQLException;
56: }
|