001/* 002 * Copyright 2002-2012 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.beans.factory.parsing; 018 019import org.springframework.core.io.Resource; 020 021/** 022 * Simple strategy allowing tools to control how source metadata is attached 023 * to the bean definition metadata. 024 * 025 * <p>Configuration parsers <strong>may</strong> provide the ability to attach 026 * source metadata during the parse phase. They will offer this metadata in a 027 * generic format which can be further modified by a {@link SourceExtractor} 028 * before being attached to the bean definition metadata. 029 * 030 * @author Rob Harrop 031 * @author Juergen Hoeller 032 * @since 2.0 033 * @see org.springframework.beans.BeanMetadataElement#getSource() 034 * @see org.springframework.beans.factory.config.BeanDefinition 035 */ 036public interface SourceExtractor { 037 038 /** 039 * Extract the source metadata from the candidate object supplied 040 * by the configuration parser. 041 * @param sourceCandidate the original source metadata (never {@code null}) 042 * @param definingResource the resource that defines the given source object 043 * (may be {@code null}) 044 * @return the source metadata object to store (may be {@code null}) 045 */ 046 Object extractSource(Object sourceCandidate, Resource definingResource); 047 048}