Author: oheger
Date: Sun Jun 8 18:25:47 2014
New Revision: 1601241
URL: http://svn.apache.org/r1601241
Log:
XMLConfiguration no longer implements the EntityRegistry interface.
It is now expected that a fully initialized EntityResolver is passed to the
initialization parameters of a configuration builder.
Modified:
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/XMLConfiguration.java
commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestXMLConfiguration.java
Modified:
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/XMLConfiguration.java
URL:
http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/XMLConfiguration.java?rev=1601241&r1=1601240&r2=1601241&view=diff
==============================================================================
---
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/XMLConfiguration.java
(original)
+++
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/XMLConfiguration.java
Sun Jun 8 18:25:47 2014
@@ -46,7 +46,6 @@ import org.apache.commons.configuration.
import org.apache.commons.configuration.io.FileLocatorAware;
import org.apache.commons.configuration.io.InputStreamSupport;
import org.apache.commons.configuration.resolver.DefaultEntityResolver;
-import org.apache.commons.configuration.resolver.EntityRegistry;
import org.apache.commons.configuration.tree.ImmutableNode;
import org.apache.commons.configuration.tree.NodeTreeWalker;
import org.apache.commons.configuration.tree.ReferenceNodeHandler;
@@ -184,8 +183,7 @@ import org.xml.sax.helpers.DefaultHandle
* @version $Id$
*/
public class XMLConfiguration extends BaseHierarchicalConfiguration implements
- EntityRegistry, FileBasedConfiguration, FileLocatorAware,
- InputStreamSupport {
+ FileBasedConfiguration, FileLocatorAware, InputStreamSupport {
/**
* The serial version UID.
*/
@@ -1037,67 +1035,6 @@ public class XMLConfiguration extends Ba
}
/**
- * <p>
- * Registers the specified DTD URL for the specified public identifier.
- * </p>
- * <p>
- * {@code XMLConfiguration} contains an internal
- * {@code EntityResolver} implementation. This maps
- * {@code PUBLICID}'s to URLs (from which the resource will be
- * loaded). A common use case for this method is to register local URLs
- * (possibly computed at runtime by a class loader) for DTDs. This allows
- * the performance advantage of using a local version without having to
- * ensure every {@code SYSTEM} URI on every processed XML document is
- * local. This implementation provides only basic functionality. If more
- * sophisticated features are required, using
- * {@link #setDocumentBuilder(DocumentBuilder)} to set a custom
- * {@code DocumentBuilder} (which also can be initialized with a
- * custom {@code EntityResolver}) is recommended.
- * </p>
- * <p>
- * <strong>Note:</strong> This method will have no effect when a custom
- * {@code DocumentBuilder} has been set. (Setting a custom
- * {@code DocumentBuilder} overrides the internal implementation.)
- * </p>
- * <p>
- * <strong>Note:</strong> This method must be called before the
- * configuration is loaded. So the default constructor of
- * {@code XMLConfiguration} should be used, the location of the
- * configuration file set, {@code registerEntityId()} called, and
- * finally the {@code load()} method can be invoked.
- * </p>
- *
- * @param publicId Public identifier of the DTD to be resolved
- * @param entityURL The URL to use for reading this DTD
- * @throws IllegalArgumentException if the public ID is undefined
- * @since 1.5
- */
- @Override
- public void registerEntityId(String publicId, URL entityURL)
- {
- if (entityResolver instanceof EntityRegistry)
- {
- ((EntityRegistry) entityResolver).registerEntityId(publicId,
entityURL);
- }
- }
-
- /**
- * Returns a map with the entity IDs that have been registered using the
- * {@code registerEntityId()} method.
- *
- * @return a map with the registered entity IDs
- */
- @Override
- public Map<String, URL> getRegisteredEntities()
- {
- if (entityResolver instanceof EntityRegistry)
- {
- return ((EntityRegistry) entityResolver).getRegisteredEntities();
- }
- return new HashMap<String, URL>();
- }
-
- /**
* A concrete {@code BuilderVisitor} that can construct XML
* documents.
*/
Modified:
commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestXMLConfiguration.java
URL:
http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestXMLConfiguration.java?rev=1601241&r1=1601240&r2=1601241&view=diff
==============================================================================
---
commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestXMLConfiguration.java
(original)
+++
commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestXMLConfiguration.java
Sun Jun 8 18:25:47 2014
@@ -36,7 +36,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
-import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -1302,34 +1301,6 @@ public class TestXMLConfiguration
}
/**
- * Tests registering the publicId of a DTD.
- */
- @Test
- public void testRegisterEntityId() throws Exception
- {
- URL dtdURL = getClass().getResource("/properties.dtd");
- final String publicId =
"http://commons.apache.org/test/properties.dtd";
- conf = new XMLConfiguration();
- load(conf, "testDtd.xml");
- conf.setPublicID(publicId);
- saveTestConfig();
- XMLConfiguration checkConfig = new XMLConfiguration();
- checkConfig.registerEntityId(publicId, dtdURL);
- checkConfig.setValidating(true);
- load(checkConfig, testSaveConf.getAbsolutePath());
- ConfigurationAssert.assertConfigurationEquals(conf, checkConfig);
- }
-
- /**
- * Tries to register a null public ID. This should cause an exception.
- */
- @Test(expected = IllegalArgumentException.class)
- public void testRegisterEntityIdNull() throws IOException
- {
- conf.registerEntityId(null, new URL("http://commons.apache.org"));
- }
-
- /**
* Tests saving a configuration that was created from a hierarchical
* configuration. This test exposes bug CONFIGURATION-301.
*/