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.beans.BeanMetadataElement; 020import org.springframework.core.io.Resource; 021import org.springframework.util.Assert; 022 023/** 024 * Representation of an import that has been processed during the parsing process. 025 * 026 * @author Juergen Hoeller 027 * @since 2.0 028 * @see ReaderEventListener#importProcessed(ImportDefinition) 029 */ 030public class ImportDefinition implements BeanMetadataElement { 031 032 private final String importedResource; 033 034 private final Resource[] actualResources; 035 036 private final Object source; 037 038 039 /** 040 * Create a new ImportDefinition. 041 * @param importedResource the location of the imported resource 042 */ 043 public ImportDefinition(String importedResource) { 044 this(importedResource, null, null); 045 } 046 047 /** 048 * Create a new ImportDefinition. 049 * @param importedResource the location of the imported resource 050 * @param source the source object (may be {@code null}) 051 */ 052 public ImportDefinition(String importedResource, Object source) { 053 this(importedResource, null, source); 054 } 055 056 /** 057 * Create a new ImportDefinition. 058 * @param importedResource the location of the imported resource 059 * @param source the source object (may be {@code null}) 060 */ 061 public ImportDefinition(String importedResource, Resource[] actualResources, Object source) { 062 Assert.notNull(importedResource, "Imported resource must not be null"); 063 this.importedResource = importedResource; 064 this.actualResources = actualResources; 065 this.source = source; 066 } 067 068 069 /** 070 * Return the location of the imported resource. 071 */ 072 public final String getImportedResource() { 073 return this.importedResource; 074 } 075 076 public final Resource[] getActualResources() { 077 return this.actualResources; 078 } 079 080 @Override 081 public final Object getSource() { 082 return this.source; 083 } 084 085}