001/*
002 * Copyright 2002-2019 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.transaction.interceptor;
018
019import java.lang.reflect.Method;
020
021/**
022 * Strategy interface used by {@link TransactionInterceptor} for metadata retrieval.
023 *
024 * <p>Implementations know how to source transaction attributes, whether from configuration,
025 * metadata attributes at source level (such as Java 5 annotations), or anywhere else.
026 *
027 * @author Rod Johnson
028 * @author Juergen Hoeller
029 * @since 15.04.2003
030 * @see TransactionInterceptor#setTransactionAttributeSource
031 * @see TransactionProxyFactoryBean#setTransactionAttributeSource
032 * @see org.springframework.transaction.annotation.AnnotationTransactionAttributeSource
033 */
034public interface TransactionAttributeSource {
035
036        /**
037         * Return the transaction attribute for the given method,
038         * or {@code null} if the method is non-transactional.
039         * @param method the method to introspect
040         * @param targetClass the target class (may be {@code null},
041         * in which case the declaring class of the method must be used)
042         * @return the matching transaction attribute, or {@code null} if none found
043         */
044        TransactionAttribute getTransactionAttribute(Method method, Class<?> targetClass);
045
046}