1 11 package org.eclipse.osgi.internal.resolver; 12 13 import java.util.HashSet ; 14 import java.util.Set ; 15 import org.eclipse.osgi.service.resolver.*; 16 import org.osgi.framework.BundleException; 17 18 21 public class UserState extends StateImpl { 22 private Set updated = new HashSet (); 24 25 public synchronized boolean removeBundle(BundleDescription description) { 26 if (description.getLocation() != null) 27 updated.remove(description.getLocation()); 28 if (!super.removeBundle(description)) 29 return false; 30 return true; 31 } 32 33 public boolean updateBundle(BundleDescription newDescription) { 34 if (!super.updateBundle(newDescription)) 35 return false; 36 updated.add(newDescription.getLocation()); 37 return true; 38 } 39 40 public StateDelta compare(State baseState) throws BundleException { 41 BundleDescription[] current = this.getBundles(); 42 StateDeltaImpl delta = new StateDeltaImpl(this); 43 for (int i = 0; i < current.length; i++) { 45 BundleDescription existing = baseState.getBundleByLocation(current[i].getLocation()); 46 if (existing == null) 47 delta.recordBundleAdded((BundleDescriptionImpl) current[i]); 48 else if (updated.contains(current[i].getLocation())) 49 delta.recordBundleUpdated((BundleDescriptionImpl) current[i]); 50 } 51 BundleDescription[] existing = baseState.getBundles(); 53 for (int i = 0; i < existing.length; i++) { 54 BundleDescription local = getBundleByLocation(existing[i].getLocation()); 55 if (local == null) 56 delta.recordBundleRemoved((BundleDescriptionImpl) existing[i]); 57 } 58 return delta; 59 } 60 } 61 | Popular Tags |