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.transaction.support;
18:
19: import org.springframework.transaction.TransactionStatus;
20:
21: /**
22: * Simple convenience class for TransactionCallback implementation.
23: * Allows for implementing a doInTransaction version without result,
24: * i.e. without the need for a return statement.
25: *
26: * @author Juergen Hoeller
27: * @since 28.03.2003
28: * @see TransactionTemplate
29: */
30: public abstract class TransactionCallbackWithoutResult implements
31: TransactionCallback {
32:
33: public final Object doInTransaction(TransactionStatus status) {
34: doInTransactionWithoutResult(status);
35: return null;
36: }
37:
38: /**
39: * Gets called by TransactionTemplate.execute within a transactional context.
40: * Does not need to care about transactions itself, although it can retrieve
41: * and influence the status of the current transaction via the given status
42: * object, e.g. setting rollback-only.
43: *
44: * <p>A RuntimeException thrown by the callback is treated as application
45: * exception that enforces a rollback. An exception gets propagated to the
46: * caller of the template.
47: *
48: * <p>Note when using JTA: JTA transactions only work with transactional
49: * JNDI resources, so implementations need to use such resources if they
50: * want transaction support.
51: *
52: * @param status associated transaction status
53: * @see TransactionTemplate#execute
54: */
55: protected abstract void doInTransactionWithoutResult(
56: TransactionStatus status);
57:
58: }
|