1 11 package org.eclipse.core.runtime.adaptor; 12 13 import java.util.Dictionary ; 14 import java.util.Enumeration ; 15 import org.eclipse.osgi.framework.adaptor.FrameworkAdaptor; 16 import org.eclipse.osgi.framework.log.FrameworkLogEntry; 17 import org.eclipse.osgi.service.resolver.Version; 18 import org.osgi.framework.BundleException; 19 import org.osgi.framework.Constants; 20 21 24 public class CachedManifest extends Dictionary { 25 26 Dictionary manifest = null; 27 EclipseBundleData bundledata; 28 29 public CachedManifest(EclipseBundleData bundledata) { 30 this.bundledata = bundledata; 31 } 32 33 private Dictionary getManifest() { 34 if (manifest == null) 35 try { 36 manifest = bundledata.loadManifest(); 37 } catch (BundleException e) { 38 final String message = EclipseAdaptorMsg.formatter.getString("ECLIPSE_CACHEDMANIFEST_UNEXPECTED_EXCEPTION", bundledata.getLocation()); FrameworkLogEntry entry = new FrameworkLogEntry(FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME, message, 0, e, null); 40 EclipseAdaptor.getDefault().getFrameworkLog().log(entry); 41 return null; 42 } 43 return manifest; 44 } 45 46 public int size() { 47 return getManifest().size(); 49 } 50 51 public boolean isEmpty() { 52 return size() == 0; 53 } 54 55 public Enumeration elements() { 56 return getManifest().elements(); 58 } 59 60 public Enumeration keys() { 61 return getManifest().keys(); 63 } 64 65 public Object get(Object key) { 66 String keyString = (String ) key; 67 if (Constants.BUNDLE_VERSION.equalsIgnoreCase(keyString)) { 68 Version result = bundledata.getVersion(); 69 return result == null ? null : result.toString(); 70 } 71 if (EclipseAdaptor.PLUGIN_CLASS.equalsIgnoreCase(keyString)) 72 return bundledata.getPluginClass(); 73 if (Constants.BUNDLE_SYMBOLICNAME.equalsIgnoreCase(keyString)) 74 return bundledata.getSymbolicName(); 75 Dictionary result = getManifest(); 76 return result == null ? null : result.get(key); 77 } 78 79 public Object remove(Object key) { 80 return getManifest().remove(key); 82 } 83 84 public Object put(Object key, Object value) { 85 return getManifest().put(key, value); 87 } 88 89 } | Popular Tags |