public BundleDelta[] getChanges(int mask, boolean exact) { synchronized (this.changes) { List<BundleDelta> result = new ArrayList<BundleDelta>(); for (Iterator<BundleDelta> changesIter = changes.values().iterator(); changesIter.hasNext();) { BundleDelta change = changesIter.next(); if (mask == change.getType() || (!exact && (change.getType() & mask) != 0)) result.add(change); } return result.toArray(new BundleDelta[result.size()]); } }
public BundleDelta[] getChanges(int mask, boolean exact) { synchronized (this.changes) { List<BundleDelta> result = new ArrayList<BundleDelta>(); for (Iterator<BundleDelta> changesIter = changes.values().iterator(); changesIter.hasNext();) { BundleDelta change = changesIter.next(); if (mask == change.getType() || (!exact && (change.getType() & mask) != 0)) result.add(change); } return result.toArray(new BundleDelta[result.size()]); } }
public BundleDelta[] getChanges(int mask, boolean exact) { synchronized (this.changes) { List<BundleDelta> result = new ArrayList<BundleDelta>(); for (Iterator<BundleDelta> changesIter = changes.values().iterator(); changesIter.hasNext();) { BundleDelta change = changesIter.next(); if (mask == change.getType() || (!exact && (change.getType() & mask) != 0)) result.add(change); } return result.toArray(new BundleDelta[result.size()]); } }
public BundleDelta[] getChanges(int mask, boolean exact) { synchronized (this.changes) { List<BundleDelta> result = new ArrayList<>(); for (Iterator<BundleDelta> changesIter = changes.values().iterator(); changesIter.hasNext();) { BundleDelta change = changesIter.next(); if (mask == change.getType() || (!exact && (change.getType() & mask) != 0)) result.add(change); } return result.toArray(new BundleDelta[result.size()]); } }
@Override public void stateResolved(StateDelta delta) { if (delta == null) { // if delta is null, then target has changed // prepare all projects for "touching" fTouchWorkspace = true; fProjectNames.clear(); } else { BundleDelta[] deltas = delta.getChanges(); for (int i = 0; i < deltas.length; i++) { // only interested in workspace plug-ins that are affected by delta // but not those who have caused it. int type = deltas[i].getType(); if ((type & BundleDelta.UPDATED) == BundleDelta.UPDATED || (type & BundleDelta.ADDED) == BundleDelta.ADDED || (type & BundleDelta.REMOVED) == BundleDelta.REMOVED) continue; IPluginModelBase model = PluginRegistry.findModel(deltas[i].getBundle()); IResource resource = model == null ? null : model.getUnderlyingResource(); if (resource != null) fProjectNames.add(resource.getProject().getName()); } } }
public void stateResolved(StateDelta delta) { if (delta == null) { // if delta is null, then target has changed // prepare all projects for "touching" fTouchWorkspace = true; fProjectNames.clear(); } else { BundleDelta[] deltas = delta.getChanges(); for (int i = 0; i < deltas.length; i++) { // only interested in workspace plug-ins that are affected by delta // but not those who have caused it. int type = deltas[i].getType(); if ((type & BundleDelta.UPDATED) == BundleDelta.UPDATED || (type & BundleDelta.ADDED) == BundleDelta.ADDED || (type & BundleDelta.REMOVED) == BundleDelta.REMOVED) continue; IPluginModelBase model = PluginRegistry.findModel(deltas[i].getBundle()); IResource resource = model == null ? null : model.getUnderlyingResource(); if (resource != null) fProjectNames.add(resource.getProject().getName()); } } }
@Override public void stateResolved(final StateDelta delta) { if (!fView.getCurrentPage().equals(this) || fTreeViewer == null || fTreeViewer.getTree().isDisposed()) // if this page is not active, then wait until we call refresh on next activation return; fTreeViewer.getTree().getDisplay().asyncExec(() -> { if (delta == null) { fTreeViewer.refresh(); } else { BundleDelta[] deltas = delta.getChanges(); for (BundleDelta d : deltas) { int type = d.getType(); if (type == BundleDelta.REMOVED || type == BundleDelta.RESOLVED || type == BundleDelta.ADDED || type == BundleDelta.UNRESOLVED) { fTreeViewer.refresh(); break; } } } }); }
private void applyDeltas(BundleDelta[] bundleDeltas) throws BundleException { Arrays.sort(bundleDeltas, new Comparator<BundleDelta>() { public int compare(BundleDelta delta0, BundleDelta delta1) { return (int) (delta0.getBundle().getBundleId() - delta1.getBundle().getBundleId()); } }); for (int i = 0; i < bundleDeltas.length; i++) { int type = bundleDeltas[i].getType(); if ((type & (BundleDelta.REMOVAL_PENDING | BundleDelta.REMOVAL_COMPLETE)) != 0) applyRemovalPending(bundleDeltas[i]); if ((type & BundleDelta.RESOLVED) != 0) { AbstractBundle bundle = setResolved(bundleDeltas[i].getBundle()); if (bundle != null && bundle.isResolved()) { NativeCodeSpecification nativeCode = bundleDeltas[i].getBundle().getNativeCodeSpecification(); if (nativeCode != null && nativeCode.getSupplier() != null) try { BundleData data = bundle.getBundleData(); data.installNativeCode(((NativeCodeDescription) nativeCode.getSupplier()).getNativePaths()); } catch (BundleException e) { framework.publishFrameworkEvent(FrameworkEvent.ERROR, bundle, e); } } } } }
private void applyRemovalPending(BundleDelta bundleDelta) throws BundleException { if ((bundleDelta.getType() & BundleDelta.REMOVAL_COMPLETE) != 0) { BundleDescription bundle = bundleDelta.getBundle(); if (bundle.getDependents() != null && bundle.getDependents().length > 0) { /* Reaching here is an internal error */ if (Debug.DEBUG_PACKAGEADMIN) { Debug.println("Bundles still depend on removed bundle! " + bundle); //$NON-NLS-1$ Debug.printStackTrace(new Exception("Stack trace")); //$NON-NLS-1$ } throw new BundleException(Msg.OSGI_INTERNAL_ERROR); } Object userObject = bundle.getUserObject(); if (userObject instanceof BundleLoaderProxy) { BundleLoader.closeBundleLoader((BundleLoaderProxy) userObject); try { ((BundleLoaderProxy) userObject).getBundleData().close(); } catch (IOException e) { // ignore } } else if (userObject instanceof BundleData) { try { ((BundleData) userObject).close(); } catch (IOException e) { // ignore } } } }
private void applyRemovalPending(BundleDelta bundleDelta) throws BundleException { if ((bundleDelta.getType() & BundleDelta.REMOVAL_COMPLETE) != 0) { BundleDescription bundle = bundleDelta.getBundle(); if (bundle.getDependents() != null && bundle.getDependents().length > 0) { /* Reaching here is an internal error */ if (Debug.DEBUG_PACKAGEADMIN) { Debug.println("Bundles still depend on removed bundle! " + bundle); //$NON-NLS-1$ Debug.printStackTrace(new Exception("Stack trace")); //$NON-NLS-1$ } throw new BundleException(Msg.OSGI_INTERNAL_ERROR); } Object userObject = bundle.getUserObject(); if (userObject instanceof BundleLoaderProxy) { BundleLoader.closeBundleLoader((BundleLoaderProxy) userObject); try { ((BundleLoaderProxy) userObject).getBundleData().close(); } catch (IOException e) { // ignore } } else if (userObject instanceof BundleData) { try { ((BundleData) userObject).close(); } catch (IOException e) { // ignore } } } }
private void applyDeltas(BundleDelta[] bundleDeltas) throws BundleException { Arrays.sort(bundleDeltas, new Comparator<BundleDelta>() { public int compare(BundleDelta delta0, BundleDelta delta1) { return (int) (delta0.getBundle().getBundleId() - delta1.getBundle().getBundleId()); } }); for (int i = 0; i < bundleDeltas.length; i++) { int type = bundleDeltas[i].getType(); if ((type & (BundleDelta.REMOVAL_PENDING | BundleDelta.REMOVAL_COMPLETE)) != 0) applyRemovalPending(bundleDeltas[i]); if ((type & BundleDelta.RESOLVED) != 0) { AbstractBundle bundle = setResolved(bundleDeltas[i].getBundle()); if (bundle != null && bundle.isResolved()) { NativeCodeSpecification nativeCode = bundleDeltas[i].getBundle().getNativeCodeSpecification(); if (nativeCode != null && nativeCode.getSupplier() != null) try { BundleData data = bundle.getBundleData(); data.installNativeCode(((NativeCodeDescription) nativeCode.getSupplier()).getNativePaths()); } catch (BundleException e) { framework.publishFrameworkEvent(FrameworkEvent.ERROR, bundle, e); } } } } }