|
Lines 11-16
Link Here
|
| 11 |
package org.eclipse.equinox.internal.p2.updatesite; |
11 |
package org.eclipse.equinox.internal.p2.updatesite; |
| 12 |
|
12 |
|
| 13 |
import java.io.*; |
13 |
import java.io.*; |
|
|
14 |
import java.lang.ref.SoftReference; |
| 14 |
import java.net.*; |
15 |
import java.net.*; |
| 15 |
import java.util.HashMap; |
16 |
import java.util.HashMap; |
| 16 |
import java.util.Map; |
17 |
import java.util.Map; |
|
Lines 48-56
Link Here
|
| 48 |
* Some variables for caching. |
49 |
* Some variables for caching. |
| 49 |
*/ |
50 |
*/ |
| 50 |
// map of String (URI.toString()) to UpdateSite |
51 |
// map of String (URI.toString()) to UpdateSite |
| 51 |
private static Map<String, UpdateSite> siteCache = new HashMap<String, UpdateSite>(); |
52 |
private static Map<String, SoftReference<UpdateSite>> siteCache = new HashMap<String, SoftReference<UpdateSite>>(); |
| 52 |
// map of String (URI.toString()) to UpdateSite (for category xmls) |
53 |
// map of String (URI.toString()) to UpdateSite (for category xmls) |
| 53 |
private static Map<String, UpdateSite> categoryCache = new HashMap<String, UpdateSite>(); |
54 |
private static Map<String, SoftReference<UpdateSite>> categoryCache = new HashMap<String, SoftReference<UpdateSite>>(); |
| 54 |
// map of String (featureID_featureVersion) to Feature |
55 |
// map of String (featureID_featureVersion) to Feature |
| 55 |
private Map<String, Feature> featureCache = new HashMap<String, Feature>(); |
56 |
private Map<String, Feature> featureCache = new HashMap<String, Feature>(); |
| 56 |
|
57 |
|
|
Lines 81-89
Link Here
|
| 81 |
public static synchronized UpdateSite loadCategoryFile(URI location, IProgressMonitor monitor) throws ProvisionException { |
82 |
public static synchronized UpdateSite loadCategoryFile(URI location, IProgressMonitor monitor) throws ProvisionException { |
| 82 |
if (location == null) |
83 |
if (location == null) |
| 83 |
return null; |
84 |
return null; |
| 84 |
UpdateSite result = categoryCache.get(location.toString()); |
85 |
UpdateSite result = null; |
| 85 |
if (result != null) |
86 |
if (!PROTOCOL_FILE.equals(location.getScheme()) && categoryCache.containsKey(location.toString())) { |
| 86 |
return result; |
87 |
result = categoryCache.get(location.toString()).get(); |
|
|
88 |
if (result != null) |
| 89 |
return result; |
| 90 |
} |
| 87 |
InputStream input = null; |
91 |
InputStream input = null; |
| 88 |
File siteFile = loadActualSiteFile(location, location, monitor); |
92 |
File siteFile = loadActualSiteFile(location, location, monitor); |
| 89 |
try { |
93 |
try { |
|
Lines 93-99
Link Here
|
| 93 |
SiteModel siteModel = siteParser.parse(input); |
97 |
SiteModel siteModel = siteParser.parse(input); |
| 94 |
String checksumString = Long.toString(checksum.getValue()); |
98 |
String checksumString = Long.toString(checksum.getValue()); |
| 95 |
result = new UpdateSite(siteModel, location, checksumString); |
99 |
result = new UpdateSite(siteModel, location, checksumString); |
| 96 |
categoryCache.put(location.toString(), result); |
100 |
if (!PROTOCOL_FILE.equals(location.getScheme())) |
|
|
101 |
categoryCache.put(location.toString(), new SoftReference<UpdateSite>(result)); |
| 97 |
return result; |
102 |
return result; |
| 98 |
} catch (SAXException e) { |
103 |
} catch (SAXException e) { |
| 99 |
String msg = NLS.bind(Messages.ErrorReadingSite, location); |
104 |
String msg = NLS.bind(Messages.ErrorReadingSite, location); |
|
Lines 119-127
Link Here
|
| 119 |
public static synchronized UpdateSite load(URI location, IProgressMonitor monitor) throws ProvisionException { |
124 |
public static synchronized UpdateSite load(URI location, IProgressMonitor monitor) throws ProvisionException { |
| 120 |
if (location == null) |
125 |
if (location == null) |
| 121 |
return null; |
126 |
return null; |
| 122 |
UpdateSite result = siteCache.get(location.toString()); |
127 |
|
| 123 |
if (result != null) |
128 |
UpdateSite result = null; |
| 124 |
return result; |
129 |
//only caching remote sites |
|
|
130 |
if (!PROTOCOL_FILE.equals(location.getScheme()) && siteCache.containsKey(location.toString())) { |
| 131 |
result = siteCache.get(location.toString()).get(); |
| 132 |
if (result != null) |
| 133 |
return result; |
| 134 |
} |
| 135 |
|
| 125 |
InputStream input = null; |
136 |
InputStream input = null; |
| 126 |
File siteFile = loadSiteFile(location, monitor); |
137 |
File siteFile = loadSiteFile(location, monitor); |
| 127 |
try { |
138 |
try { |
|
Lines 131-137
Link Here
|
| 131 |
SiteModel siteModel = siteParser.parse(input); |
142 |
SiteModel siteModel = siteParser.parse(input); |
| 132 |
String checksumString = Long.toString(checksum.getValue()); |
143 |
String checksumString = Long.toString(checksum.getValue()); |
| 133 |
result = new UpdateSite(siteModel, getSiteURI(location), checksumString); |
144 |
result = new UpdateSite(siteModel, getSiteURI(location), checksumString); |
| 134 |
siteCache.put(location.toString(), result); |
145 |
if (!PROTOCOL_FILE.equals(location.getScheme())) |
|
|
146 |
siteCache.put(location.toString(), new SoftReference<UpdateSite>(result)); |
| 135 |
return result; |
147 |
return result; |
| 136 |
} catch (SAXException e) { |
148 |
} catch (SAXException e) { |
| 137 |
String msg = NLS.bind(Messages.ErrorReadingSite, location); |
149 |
String msg = NLS.bind(Messages.ErrorReadingSite, location); |