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.interceptor;
  17. import java.lang.reflect.Method;
  18. /**
  19. * Very simple implementation of TransactionAttributeSource which will always return
  20. * the same TransactionAttribute for all methods fed to it. The TransactionAttribute
  21. * may be specified, but will otherwise default to PROPOGATION_REQUIRED. This may be
  22. * used in the cases where you want to use the same transaction attribute with all
  23. * methods being handled by a transaction interceptor.
  24. * @author Colin Sampaleanu
  25. * @since 15.10.2003
  26. * @version $Id: MatchAlwaysTransactionAttributeSource.java,v 1.5 2004/03/18 02:46:05 trisberg Exp $
  27. * @see org.springframework.transaction.interceptor.TransactionProxyFactoryBean
  28. * @see org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator
  29. */
  30. public class MatchAlwaysTransactionAttributeSource implements TransactionAttributeSource {
  31. private TransactionAttribute transactionAttribute = new DefaultTransactionAttribute();
  32. /**
  33. * Allows a transaction attribute to be specified, using the String form, for
  34. * example, "PROPOGATION_REQUIRED".
  35. * @param transactionAttribute The String form of the transactionAttribute to use.
  36. * @see org.springframework.transaction.interceptor.TransactionAttributeEditor
  37. */
  38. public void setTransactionAttribute(TransactionAttribute transactionAttribute) {
  39. this.transactionAttribute = transactionAttribute;
  40. }
  41. public TransactionAttribute getTransactionAttribute(Method method, Class targetClass) {
  42. return transactionAttribute;
  43. }
  44. }