Summary: | Features loaded multiple times during the session | ||
---|---|---|---|
Product: | [Eclipse Project] Platform | Reporter: | Dejan Glozic <dejan> |
Component: | Update (deprecated - use Eclipse>Equinox>p2) | Assignee: | Christophe Elek <celek> |
Status: | RESOLVED FIXED | QA Contact: | |
Severity: | major | ||
Priority: | P2 | ||
Version: | 2.0 | ||
Target Milestone: | 2.0.2 | ||
Hardware: | PC | ||
OS: | All | ||
Whiteboard: |
Description
Dejan Glozic
2002-10-14 13:14:39 EDT
Conditional 2.0.2 (if we are done with all other defects and are on time). Proposed implementation: Add a method to ISite interface: /** * Creates a new feature object. The feature must exist on this site * or a core exception will be thrown. Concrete implementations * may elect to cache instances, in which case subsequent calls * to create a feature with the same type, version and id will * return the same instance. * param vid versioned identifier of the feature to create * param type the feature type that will be used to select the factory. If * <code>null</code> is passed, default feature type will be used. * param url URL of the feature archive as listed in the site. * return newly created feature object, or a cached value if * caching is implemented by this site. */ IFeature createFeature(VersionedIdentifier vid, String type, URL url) throws CoreException; Possible implementation in 'Site': public IFeature createFeature(VersionedIdentifier vid, String type, URL url) throws CoreException { // First check the cache IFeature feature = (IFeature)featureCache.get(vid); if (feature!=null) return feature; // Create a new one if (type == null || type.equals("")) { //$NON-NLS-1$ // ask the Site for the default type type = getDefaultPackagedFeatureType(); } IFeatureFactory factory = FeatureTypeFactory.getInstance().getFactory(type); feature = factory.createFeature(url, this); if (feature != null) { VersionedIdentifier featureID = feature.getVersionedIdentifier(); if (vid.equals(featureID)==false) { // FIXME: non-NL message UpdateManagerPlugin.warn("The versionId of the referenced feature doesn't match the one of the feature reference:" + getURL()); } // Add the feature to the cache featureCache.put(featureID, feature); } return feature; } The new site method should be called from FeatureReference.getFeature (IFeatureReference) In this light (since caching already exists on a site), feature reference may drop its own cached IFeature hadles and always call ISite. The performance loss will be miniscule because the call will immediately return cached IFeature instance if it has already been created. This can at least be done for 'exact' match. For 'best' match, we may still choose to hang on the feature because some lookup is involved. Fixed and tested. |