1 16 17 package org.springframework.beans.factory.xml; 18 19 import org.springframework.beans.factory.config.BeanDefinition; 20 import org.springframework.beans.factory.parsing.ProblemReporter; 21 import org.springframework.beans.factory.parsing.ReaderContext; 22 import org.springframework.beans.factory.parsing.ReaderEventListener; 23 import org.springframework.beans.factory.parsing.SourceExtractor; 24 import org.springframework.beans.factory.support.BeanDefinitionRegistry; 25 import org.springframework.core.io.Resource; 26 27 36 public class XmlReaderContext extends ReaderContext { 37 38 private final XmlBeanDefinitionReader reader; 39 40 private final NamespaceHandlerResolver namespaceHandlerResolver; 41 42 43 public XmlReaderContext( 44 Resource resource, ProblemReporter problemReporter, 45 ReaderEventListener eventListener, SourceExtractor sourceExtractor, 46 XmlBeanDefinitionReader reader, NamespaceHandlerResolver namespaceHandlerResolver) { 47 48 super(resource, problemReporter, eventListener, sourceExtractor); 49 this.reader = reader; 50 this.namespaceHandlerResolver = namespaceHandlerResolver; 51 } 52 53 54 public final XmlBeanDefinitionReader getReader() { 55 return this.reader; 56 } 57 58 public final BeanDefinitionRegistry getRegistry() { 59 return this.reader.getBeanFactory(); 60 } 61 62 public final NamespaceHandlerResolver getNamespaceHandlerResolver() { 63 return this.namespaceHandlerResolver; 64 } 65 66 67 public String generateBeanName(BeanDefinition beanDefinition) { 68 return this.reader.getBeanNameGenerator().generateBeanName(beanDefinition, getRegistry()); 69 } 70 71 public String registerWithGeneratedName(BeanDefinition beanDefinition) { 72 String generatedName = generateBeanName(beanDefinition); 73 getRegistry().registerBeanDefinition(generatedName, beanDefinition); 74 return generatedName; 75 } 76 77 } 78 | Popular Tags |