1. /*
  2. * Copyright 2002-2004 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. package org.springframework.transaction;
  17. /**
  18. * Representation of the status of a transaction,
  19. * consisting of a transaction object and some status flags.
  20. *
  21. * <p>Transactional code can use this to retrieve status information,
  22. * and to programmatically request a rollback (instead of throwing
  23. * an exception that causes an implicit rollback).
  24. *
  25. * @author Juergen Hoeller
  26. * @since 27.03.2003
  27. * @see PlatformTransactionManager
  28. * @see org.springframework.transaction.support.TransactionCallback#doInTransaction
  29. * @see org.springframework.transaction.interceptor.TransactionInterceptor#currentTransactionStatus
  30. * @see #setRollbackOnly
  31. * @version $Id: TransactionStatus.java,v 1.5 2004/03/18 02:46:10 trisberg Exp $
  32. */
  33. public interface TransactionStatus {
  34. /**
  35. * Return if the transaction is new,
  36. * else participating in an existing transaction.
  37. */
  38. boolean isNewTransaction();
  39. /**
  40. * Set the transaction rollback-only. This instructs the transaction manager
  41. * that the only possible outcome of the transaction may be a rollback,
  42. * proceeding with the normal applicaiton workflow though (i.e. no exception).
  43. * <p>For transactions managed by TransactionTemplate or TransactionInterceptor.
  44. * An alternative way to trigger a rollback is throwing an application exception.
  45. * @see org.springframework.transaction.support.TransactionCallback#doInTransaction
  46. * @see org.springframework.transaction.interceptor.TransactionAttribute#rollbackOn
  47. */
  48. void setRollbackOnly();
  49. /**
  50. * Return if the transaction has been set rollback-only.
  51. */
  52. public boolean isRollbackOnly();
  53. }