Package org.osgi.framework.hooks.resolver

Examples of org.osgi.framework.hooks.resolver.ResolverHook


    if (refs != null)
      for (ServiceReferenceImpl<ResolverHookFactory> hookRef : refs) {
        ResolverHookFactory factory = context.getService(hookRef);
        if (factory != null) {
          try {
            ResolverHook hook = factory.begin(triggers);
            if (hook != null)
              hookRefs.add(new HookReference(hookRef, hook));
          } catch (Throwable t) {
            handleHookException(t, factory, "begin", hookRef.getBundle(), hookRefs, true); //$NON-NLS-1$
          }
View Full Code Here


                try
                {
                    ResolverHookFactory rhf = m_felix.getService(m_felix, ref, false);
                    if (rhf != null)
                    {
                        ResolverHook hook =
                            Felix.m_secureAction
                                .invokeResolverHookFactory(rhf, triggers);
                        if (hook != null)
                        {
                            hookMap.put(ref, hook);
View Full Code Here

                                findNext();

                            if (next == null)
                                throw new NoSuchElementException();

                            ResolverHook hook = next.getValue();
                            next = null;
                            return hook;
                        }

                        // Find the next hook on the iterator, but only if the service is still registered.
View Full Code Here

  public VersionConstraint[] getUnsatisfiedLeaves(BundleDescription[] bundles) {
    if (bundles.length == 0)
      return new VersionConstraint[0];
    State state = bundles[0].getContainingState();
    ResolverHook hook = beginHook(state, Arrays.asList((BundleRevision[]) bundles));
    try {
      return getUnsatisfiedLeaves(state, bundles, hook);
    } finally {
      if (hook != null)
        hook.end();
    }
  }
View Full Code Here

  /**
   * @see StateHelper
   */
  public VersionConstraint[] getUnsatisfiedConstraints(BundleDescription bundle) {
    ResolverHook hook = beginHook(bundle.getContainingState(), Arrays.asList(new BundleRevision[] {bundle}));
    try {
      return getUnsatisfiedConstraints(bundle, hook);
    } finally {
      if (hook != null)
        hook.end();
    }
  }
View Full Code Here

  /**
   * @see StateHelper
   */
  public boolean isResolvable(ImportPackageSpecification constraint) {
    ResolverHook hook = beginHook(constraint.getBundle().getContainingState(), Arrays.asList(new BundleRevision[] {constraint.getBundle()}));
    try {
      return isResolvable(constraint, hook);
    } finally {
      if (hook != null)
        hook.end();
    }
  }
View Full Code Here

  /*
   * Returns whether a bundle specification/host specification can be resolved.
   */
  private boolean isBundleConstraintResolvable(VersionConstraint constraint, String namespace) {
    ResolverHook hook = beginHook(constraint.getBundle().getContainingState(), Arrays.asList(new BundleRevision[] {constraint.getBundle()}));
    try {
      return isBundleConstraintResolvable(constraint, namespace, hook);
    } finally {
      if (hook != null)
        hook.end();
    }
  }
View Full Code Here

    synchronized (this.monitor) {
      if (resolver == null)
        throw new IllegalStateException("no resolver set"); //$NON-NLS-1$
      if (resolving == true)
        throw new IllegalStateException("An attempt to start a nested resolve process has been detected."); //$NON-NLS-1$
      ResolverHook currentHook = null;
      try {
        resolving = true;
        long start = 0;
        if (StateManager.DEBUG_PLATFORM_ADMIN_RESOLVER)
          start = System.currentTimeMillis();
        if (!incremental) {
          resolved = false;
          reResolve = getBundles();
          // need to get any removal pendings before flushing
          if (removalPendings.size() > 0) {
            BundleDescription[] removed = internalGetRemovalPending();
            reResolve = mergeBundles(reResolve, removed);
          }
          flush(reResolve);
        } else {
          if (resolved && reResolve == null)
            return new StateDeltaImpl(this);
          if (developmentMode) {
            // in dev mode we need to aggressively flush removal pendings
            if (removalPendings.size() > 0) {
              BundleDescription[] removed = internalGetRemovalPending();
              reResolve = mergeBundles(reResolve, removed);
            }
          }
          if (reResolve == null)
            reResolve = internalGetRemovalPending();
          if (triggers == null) {
            Set<BundleDescription> triggerSet = new HashSet<BundleDescription>();
            Collection<BundleDescription> closure = getDependencyClosure(Arrays.asList(reResolve));
            for (BundleDescription toRefresh : closure) {
              Bundle bundle = toRefresh.getBundle();
              if (bundle != null && (bundle.getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED | Bundle.RESOLVED)) == 0)
                triggerSet.add(toRefresh);
            }
            triggers = triggerSet.toArray(new BundleDescription[triggerSet.size()]);
          }
        }
        // use the Headers class to handle ignoring case while matching keys (bug 180817)
        @SuppressWarnings("unchecked")
        Headers<Object, Object>[] tmpPlatformProperties = new Headers[platformProperties.length];
        for (int i = 0; i < platformProperties.length; i++) {
          tmpPlatformProperties[i] = new Headers<Object, Object>(platformProperties[i].size());
          for (Enumeration<Object> keys = platformProperties[i].keys(); keys.hasMoreElements();) {
            Object key = keys.nextElement();
            tmpPlatformProperties[i].put(key, platformProperties[i].get(key));
          }
        }

        ResolverHookFactory currentFactory = hookFactory;
        if (currentFactory != null) {
          @SuppressWarnings("unchecked")
          Collection<BundleRevision> triggerRevisions = Collections.unmodifiableCollection(triggers == null ? Collections.EMPTY_LIST : Arrays.asList((BundleRevision[]) triggers));
          currentHook = begin(triggerRevisions);
        }
        ResolverHookException error = null;
        try {
          resolver.resolve(reResolve, tmpPlatformProperties);
        } catch (ResolverHookException e) {
          error = e;
          resolverErrors.clear();
        }
        resolved = removalPendings.size() == 0;

        StateDeltaImpl savedChanges = changes == null ? new StateDeltaImpl(this) : changes;
        savedChanges.setResolverHookException(error);
        changes = new StateDeltaImpl(this);

        if (StateManager.DEBUG_PLATFORM_ADMIN_RESOLVER) {
          long time = System.currentTimeMillis() - start;
          Debug.println("Time spent resolving: " + time); //$NON-NLS-1$
          cumulativeTime = cumulativeTime + time;
          FrameworkDebugOptions.getDefault().setOption("org.eclipse.core.runtime.adaptor/resolver/timing/value", Long.toString(cumulativeTime)); //$NON-NLS-1$
        }
        if (savedChanges.getChanges().length > 0)
          updateTimeStamp();
        return savedChanges;
      } finally {
        if (currentHook != null)
          currentHook.end();
        resolving = false;
      }
    }
  }
View Full Code Here

  private ResolverHook begin(Collection<BundleRevision> triggers) {
    ResolverHookFactory current;
    synchronized (this.monitor) {
      current = this.hookFactory;
    }
    ResolverHook newHook = current.begin(triggers);
    synchronized (this.monitor) {
      this.hook = newHook;
    }
    return newHook;
  }
View Full Code Here

    BundleDescriptionImpl importer = (BundleDescriptionImpl) importingBundle;
    if (importer.getDynamicStamp(requestedPackage) == getTimeStamp())
      return null;
    fullyLoad();
    synchronized (this.monitor) {
      ResolverHook currentHook = null;
      try {
        resolving = true;
        ResolverHookFactory currentFactory = hookFactory;
        if (currentFactory != null) {
          Collection<BundleRevision> triggers = new ArrayList<BundleRevision>(1);
          triggers.add(importingBundle);
          triggers = Collections.unmodifiableCollection(triggers);
          currentHook = begin(triggers);
        }
        // ask the resolver to resolve our dynamic import
        ExportPackageDescriptionImpl result = (ExportPackageDescriptionImpl) resolver.resolveDynamicImport(importingBundle, requestedPackage);
        if (result == null)
          importer.setDynamicStamp(requestedPackage, new Long(getTimeStamp()));
        else {
          importer.setDynamicStamp(requestedPackage, null); // remove any cached timestamp
          // need to add the result to the list of resolved imports
          importer.addDynamicResolvedImport(result);
        }
        setDynamicCacheChanged(true);
        return result;
      } finally {
        resolving = false;
        if (currentHook != null)
          currentHook.end();
      }
    }

  }
View Full Code Here

TOP

Related Classes of org.osgi.framework.hooks.resolver.ResolverHook

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.