001/*
002 * Copyright 2002-2015 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.core;
018
019import org.springframework.util.ClassUtils;
020
021/**
022 * Default implementation of the {@link ParameterNameDiscoverer} strategy interface,
023 * using the Java 8 standard reflection mechanism (if available), and falling back
024 * to the ASM-based {@link LocalVariableTableParameterNameDiscoverer} for checking
025 * debug information in the class file.
026 *
027 * <p>Further discoverers may be added through {@link #addDiscoverer(ParameterNameDiscoverer)}.
028 *
029 * @author Juergen Hoeller
030 * @since 4.0
031 * @see StandardReflectionParameterNameDiscoverer
032 * @see LocalVariableTableParameterNameDiscoverer
033 */
034public class DefaultParameterNameDiscoverer extends PrioritizedParameterNameDiscoverer {
035
036        private static final boolean standardReflectionAvailable = ClassUtils.isPresent(
037                        "java.lang.reflect.Executable", DefaultParameterNameDiscoverer.class.getClassLoader());
038
039
040        public DefaultParameterNameDiscoverer() {
041                if (standardReflectionAvailable) {
042                        addDiscoverer(new StandardReflectionParameterNameDiscoverer());
043                }
044                addDiscoverer(new LocalVariableTableParameterNameDiscoverer());
045        }
046
047}