KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > transaction > support > TransactionCallbackWithoutResult


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.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 TransactionCallback {
31
32     public final Object JavaDoc doInTransaction(TransactionStatus status) {
33         doInTransactionWithoutResult(status);
34         return null;
35     }
36
37     /**
38      * Gets called by TransactionTemplate.execute within a transactional context.
39      * Does not need to care about transactions itself, although it can retrieve
40      * and influence the status of the current transaction via the given status
41      * object, e.g. setting rollback-only.
42      *
43      * <p>A RuntimeException thrown by the callback is treated as application
44      * exception that enforces a rollback. An exception gets propagated to the
45      * caller of the template.
46      *
47      * <p>Note when using JTA: JTA transactions only work with transactional
48      * JNDI resources, so implementations need to use such resources if they
49      * want transaction support.
50      *
51      * @param status associated transaction status
52      * @see TransactionTemplate#execute
53      */

54     protected abstract void doInTransactionWithoutResult(TransactionStatus status);
55
56 }
57
Popular Tags