Java Code Examples for org.osgi.framework.BundleException#REJECTED_BY_HOOK
The following examples show how to use
org.osgi.framework.BundleException#REJECTED_BY_HOOK .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Bundles.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Install a new bundle. * * @param location The location to be installed */ BundleImpl install(final String location, final InputStream in, final Bundle caller) throws BundleException { checkIllegalState(); BundleImpl b; synchronized (this) { b = bundles.get(location); if (b != null) { if (fwCtx.bundleHooks.filterBundle(b.bundleContext, b) == null && caller != fwCtx.systemBundle) { throw new BundleException("Rejected by a bundle hook", BundleException.REJECTED_BY_HOOK); } else { return b; } } b = fwCtx.perm.callInstall0(this, location, in, caller); } return b; }
Example 2
Source File: ResolverHooks.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
void filterMatches(BundleRequirement requirement , Collection<? extends BundleCapability> candidates) throws BundleException { if (hasHooks()) { @SuppressWarnings("unchecked") Collection<BundleCapability> c = new RemoveOnlyCollection<BundleCapability>((Collection<BundleCapability>) candidates); blockResolveForHooks(); try { for (TrackedResolverHookFactory rhf : active) { final ResolverHook rh = checkActiveRemoved(rhf); try { rh.filterMatches(requirement, c); } catch (RuntimeException re) { throw new BundleException("Resolver hook throw an exception, bid=" + rhf.bundle.getBundleId(), BundleException.REJECTED_BY_HOOK, re); } } } finally { unblockResolveForHooks(); } } }
Example 3
Source File: ResolverHooks.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
void filterSingletonCollisions(BundleCapability singleton , Collection<BundleCapability> candidates) throws BundleException { if (hasHooks()) { Collection<BundleCapability> c = new RemoveOnlyCollection<BundleCapability>(candidates); blockResolveForHooks(); try { for (TrackedResolverHookFactory rhf : active) { final ResolverHook rh = checkActiveRemoved(rhf); try { rh.filterSingletonCollisions(singleton, c); } catch (RuntimeException re) { throw new BundleException("Resolver hook throw an exception, bid=" + rhf.bundle.getBundleId(), BundleException.REJECTED_BY_HOOK, re); } } } finally { unblockResolveForHooks(); } } }
Example 4
Source File: Concierge.java From concierge with Eclipse Public License 1.0 | 5 votes |
/** * install a bundle from input stream. * * @param location * the bundle location. * @param in * the input stream. * @return a Bundle object. * @throws BundleException * if the installation failed. */ synchronized BundleImpl installNewBundle(final BundleContext context, final String location, final InputStream in) throws BundleException { final AbstractBundle cached; if ((cached = location_bundles.get(location)) != null) { if (!bundleFindHooks.isEmpty()) { final Bundle[] test = filterWithBundleHooks(context, Arrays.asList((Bundle) cached)); if (test.length == 0) { throw new BundleException( "Existing bundle rejected by find hooks", BundleException.REJECTED_BY_HOOK); } } return (BundleImpl) cached; } final BundleImpl bundle = new BundleImpl(this, context, location, nextBundleID++, in); // notify the listeners notifyBundleListeners(BundleEvent.INSTALLED, bundle, context.getBundle()); storeMetadata(); return bundle; }
Example 5
Source File: ResolverHooks.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
synchronized void beginResolve(final BundleImpl [] triggers) throws BundleException { if (!isOpen()) { return; } if (currentTriggers == null) { Collection<BundleRevision> triggerCollection = new ArrayList<BundleRevision>(); for (BundleImpl b : triggers) { triggerCollection.add(b.current().bundleRevision); } active = new ArrayList<TrackedResolverHookFactory>(); for (Entry<ServiceReference<ResolverHookFactory>, TrackedResolverHookFactory> e : resolverHookTracker.getTracked().entrySet()) { TrackedResolverHookFactory rhf = resolverHookTracker.getService(e.getKey()); if (null != rhf) { blockResolveForHooks(); try { if (rhf.begin(triggerCollection)) { active.add(rhf); currentTriggers = triggers; } } catch (RuntimeException re) { throw new BundleException("Resolver hook throw an exception, bid=" + rhf.bundle.getBundleId(), BundleException.REJECTED_BY_HOOK, re); } finally { unblockResolveForHooks(); } } } if (active.isEmpty()) { active = null; } else { resolvableBundles = new HashMap<BundleGeneration, Boolean>(); } } }
Example 6
Source File: ResolverHooks.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
boolean filterResolvable(BundleGeneration bg) throws BundleException { if (hasHooks()) { Boolean res = resolvableBundles.get(bg); if (res == null) { Collection<BundleRevision> c = new ShrinkableSingletonCollection<BundleRevision>(bg.bundleRevision); blockResolveForHooks(); try { for (TrackedResolverHookFactory rhf : active) { final ResolverHook rh = checkActiveRemoved(rhf); try { rh.filterResolvable(c); } catch (RuntimeException re) { throw new BundleException("Resolver hook throw an exception, bid=" + rhf.bundle.getBundleId(), BundleException.REJECTED_BY_HOOK, re); } } } finally { unblockResolveForHooks(); } res = Boolean.valueOf(!c.isEmpty()); resolvableBundles.put(bg, res); } return res.booleanValue(); } return true; }
Example 7
Source File: ResolverHooks.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
private ResolverHook checkActiveRemoved(TrackedResolverHookFactory rhf) throws BundleException { ResolverHook rh = rhf.getResolverHook(); if (null == rh) { throw new BundleException("Resolver hook service was unregistered", BundleException.REJECTED_BY_HOOK); } return rh; }
Example 8
Source File: BundleImpl.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Get updated bundle state. That means check if an installed bundle has been * resolved. * * @return Bundles state */ int getUpdatedState(BundleImpl [] triggers, boolean isResolve) { if (state == INSTALLED) { try { synchronized (fwCtx.resolver) { waitOnOperation(fwCtx.resolver, "Bundle.resolve", true); final BundleGeneration current = current(); if (state == INSTALLED && (!fwCtx.isInit || current.isExtension())) { if (triggers != null) { fwCtx.resolverHooks.beginResolve(triggers); } if (current.isFragment()) { List<BundleGeneration> hosts; if (isResolve) { hosts = new ArrayList<BundleGeneration>(); List<BundlePackages> bps = fwCtx.resolver.getFragBundlePackages(current.bpkgs); if (bps != null) { for (BundlePackages bp : bps) { hosts.add(bp.bg); } } } else { hosts = current.fragment.targets(); } if (!hosts.isEmpty()) { for (final BundleGeneration host : hosts) { if (isResolve || host.bpkgs.isActive()) { if (!current.fragment.isHost(host)) { attachToFragmentHost(host, isResolve); } } else { // Try resolve our host // NYI! Detect circular attach host.bundle.getUpdatedState(null, false); } } } if (state == INSTALLED && current.fragment.hasHosts()) { current.setWired(); state = RESOLVED; operation = RESOLVING; if (current.isExtension()) { // TODO call on bundle thread!? fwCtx.systemBundle.extensionCallStart(this); } bundleThread().bundleChanged(new BundleEvent(BundleEvent.RESOLVED, this)); operation = IDLE; } } else { if (current.resolvePackages(triggers, isResolve)) { current.setWired(); state = RESOLVED; operation = RESOLVING; if (!isResolve) { current.updateStateFragments(); } bundleThread().bundleChanged(new BundleEvent(BundleEvent.RESOLVED, this)); operation = IDLE; } else { String reason = current.bpkgs.getResolveFailReason(); throw new BundleException("Bundle#" + id + ", unable to resolve: " + reason, reason == Resolver.RESOLVER_HOOK_VETO ? BundleException.REJECTED_BY_HOOK : BundleException.RESOLVE_ERROR); } } if (triggers != null && triggers.length == 1) { BundleImpl[] t = triggers; triggers = null; fwCtx.resolverHooks.endResolve(t); } } } } catch (final BundleException be) { resolveFailException = be; fwCtx.frameworkError(this, be); if (triggers != null && triggers.length == 1) { try { fwCtx.resolverHooks.endResolve(triggers); } catch (final BundleException be2) { resolveFailException = be2; fwCtx.frameworkError(this, be2); } } } } return state; }