01: /*
02: * Copyright 2002-2007 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.transaction.support;
18:
19: import org.springframework.transaction.TransactionException;
20:
21: /**
22: * Interface specifying basic transaction execution operations.
23: * Implemented by {@link TransactionTemplate}. Not often used directly,
24: * but a useful option to enhance testability, as it can easily be
25: * mocked or stubbed.
26: *
27: * @author Juergen Hoeller
28: * @since 2.0.4
29: */
30: public interface TransactionOperations {
31:
32: /**
33: * Execute the action specified by the given callback object within a transaction.
34: * <p>Allows for returning a result object created within the transaction, that is,
35: * a domain object or a collection of domain objects. A RuntimeException thrown
36: * by the callback is treated as a fatal exception that enforces a rollback.
37: * Such an exception gets propagated to the caller of the template.
38: * @param action the callback object that specifies the transactional action
39: * @return a result object returned by the callback, or <code>null</code> if none
40: * @throws TransactionException in case of initialization, rollback, or system errors
41: */
42: Object execute(TransactionCallback action)
43: throws TransactionException;
44:
45: }
|