View | Details | Raw Unified | Return to bug 244444
Collapse All | Expand All

(-)src/org/eclipse/wst/html/core/internal/modelquery/XHTMLAssociationProvider.java (-2 / +74 lines)
Lines 11-16 Link Here
11
package org.eclipse.wst.html.core.internal.modelquery;
11
package org.eclipse.wst.html.core.internal.modelquery;
12
12
13
13
14
import java.lang.ref.Reference;
15
import java.lang.ref.SoftReference;
16
import java.util.Collection;
17
import java.util.HashMap;
18
import java.util.HashSet;
19
import java.util.Map;
20
21
import org.eclipse.core.runtime.IConfigurationElement;
22
import org.eclipse.core.runtime.IExtension;
23
import org.eclipse.core.runtime.Platform;
14
import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver;
24
import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver;
15
import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
25
import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
16
import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManager;
26
import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManager;
Lines 26-31 Link Here
26
 * This class closely resemble XMLModelQueryAssociationProvider.
36
 * This class closely resemble XMLModelQueryAssociationProvider.
27
 */
37
 */
28
class XHTMLAssociationProvider extends XMLAssociationProvider {
38
class XHTMLAssociationProvider extends XMLAssociationProvider {
39
	
40
	/**
41
	 * set CACHE_FIXED_DOCUMENTS to false to test effects of not caching certain catalog-contributed schemas.
42
	 */
43
	private static final boolean CACHE_FIXED_DOCUMENTS = true;
44
	private static final String[] STANDARD_SCHEMA_BUNDLES = new String[] {"org.eclipse.wst.standard.schemas","org.eclipse.jst.standard.schemas"};
45
	private static final String XML_CATALOG_EXT_POINT = "org.eclipse.wst.xml.core.catalogContributions"; 
46
	private static Collection fFixedPublicIDs = null;
47
	private static Map fFixedCMDocuments = new HashMap();
29
48
30
	/**
49
	/**
31
	 * set USE_QUICK_CACHE to false to test effects of not caching at all.
50
	 * set USE_QUICK_CACHE to false to test effects of not caching at all.
Lines 59-64 Link Here
59
	public CMDocument getXHTMLCMDocument(String publicId, String systemId) {
78
	public CMDocument getXHTMLCMDocument(String publicId, String systemId) {
60
		if (idResolver == null)
79
		if (idResolver == null)
61
			return null;
80
			return null;
81
		
62
		String grammerURI = null;
82
		String grammerURI = null;
63
		if (USE_QUICK_CACHE) {
83
		if (USE_QUICK_CACHE) {
64
			/*
84
			/*
Lines 84-90 Link Here
84
104
85
		if (grammerURI == null)
105
		if (grammerURI == null)
86
			return null;
106
			return null;
87
107
		
108
		CMDocument cmDocument = null;
109
		if (CACHE_FIXED_DOCUMENTS) {
110
			Reference ref = (Reference) fFixedCMDocuments.get(publicId);
111
			if (ref != null) {
112
				cmDocument = (CMDocument) ref.get();
113
				if (cmDocument != null) {
114
					return cmDocument;
115
				}
116
			}
117
		}
118
		
88
		/*
119
		/*
89
		 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=88896
120
		 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=88896
90
		 * 
121
		 * 
Lines 105-111 Link Here
105
		 * grammerURI); CMDocument cmDocument =
136
		 * grammerURI); CMDocument cmDocument =
106
		 * documentManager.getCMDocument(publicId, grammerURI, "dtd");
137
		 * documentManager.getCMDocument(publicId, grammerURI, "dtd");
107
		 */
138
		 */
108
		CMDocument cmDocument = documentManager.getCMDocument(publicId, grammerURI, null);
139
		synchronized (grammerURI) {
140
			cmDocument = documentManager.getCMDocument(publicId, grammerURI, null);
141
		}
142
		
143
		if (CACHE_FIXED_DOCUMENTS && getFixedPublicIDs().contains(publicId)) {
144
			fFixedCMDocuments.put(publicId, new SoftReference(cmDocument));
145
		}
146
		
109
		return cmDocument;
147
		return cmDocument;
110
	}
148
	}
111
149
Lines 134-137 Link Here
134
	public String getCachedGrammerURI() {
172
	public String getCachedGrammerURI() {
135
		return fCachedGrammerURI;
173
		return fCachedGrammerURI;
136
	}
174
	}
175
176
	/**
177
	 * @return the fFixedPublicIDs, a collection of contributed Public
178
	 *         Identifiers from the known schema plug-ins.
179
	 */
180
	private static Collection getFixedPublicIDs() {
181
		/**
182
		 * public:publicId
183
		 * TODO: system:systemId and uri:name in their own methods and maps?
184
		 */
185
		synchronized (STANDARD_SCHEMA_BUNDLES) {
186
			if (fFixedPublicIDs == null) {
187
				fFixedPublicIDs = new HashSet();
188
				for (int i = 0; i < STANDARD_SCHEMA_BUNDLES.length; i++) {
189
					IExtension[] extensions = Platform.getExtensionRegistry().getExtensions(STANDARD_SCHEMA_BUNDLES[i]);
190
					for (int j = 0; j < extensions.length; j++) {
191
						if (XML_CATALOG_EXT_POINT.equals(extensions[j].getExtensionPointUniqueIdentifier())) {
192
							IConfigurationElement[] configurationElements = extensions[j].getConfigurationElements();
193
							for (int k = 0; k < configurationElements.length; k++) {
194
								IConfigurationElement[] publics = configurationElements[k].getChildren("public");
195
								for (int l = 0; l < publics.length; l++) {
196
									String publicId = publics[l].getAttribute("publicId");
197
									if (publicId != null && publicId.length() > 0) {
198
										fFixedPublicIDs.add(publicId);
199
									}
200
								}
201
							}
202
						}
203
					}
204
				}
205
			}
206
		}
207
		return fFixedPublicIDs;
208
	}
137
}
209
}

Return to bug 244444