From 1c839dbe9c6d78f4dd962ad40ede569336c7c13c Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 12 Nov 2009 02:14:01 +0000 Subject: [PATCH] added setValidating method to AbstractXmlApplicationContext, analogous to GenericXmlApplicationContext --- .../support/AbstractXmlApplicationContext.java | 16 +++++++++++++++- .../support/GenericXmlApplicationContext.java | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/org.springframework.context/src/main/java/org/springframework/context/support/AbstractXmlApplicationContext.java b/org.springframework.context/src/main/java/org/springframework/context/support/AbstractXmlApplicationContext.java index 853cad3b59c..d0f44e92bc4 100644 --- a/org.springframework.context/src/main/java/org/springframework/context/support/AbstractXmlApplicationContext.java +++ b/org.springframework.context/src/main/java/org/springframework/context/support/AbstractXmlApplicationContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,6 +44,9 @@ import org.springframework.core.io.Resource; */ public abstract class AbstractXmlApplicationContext extends AbstractRefreshableConfigApplicationContext { + private boolean validating = false; + + /** * Create a new AbstractXmlApplicationContext with no parent. */ @@ -59,6 +62,14 @@ public abstract class AbstractXmlApplicationContext extends AbstractRefreshableC } + /** + * Set whether to use XML validation. Default is true. + */ + public void setValidating(boolean validating) { + this.validating = validating; + } + + /** * Loads the bean definitions via an XmlBeanDefinitionReader. * @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader @@ -90,6 +101,9 @@ public abstract class AbstractXmlApplicationContext extends AbstractRefreshableC * @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader#setDocumentReaderClass */ protected void initBeanDefinitionReader(XmlBeanDefinitionReader beanDefinitionReader) { + beanDefinitionReader.setValidationMode(this.validating ? + XmlBeanDefinitionReader.VALIDATION_AUTO : XmlBeanDefinitionReader.VALIDATION_NONE); + } /** diff --git a/org.springframework.context/src/main/java/org/springframework/context/support/GenericXmlApplicationContext.java b/org.springframework.context/src/main/java/org/springframework/context/support/GenericXmlApplicationContext.java index d4f759d4b70..6ae0d024448 100644 --- a/org.springframework.context/src/main/java/org/springframework/context/support/GenericXmlApplicationContext.java +++ b/org.springframework.context/src/main/java/org/springframework/context/support/GenericXmlApplicationContext.java @@ -69,7 +69,7 @@ public class GenericXmlApplicationContext extends GenericApplicationContext { /** - * Set whether to use XML validation. + * Set whether to use XML validation. Default is true. */ public void setValidating(boolean validating) { this.reader.setValidationMode(validating ?