[389963] URIResolver shared between new instances of a model
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/FileBufferModelManager.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/FileBufferModelManager.java index 6ae82d5..aad98e6 100644 --- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/FileBufferModelManager.java +++ b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/FileBufferModelManager.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2001, 2010 IBM Corporation and others. + * Copyright (c) 2001, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -53,6 +53,7 @@ import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; import org.eclipse.wst.sse.core.internal.provisional.exceptions.ResourceInUse; import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; +import org.eclipse.wst.sse.core.internal.util.URIResolverExtension; import org.eclipse.wst.sse.core.internal.util.URIResolver; /** @@ -102,7 +103,7 @@ /** * A URIResolver instance of models built on java.io.Files */ - static class ExternalURIResolver implements URIResolver { + static class ExternalURIResolver implements URIResolver, URIResolverExtension { IPath fLocation; ExternalURIResolver(IPath location) { @@ -164,13 +165,17 @@ public void setProject(IProject newProject) { } + + public URIResolver newInstance() { + return new ExternalURIResolver(fLocation != null ? (IPath) fLocation.clone() : null); + } } /** * A URIResolver instance of models built on the extensible WST URI * resolver */ - static class CommonURIResolver implements URIResolver { + static class CommonURIResolver implements URIResolver, URIResolverExtension { String fLocation; IPath fPath; private IProject fProject; @@ -182,6 +187,9 @@ fProject = workspaceFile.getProject(); } + private CommonURIResolver() { + } + public String getFileBaseLocation() { return fLocation; } @@ -245,6 +253,14 @@ public void setProject(IProject newProject) { fProject = newProject; } + + public URIResolver newInstance() { + CommonURIResolver resolver = new CommonURIResolver(); + resolver.fLocation = fLocation; + resolver.fPath = (IPath) fPath.clone(); + resolver.fProject = fProject; + return resolver; + } } /**
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/model/ModelManagerImpl.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/model/ModelManagerImpl.java index 82c1854..c195417 100644 --- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/model/ModelManagerImpl.java +++ b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/model/ModelManagerImpl.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2001, 2010 IBM Corporation and others. + * Copyright (c) 2001, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -80,6 +80,7 @@ import org.eclipse.wst.sse.core.internal.provisional.exceptions.ResourceInUse; import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; import org.eclipse.wst.sse.core.internal.util.Assert; +import org.eclipse.wst.sse.core.internal.util.URIResolverExtension; import org.eclipse.wst.sse.core.internal.util.ProjectResolver; import org.eclipse.wst.sse.core.internal.util.URIResolver; import org.eclipse.wst.sse.core.internal.util.Utilities; @@ -895,6 +896,9 @@ ((AbstractStructuredModel) newModel).setContentTypeIdentifier(oldModel.getContentTypeIdentifier()); } URIResolver oldResolver = oldModel.getResolver(); + if (oldResolver instanceof URIResolverExtension) { + oldResolver = ((URIResolverExtension) oldResolver).newInstance(); + } newModel.setResolver(oldResolver); try { newModel.setId(DUPLICATED_MODEL);
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/util/URIResolverExtension.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/util/URIResolverExtension.java new file mode 100644 index 0000000..31224ed --- /dev/null +++ b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/util/URIResolverExtension.java
@@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2012 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.sse.core.internal.util; + +/** + * Extension to the {@link URIResolver} interface. Implementing this interface + * allows for a new copy of the URIResolver to be created + * + */ +public interface URIResolverExtension { + /** + * Creates a new instance of the implementing {@link URIResolver} + * + * @return a new instance of the {@link URIResolver} + */ + URIResolver newInstance(); +}
diff --git a/features/org.eclipse.wst.xml_core.feature.patch/buildnotes_org.eclipse.wst.xml_core.feature.patch.html b/features/org.eclipse.wst.xml_core.feature.patch/buildnotes_org.eclipse.wst.xml_core.feature.patch.html index 0cb2086..ad16b36 100644 --- a/features/org.eclipse.wst.xml_core.feature.patch/buildnotes_org.eclipse.wst.xml_core.feature.patch.html +++ b/features/org.eclipse.wst.xml_core.feature.patch/buildnotes_org.eclipse.wst.xml_core.feature.patch.html
@@ -12,5 +12,6 @@ <p>Bug <a href='https://bugs.eclipse.org/376202'>376608</a>. XSI types not correctly supported in Content Model</p> <p>Bug <a href='https://bugs.eclipse.org/376220'>376914</a>. XSI types not correctly supported in Content Model - XSD component</p> <p>Bug <a href='https://bugs.eclipse.org/379984'>379984</a>. getAttributeNode in ElementImpl should not perform modifications on the document</p> +<p>Bug <a href='https://bugs.eclipse.org/389963'>389963</a>. URIResolver shared between new instances of a model</p> </body> -</head> \ No newline at end of file +</head>
diff --git a/features/org.eclipse.wst.xml_core.feature.patch/feature.properties b/features/org.eclipse.wst.xml_core.feature.patch/feature.properties index 7165742..3d76b75 100644 --- a/features/org.eclipse.wst.xml_core.feature.patch/feature.properties +++ b/features/org.eclipse.wst.xml_core.feature.patch/feature.properties
@@ -30,6 +30,7 @@ Bug https://bugs.eclipse.org/376608 XSI types not correctly supported in Content Model\n\ Bug https://bugs.eclipse.org/376914 XSI types not correctly supported in Content Model - XSD component\n\ Bug https://bugs.eclipse.org/379984 getAttributeNode in ElementImpl should not perform modifications on the document\n\ +Bug https://bugs.eclipse.org/389963 URIResolver shared between new instances of a model \n\ \n\ # "copyright" property - text of the "Feature Update Copyright" copyright=\