Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 39827 Details for
Bug 139092
CMDocumentManagerImpl.getCMDocument(....) is taking too much time loading the same dtd file , its not caching it.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
patch
bug 139092.txt (text/plain), 5.20 KB, created by
Raj Mandayam
on 2006-04-28 16:14:29 EDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Raj Mandayam
Created:
2006-04-28 16:14:29 EDT
Size:
5.20 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.wst.xml.core >Index: src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/CMDocumentManagerImpl.java >=================================================================== >RCS file: /cvsroot/webtools/wst/components/xml/plugins/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/CMDocumentManagerImpl.java,v >retrieving revision 1.4 >diff -u -r1.4 CMDocumentManagerImpl.java >--- src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/CMDocumentManagerImpl.java 1 Nov 2005 19:43:27 -0000 1.4 >+++ src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/modelqueryimpl/CMDocumentManagerImpl.java 28 Apr 2006 20:08:51 -0000 >@@ -255,16 +255,24 @@ > x++; > if (resolvedURI != null && resolvedURI.length() > 0) > { >- // TODO... pass the TYPE thru to the CMDocumentBuilder >- result = ContentModelManager.getInstance().createCMDocument(resolvedURI, type); >+ // try to get from cache >+ result = CMDocumentCache.getCachedDocument(resolvedURI); >+ if(result == null){ >+ // TODO... pass the TYPE thru to the CMDocumentBuilder >+ result = ContentModelManager.getInstance().createCMDocument(resolvedURI, type); >+ >+ // load the annotation files for the document >+ if (publicId != null) >+ { >+ AnnotationUtility.loadAnnotationsForGrammar(publicId, result); >+ } >+ if(result != null) >+ CMDocumentCache.putCachedCMDocument(resolvedURI, result); >+ >+ } > } > if (result != null) > { >- // load the annotation files for the document >- if (publicId != null) >- { >- AnnotationUtility.loadAnnotationsForGrammar(publicId, result); >- } > cmDocumentCache.putCMDocument(resolvedURI, result); > } > else >@@ -279,4 +287,4 @@ > // TODO... initiate a timed release of the entries in the CMDocumentCache > publicIdTable = new Hashtable(); > } >-} >+} >\ No newline at end of file >Index: src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/CMDocumentCache.java >=================================================================== >RCS file: /cvsroot/webtools/wst/components/xml/plugins/org.eclipse.wst.xml.core/src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/CMDocumentCache.java,v >retrieving revision 1.1 >diff -u -r1.1 CMDocumentCache.java >--- src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/CMDocumentCache.java 18 Mar 2005 18:22:58 -0000 1.1 >+++ src-contentmodel/org/eclipse/wst/xml/core/internal/contentmodel/util/CMDocumentCache.java 28 Apr 2006 20:08:51 -0000 >@@ -18,6 +18,10 @@ > import java.util.List; > import java.util.Vector; > >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.core.runtime.jobs.Job; > import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument; > > >@@ -32,6 +36,8 @@ > public static final int STATUS_LOADED = 3; > public static final int STATUS_ERROR = 4; > >+ >+ > protected class Entry > { > public String uri; >@@ -52,6 +58,31 @@ > } > } > >+ static class ReleaseModelsJob extends Job { >+ ReleaseModelsJob(){ >+ super("CMDocumentManager Release Models Job"); >+ } >+ >+ >+ >+ protected IStatus run(IProgressMonitor monitor) { >+ System.out.println("CMDocumentManager Release Models Job"); >+ int total = fCachedDocuments.size(); >+ monitor.beginTask("Releasing " + total + " models", total); >+ >+ // dont hold the reference to the releasedModels for too long >+ // that way there is no possiblity of deadlock during concurrent >+ // access >+ fCachedDocuments.clear(); >+ >+ monitor.done(); >+ return Status.OK_STATUS; >+ } >+} >+ >+private static Hashtable fCachedDocuments = new Hashtable(); >+private static ReleaseModelsJob discardJob; >+ > protected Hashtable hashtable; > protected List listenerList = new Vector(); > >@@ -200,4 +231,41 @@ > } > return list; > } >+ >+/** >+ * Gets the documents. >+ * >+ * @return Returns a Hashtable >+ */ >+public static Hashtable getCachedDocuments() { >+ if (fCachedDocuments == null){ >+ fCachedDocuments = new Hashtable(); >+ } >+ return fCachedDocuments; >+} >+ >+private static Job getDiscardJob() { >+ if (discardJob == null) { >+ discardJob = new ReleaseModelsJob(); >+ } >+ >+ return discardJob; >+} >+ >+public static CMDocument getCachedDocument(String resolvedURI) { >+ CMDocument result = (CMDocument) fCachedDocuments.get(resolvedURI); >+ if(result != null){ >+ // if a reference occurs delay release of cache by 60 seconds >+ getDiscardJob().cancel(); >+ getDiscardJob().schedule(60000); >+ } >+ return result; >+} >+ >+public static void putCachedCMDocument(String resolvedURI, CMDocument result) { >+ fCachedDocuments.put(resolvedURI, result); >+ // if a reference is added (start release/delay release if already started) of cache by 60 seconds >+ getDiscardJob().cancel(); >+ getDiscardJob().schedule(60000); > } >+} >\ No newline at end of file
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
thatnitind
:
review-
Actions:
View
Attachments on
bug 139092
:
39827