Search in sources :

Example 1 with GlobalCacheQueryResponse

use of org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.GlobalCMDocumentCache.GlobalCacheQueryResponse in project webtools.sourceediting by eclipse.

the class CMDocumentManagerImpl method buildCMDocument.

public synchronized CMDocument buildCMDocument(String publicId, String resolvedURI, String type) {
    cmDocumentCache.setStatus(resolvedURI, CMDocumentCache.STATUS_LOADING);
    boolean documentCacheable = false;
    if (globalCMDocumentCacheEnabled) {
        GlobalCacheQueryResponse response = GlobalCMDocumentCache.getInstance().getCMDocument(resolvedURI);
        CMDocument cachedCMDocument = response.getCachedCMDocument();
        documentCacheable = response.isDocumentCacheable();
        if (cachedCMDocument != null) {
            cmDocumentCache.putCMDocument(resolvedURI, cachedCMDocument);
            return cachedCMDocument;
        }
    }
    CMDocument result = null;
    if (resolvedURI != null && resolvedURI.length() > 0) {
        // TODO... pass the TYPE thru to the CMDocumentBuilder
        result = ContentModelManager.getInstance().createCMDocument(resolvedURI, type);
    }
    if (result != null) {
        // load the annotation files for the document
        if (publicId != null) {
            AnnotationUtility.loadAnnotationsForGrammar(publicId, result);
        }
        if (globalCMDocumentCacheEnabled && documentCacheable) {
            GlobalCMDocumentCache.getInstance().putCMDocument(resolvedURI, result);
        }
        cmDocumentCache.putCMDocument(resolvedURI, result);
    } else {
        cmDocumentCache.setStatus(resolvedURI, CMDocumentCache.STATUS_ERROR);
    }
    return result;
}
Also used : CMDocument(org.eclipse.wst.xml.core.internal.contentmodel.CMDocument) GlobalCacheQueryResponse(org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.GlobalCMDocumentCache.GlobalCacheQueryResponse)

Aggregations

CMDocument (org.eclipse.wst.xml.core.internal.contentmodel.CMDocument)1 GlobalCacheQueryResponse (org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.GlobalCMDocumentCache.GlobalCacheQueryResponse)1