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. * This is the central interface in Spring's transaction support.
  19. * Applications can use this directly, but it is not primarily meant as API.
  20. * Typically, applications will work with either TransactionTemplate or the
  21. * AOP transaction interceptor.
  22. *
  23. * <p>For implementers, AbstractPlatformTransactionManager is a good starting
  24. * point. The default implementations are DataSourceTransactionManager and
  25. * JtaTransactionManager.
  26. *
  27. * @author Rod Johnson
  28. * @author Juergen Hoeller
  29. * @since 16-Mar-2003
  30. * @version $Revision: 1.2 $
  31. * @see org.springframework.transaction.support.TransactionTemplate
  32. * @see org.springframework.transaction.interceptor.TransactionInterceptor
  33. * @see org.springframework.transaction.support.AbstractPlatformTransactionManager
  34. * @see org.springframework.jdbc.datasource.DataSourceTransactionManager
  35. * @see org.springframework.transaction.jta.JtaTransactionManager
  36. */
  37. public interface PlatformTransactionManager {
  38. /**
  39. * Return a currently active transaction or create a new one.
  40. * Note that parameters like isolation level or timeout will only be applied
  41. * to new transactions, and thus be ignored when participating in active ones.
  42. * Furthermore, they aren't supported by every transaction manager:
  43. * A proper implementation should thrown an exception when custom values
  44. * that it doesn't support are specified.
  45. * @param definition TransactionDefinition instance (can be null for defaults),
  46. * describing propagation behavior, isolation level, timeout etc.
  47. * @return transaction status object representing the new or current transaction
  48. * @throws TransactionException in case of lookup, creation, or system errors
  49. */
  50. TransactionStatus getTransaction(TransactionDefinition definition)
  51. throws TransactionException;
  52. /**
  53. * Commit the given transaction, with regard to its status.
  54. * If the transaction has been marked rollback-only programmatically,
  55. * perform a rollback.
  56. * If the transaction wasn't a new one, omit the commit
  57. * to take part in the surrounding transaction properly.
  58. * @param status object returned by the getTransaction() method.
  59. * @throws TransactionException in case of commit or system errors
  60. */
  61. void commit(TransactionStatus status) throws TransactionException;
  62. /**
  63. * Roll back the given transaction, with regard to its status.
  64. * If the transaction wasn't a new one, just set it rollback-only
  65. * to take part in the surrounding transaction properly.
  66. * @param status object returned by the getTransaction() method.
  67. * @throws TransactionException in case of system errors
  68. */
  69. void rollback(TransactionStatus status) throws TransactionException;
  70. }