1. /*
  2. * Copyright 2002-2004 the original author or authors.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.springframework.beans.factory.xml;
  17. import org.w3c.dom.Document;
  18. import org.springframework.beans.BeansException;
  19. import org.springframework.beans.factory.support.BeanDefinitionRegistry;
  20. import org.springframework.core.io.Resource;
  21. /**
  22. * Strategy interface for parsing XML bean definitions.
  23. * Used by XmlBeanDefinitionReader for actually parsing a DOM document.
  24. *
  25. * <p>Instantiated per document to parse: Implementations can hold state in
  26. * instance variables during the execution of the registerBeanDefinitions
  27. * method, for example global settings that are defined for all bean
  28. * definitions in the document.
  29. *
  30. * @author Juergen Hoeller
  31. * @since 18.12.2003
  32. * @see XmlBeanDefinitionReader#setParserClass
  33. */
  34. public interface XmlBeanDefinitionParser {
  35. /**
  36. * Parse bean definitions from the given DOM document,
  37. * and register them with the given bean factory.
  38. * @param beanFactory the bean factory to register the bean definitions with
  39. * @param beanClassLoader class loader to use for bean classes
  40. * (null suggests to not load bean classes but just register bean definitions
  41. * with class names, for example when just registering beans in a registry
  42. * but not actually instantiating them in a factory)
  43. * @param doc the DOM document
  44. * @param resource descriptor of the original XML resource
  45. * (useful for displaying parse errors)
  46. * @throws BeansException in case of parsing errors
  47. */
  48. void registerBeanDefinitions(BeanDefinitionRegistry beanFactory, ClassLoader beanClassLoader,
  49. Document doc, Resource resource) throws BeansException;
  50. }