提交 1c839dbe 编写于 作者: J Juergen Hoeller

added setValidating method to AbstractXmlApplicationContext, analogous to...

added setValidating method to AbstractXmlApplicationContext, analogous to GenericXmlApplicationContext
上级 08323346
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -44,6 +44,9 @@ import org.springframework.core.io.Resource; ...@@ -44,6 +44,9 @@ import org.springframework.core.io.Resource;
*/ */
public abstract class AbstractXmlApplicationContext extends AbstractRefreshableConfigApplicationContext { public abstract class AbstractXmlApplicationContext extends AbstractRefreshableConfigApplicationContext {
private boolean validating = false;
/** /**
* Create a new AbstractXmlApplicationContext with no parent. * Create a new AbstractXmlApplicationContext with no parent.
*/ */
...@@ -59,6 +62,14 @@ public abstract class AbstractXmlApplicationContext extends AbstractRefreshableC ...@@ -59,6 +62,14 @@ public abstract class AbstractXmlApplicationContext extends AbstractRefreshableC
} }
/**
* Set whether to use XML validation. Default is <code>true</code>.
*/
public void setValidating(boolean validating) {
this.validating = validating;
}
/** /**
* Loads the bean definitions via an XmlBeanDefinitionReader. * Loads the bean definitions via an XmlBeanDefinitionReader.
* @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader * @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader
...@@ -90,6 +101,9 @@ public abstract class AbstractXmlApplicationContext extends AbstractRefreshableC ...@@ -90,6 +101,9 @@ public abstract class AbstractXmlApplicationContext extends AbstractRefreshableC
* @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader#setDocumentReaderClass * @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader#setDocumentReaderClass
*/ */
protected void initBeanDefinitionReader(XmlBeanDefinitionReader beanDefinitionReader) { protected void initBeanDefinitionReader(XmlBeanDefinitionReader beanDefinitionReader) {
beanDefinitionReader.setValidationMode(this.validating ?
XmlBeanDefinitionReader.VALIDATION_AUTO : XmlBeanDefinitionReader.VALIDATION_NONE);
} }
/** /**
......
...@@ -69,7 +69,7 @@ public class GenericXmlApplicationContext extends GenericApplicationContext { ...@@ -69,7 +69,7 @@ public class GenericXmlApplicationContext extends GenericApplicationContext {
/** /**
* Set whether to use XML validation. * Set whether to use XML validation. Default is <code>true</code>.
*/ */
public void setValidating(boolean validating) { public void setValidating(boolean validating) {
this.reader.setValidationMode(validating ? this.reader.setValidationMode(validating ?
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册