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;
18:
19: /**
20: * Representation of the status of a transaction.
21: *
22: * <p>Transactional code can use this to retrieve status information,
23: * and to programmatically request a rollback (instead of throwing
24: * an exception that causes an implicit rollback).
25: *
26: * <p>Derives from the SavepointManager interface to provide access
27: * to savepoint management facilities. Note that savepoint management
28: * is only available if supported by the underlying transaction manager.
29: *
30: * @author Juergen Hoeller
31: * @since 27.03.2003
32: * @see #setRollbackOnly()
33: * @see PlatformTransactionManager#getTransaction
34: * @see org.springframework.transaction.support.TransactionCallback#doInTransaction
35: * @see org.springframework.transaction.interceptor.TransactionInterceptor#currentTransactionStatus()
36: */
37: public interface TransactionStatus extends SavepointManager {
38:
39: /**
40: * Return whether the present transaction is new (else participating
41: * in an existing transaction, or potentially not running in an
42: * actual transaction in the first place).
43: */
44: boolean isNewTransaction();
45:
46: /**
47: * Return whether this transaction internally carries a savepoint,
48: * that is, has been created as nested transaction based on a savepoint.
49: * <p>This method is mainly here for diagnostic purposes, alongside
50: * {@link #isNewTransaction()}. For programmatic handling of custom
51: * savepoints, use SavepointManager's operations.
52: * @see #isNewTransaction()
53: * @see #createSavepoint
54: * @see #rollbackToSavepoint(Object)
55: * @see #releaseSavepoint(Object)
56: */
57: boolean hasSavepoint();
58:
59: /**
60: * Set the transaction rollback-only. This instructs the transaction manager
61: * that the only possible outcome of the transaction may be a rollback, as
62: * alternative to throwing an exception which would in turn trigger a rollback.
63: * <p>This is mainly intended for transactions managed by
64: * {@link org.springframework.transaction.support.TransactionTemplate} or
65: * {@link org.springframework.transaction.interceptor.TransactionInterceptor},
66: * where the actual commit/rollback decision is made by the container.
67: * @see org.springframework.transaction.support.TransactionCallback#doInTransaction
68: * @see org.springframework.transaction.interceptor.TransactionAttribute#rollbackOn
69: */
70: void setRollbackOnly();
71:
72: /**
73: * Return whether the transaction has been marked as rollback-only
74: * (either by the application or by the transaction infrastructure).
75: */
76: boolean isRollbackOnly();
77:
78: /**
79: * Return whether this transaction is completed, that is,
80: * whether it has already been committed or rolled back.
81: * @see PlatformTransactionManager#commit
82: * @see PlatformTransactionManager#rollback
83: */
84: boolean isCompleted();
85:
86: }
|