org.eclipse.osgi_3.7.2.v20120110-1415

rt = new ExportPackageDescriptionImpl(getBundleDescription(), newExports[i]);
          hostExports.add(new ResolverExport(this, hostExport));
        }
      }
      fragmentExports.put(bundleID, hostExports);
    }
    List<GenericCapability> hostCapabilities = new ArrayList(newGenericCapabilities.length);
    if ((newGenericCapabilities.length > 0) && (dynamicAttach))
    {
      GenericDescription[] arrayOfGenericDescription1;
      hostExport = (arrayOfGenericDescription1 = newGenericCapabilities).length;
      for (foundEquivalent = false; foundEquivalent < hostExport; foundEquivalent++)
      {
        GenericDescription capability = arrayOfGenericDescription1[foundEquivalent];
        GenericDescription hostCapabililty = new GenericDescriptionImpl(getBundleDescription(), capability);
        hostCapabilities.add(new GenericCapability(this, hostCapabililty));
      }
      fragmentGenericCapabilities.put(bundleID, hostCapabilities);
    }
    if (dynamicAttach)
    {
      resolver.getResolverExports().put((ResolverExport[])hostExports.toArray(new ResolverExport[hostExports.size()]));
      resolver.addGenerics((GenericCapability[])hostCapabilities.toArray(new GenericCapability[hostCapabilities.size()]));
    }
  }
  
  private boolean equivalentExports(ResolverExport existingExport, ExportPackageDescription newDescription)
  {
    ExportPackageDescription existingDescription = existingExport.getExportPackageDescription();
    if (!existingDescription.getName().equals(newDescription.getName())) {
      return false;
    }
    if (!existingDescription.getVersion().equals(newDescription.getVersion())) {
      return false;
    }
    if (!equivalentMaps(existingDescription.getAttributes(), newDescription.getAttributes(), true)) {
      return false;
    }
    if (!equivalentMaps(existingDescription.getDirectives(), newDescription.getDirectives(), true)) {
      return false;
    }
    return true;
  }
  
  public static boolean equivalentMaps(Map<String, Object> existingDirectives, Map<String, Object> newDirectives, boolean exactMatch)
  {
    if ((existingDirectives == null) && (newDirectives == null)) {
      return true;
    }
    if (existingDirectives == null ? newDirectives != null : newDirectives == null) {
      return false;
    }
    if ((exactMatch) && (existingDirectives.size() != newDirectives.size())) {
      return false;
    }
    for (Iterator<Map.Entry<String, Object>> entries = existingDirectives.entrySet().iterator(); entries.hasNext();)
    {
      Map.Entry<String, Object> entry = (Map.Entry)entries.next();
      Object newValue = newDirectives.get(entry.getKey());
      if ((newValue == null) || (entry.getValue().getClass() != newValue.getClass())) {
        return false;
      }
      if ((newValue instanceof String[]))
      {
        if (!Arrays.equals((Object[])entry.getValue(), (Object[])newValue)) {
          return false;
        }
      }
      else if (!entry.getValue().equals(newValue)) {
        return false;
      }
    }
    return true;
  }
  
  boolean constraintsConflict(BundleDescription fragment, ImportPackageSpecification[] newImports, BundleSpecification[] newRequires, GenericSpecification[] newGenericRequires)
  {
    boolean result = false;
    for (int i = 0; i < newImports.length; i++)
    {
      ResolverImport hostImport = getImport(newImports[i].getName());
      ResolverExport resolvedExport = (ResolverExport)(hostImport == null ? null : hostImport.getSelectedSupplier());
      if (((resolvedExport == null) && (isResolved())) || ((resolvedExport != null) && (!newImports[i].isSatisfiedBy(resolvedExport.getExportPackageDescription()))))
      {
        result = true;
        resolver.getState().addResolverError(fragment, 16, newImports[i].toString(), newImports[i]);
      }
    }
    for (int i = 0; i < newRequires.length; i++)
    {
      BundleConstraint hostRequire = getRequire(newRequires[i].getName());
      ResolverBundle resolvedRequire = (ResolverBundle)(hostRequire == null ? null : hostRequire.getSelectedSupplier());
      if (((resolvedRequire == null) && (isResolved())) || ((resolvedRequire != null) && (!newRequires[i].isSatisfiedBy(resolvedRequire.getBundleDescription()))))
      {
        result = true;
        resolver.getState().addResolverError(fragment, 16, newRequires[i].toString(), newRequires[i]);
      }
    }
    if ((isResolved()) && (newGenericRequires != null) && (newGenericRequires.length > 0)) {
      result = true;
    }
    return result;
  }
  
  private void setNewFragmentExports(boolean newFragmentExports)
  {
    this.newFragmentExports = newFragmentExports;
  }
  
  boolean isNewFragmentExports()
  {
    return newFragmentExports;
  }
  
  private void setNewFragmentCapabilities(boolean newFragmentCapabilities)
  {
    this.newFragmentCapabilities = newFragmentCapabilities;
  }
  
  boolean isNewFragmentCapabilities()
  {
    return newFragmentCapabilities;
  }
  
  void detachFragment(ResolverBundle fragment, ResolverConstraint reason)
  {
    if (isFragment()) {
      return;
    }
    initFragments();
    
    ResolverImport[] oldImports = getImportPackages();
    BundleConstraint[] oldRequires = getRequires();
    if (!fragments.remove(fragment)) {
      return;
    }
    fragment.setNewFragmentExports(false);
    fragment.setNewFragmentCapabilities(false);
    fragment.getHost().removePossibleSupplier(this);
    fragmentImports.remove(bundleID);
    fragmentRequires.remove(bundleID);
    List<ResolverExport> removedExports = (List)fragmentExports.remove(bundleID);
    fragmentGenericRequires.remove(bundleID);
    List<GenericCapability> removedCapabilities = (List)fragmentGenericCapabilities.remove(bundleID);
    if (reason != null)
    {
      ResolverBundle[] remainingFrags = (ResolverBundle[])fragments.toArray(new ResolverBundle[fragments.size()]);
      ResolverBundle[] arrayOfResolverBundle1;
      int j = (arrayOfResolverBundle1 = remainingFrags).length;
      for (int i = 0; i < j; i++)
      {
        ResolverBundle remainingFrag = arrayOfResolverBundle1[i];
        List<ResolverImport> additionalImports = new ArrayList(0);
        List<BundleConstraint> additionalRequires = new ArrayList(0);
        if (!hasUnresolvedConstraint(reason, fragment, remainingFrag, oldImports, oldRequires, additionalImports, additionalRequires))
        {
          if (additionalImports.size() > 0)
          {
            List<ResolverImport> remainingImports = (List)fragmentImports.get(bundleID);
            if (remainingImports == null) {
              fragmentImports.put(bundleID, additionalImports);
            } else {
              remainingImports.addAll(additionalImports);
            }
          }
          if (additionalRequires.size() > 0)
          {
            List<BundleConstraint> remainingRequires = (List)fragmentRequires.get(bundleID);
            if (remainingRequires == null) {
              fragmentRequires.put(bundleID, additionalRequires);
            } else {
              remainingRequires.addAll(additionalRequires);
            }
          }
        }
      }
    }
    ResolverExport[] results = removedExports == null ? new ResolverExport[0] : (ResolverExport[])removedExports.toArray(new ResolverExport[removedExports.size()]);
    for (int i = 0; i < results.length; i++) {
      results[i].setSubstitute(results[i]);
    }
    resolver.getResolverExports().remove(results);
    if (removedCapabilities != null) {
      resolver.removeGenerics((GenericCapability[])removedCapabilities.toArray(new GenericCapability[removedCapabilities.size()]));
    }
  }
  
  private boolean hasUnresolvedConstraint(ResolverConstraint reason, ResolverBundle detachedFragment, ResolverBundle remainingFragment, ResolverImport[] oldImports, BundleConstraint[] oldRequires, List<ResolverImport> additionalImports, List<BundleConstraint> additionalRequires)
  {
    ImportPackageSpecification[] remainingFragImports = remainingFragment.getBundleDescription().getImportPackages();
    BundleSpecification[] remainingFragRequires = remainingFragment.getBundleDescription().getRequiredBundles();
    VersionConstraint[] constraints;
    VersionConstraint[] constraints;
    if ((reason instanceof ResolverImport)) {
      constraints = remainingFragImports;
    } else {
      constraints = remainingFragRequires;
    }
    for (int i = 0; i < constraints.length; i++) {
      if (reason.getName().equals(constraints[i].getName()))
      {
        detachFragment(remainingFragment, reason);
        return true;
      }
    }
    for (int i = 0; i < oldImports.length; i++) {
      if (oldImports[i].getVersionConstraint().getBundle() == detachedFragment.getBundleDescription()) {
        for (int j = 0; j < remainingFragImports.length; j++) {
          if (oldImports[i].getName().equals(remainingFragImports[j].getName()))
          {
            additionalImports.add(oldImports[i]);
            oldImports[i].setVersionConstraint(remainingFragImports[j]);
            break;
          }
        }
      }
    }
    for (int i = 0; i < oldRequires.length; i++) {
      if (oldRequires[i].getVersionConstraint().getBundle() == detachedFragment.getBundleDescription()) {
        for (int j = 0; j < remainingFragRequires.length; j++) {
          if (oldRequires[i].getName().equals(remainingFragRequires[j].getName()))
          {
            additionalRequires.add(oldRequires[i]);
            oldRequires[i].setVersionConstraint(remainingFragRequires[j]);
            break;
          }
        }
      }
    }
    return false;
  }
  
  void detachAllFragments()
  {
    if (fragments == null) {
      return;
    }
    ResolverBundle[] allFragments = (ResolverBundle[])fragments.toArray(new ResolverBundle[fragments.size()]);
    for (int i = 0; i < allFragments.length; i++) {
      detachFragment(allFragments[i], null);
    }
    fragments = null;
  }
  
  boolean isResolvable()
  {
    return resolvable;
  }
  
  void setResolvable(boolean resolvable)
  {
    this.resolvable = resolvable;
  }
  
  void addExport(ResolverExport re)
  {
    ResolverExport[] newExports = new ResolverExport[exports.length + 1];
    for (int i = 0; i < exports.length; i++) {
      newExports[i] = exports[i];
    }
    newExports[exports.length] = re;
    exports = newExports;
  }
  
  ResolverImpl getResolver()
  {
    return resolver;
  }
  
  ResolverBundle[] getFragments()
  {
    return fragments == null ? new ResolverBundle[0] : (ResolverBundle[])fragments.toArray(new ResolverBundle[fragments.size()]);
  }
  
  public int compareTo(ResolverBundle o)
  {
    String bsn = getName();
    String otherBsn = o.getName();
    if (bsn == null) {
      return otherBsn == null ? 0 : 1;
    }
    return otherBsn == null ? -1 : bsn.compareTo(otherBsn);
  }
  
  void setUninstalled()
  {
    uninstalled = true;
  }
  
  boolean isUninstalled()
  {
    return uninstalled;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.module.ResolverBundle
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.internal.module;

import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.VersionConstraint;
import org.osgi.framework.wiring.BundleRequirement;

public abstract class ResolverConstraint
{
  protected final ResolverBundle bundle;
  protected VersionConstraint constraint;
  private BundleRequirement requrement;
  private VersionSupplier[] possibleSuppliers;
  private int selectedSupplierIndex = 0;
  
  ResolverConstraint(ResolverBundle bundle, VersionConstraint constraint)
  {
    this.bundle = bundle;
    this.constraint = constraint;
    requrement = constraint.getRequirement();
  }
  
  ResolverBundle getBundle()
  {
    return bundle;
  }
  
  BundleDescription getBundleDescription()
  {
    return bundle.getBundleDescription();
  }
  
  boolean isFromFragment()
  {
    return constraint.getBundle().getHost() != null;
  }
  
  boolean isSatisfiedBy(VersionSupplier vs)
  {
    if ((vs.getResolverBundle().isUninstalled()) || (!bundle.getResolver().getPermissionChecker().checkPermission(constraint, vs.getBaseDescription()))) {
      return false;
    }
    return (vs.getSubstitute() == null) && (constraint.isSatisfiedBy(vs.getBaseDescription()));
  }
  
  VersionConstraint getVersionConstraint()
  {
    return constraint;
  }
  
  public String getName()
  {
    return constraint.getName();
  }
  
  public String toString()
  {
    return constraint.toString();
  }
  
  abstract boolean isOptional();
  
  void addPossibleSupplier(VersionSupplier supplier)
  {
    if (supplier == null) {
      return;
    }
    if (possibleSuppliers == null)
    {
      possibleSuppliers = new VersionSupplier[] { supplier };
      return;
    }
    VersionSupplier[] newSuppliers = new VersionSupplier[possibleSuppliers.length + 1];
    System.arraycopy(possibleSuppliers, 0, newSuppliers, 0, possibleSuppliers.length);
    newSuppliers[possibleSuppliers.length] = supplier;
    possibleSuppliers = newSuppliers;
  }
  
  public void removePossibleSupplier(VersionSupplier supplier)
  {
    if ((possibleSuppliers == null) || (supplier == null)) {
      return;
    }
    int index = -1;
    for (int i = 0; i < possibleSuppliers.length; i++) {
      if (possibleSuppliers[i] == supplier)
      {
        index = i;
        break;
      }
    }
    if (index >= 0)
    {
      if (possibleSuppliers.length == 1)
      {
        possibleSuppliers = null;
        return;
      }
      VersionSupplier[] newSuppliers = new VersionSupplier[possibleSuppliers.length - 1];
      System.arraycopy(possibleSuppliers, 0, newSuppliers, 0, index);
      if (index < possibleSuppliers.length - 1) {
        System.arraycopy(possibleSuppliers, index + 1, newSuppliers, index, possibleSuppliers.length - index - 1);
      }
      possibleSuppliers = newSuppliers;
    }
  }
  
  int getNumPossibleSuppliers()
  {
    if (possibleSuppliers == null) {
      return 0;
    }
    return possibleSuppliers.length;
  }
  
  boolean selectNextSupplier()
  {
    if ((possibleSuppliers == null) || (selectedSupplierIndex >= possibleSuppliers.length)) {
      return false;
    }
    selectedSupplierIndex += 1;
    return selectedSupplierIndex < possibleSuppliers.length;
  }
  
  VersionSupplier getSelectedSupplier()
  {
    if ((possibleSuppliers == null) || (selectedSupplierIndex >= possibleSuppliers.length)) {
      return null;
    }
    return possibleSuppliers[selectedSupplierIndex];
  }
  
  void setSelectedSupplier(int selectedSupplier)
  {
    selectedSupplierIndex = selectedSupplier;
  }
  
  int getSelectedSupplierIndex()
  {
    return selectedSupplierIndex;
  }
  
  VersionSupplier[] getPossibleSuppliers()
  {
    return possibleSuppliers;
  }
  
  void clearPossibleSuppliers()
  {
    possibleSuppliers = null;
    selectedSupplierIndex = 0;
  }
  
  void setVersionConstraint(VersionConstraint constraint)
  {
    this.constraint = constraint;
    requrement = constraint.getRequirement();
  }
  
  BundleRequirement getRequirement()
  {
    return requrement;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.module.ResolverConstraint
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.internal.module;

import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.ExportPackageDescription;

public class ResolverExport
  extends VersionSupplier
{
  private ResolverBundle resolverBundle;
  
  ResolverExport(ResolverBundle resolverBundle, ExportPackageDescription epd)
  {
    super(epd);
    this.resolverBundle = resolverBundle;
  }
  
  public ExportPackageDescription getExportPackageDescription()
  {
    return (ExportPackageDescription)base;
  }
  
  public BundleDescription getBundleDescription()
  {
    return getExportPackageDescription().getExporter();
  }
  
  ResolverBundle getExporter()
  {
    return resolverBundle;
  }
  
  ResolverBundle getResolverBundle()
  {
    return getExporter();
  }
  
  String[] getUsesDirective()
  {
    return (String[])getExportPackageDescription().getDirective("uses");
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.module.ResolverExport
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.internal.module;

import java.io.PrintStream;
import java.security.AccessController;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.osgi.framework.debug.Debug;
import org.eclipse.osgi.framework.debug.FrameworkDebugOptions;
import org.eclipse.osgi.framework.internal.core.Constants;
import org.eclipse.osgi.framework.internal.core.FilterImpl;
import org.eclipse.osgi.framework.util.SecureAction;
import org.eclipse.osgi.internal.baseadaptor.ArrayMap;
import org.eclipse.osgi.internal.resolver.BaseDescriptionImpl;
import org.eclipse.osgi.internal.resolver.BundleDescriptionImpl;
import org.eclipse.osgi.internal.resolver.StateImpl;
import org.eclipse.osgi.service.resolver.BaseDescription;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.BundleSpecification;
import org.eclipse.osgi.service.resolver.DisabledInfo;
import org.eclipse.osgi.service.resolver.ExportPackageDescription;
import org.eclipse.osgi.service.resolver.GenericDescription;
import org.eclipse.osgi.service.resolver.GenericSpecification;
import org.eclipse.osgi.service.resolver.HostSpecification;
import org.eclipse.osgi.service.resolver.ImportPackageSpecification;
import org.eclipse.osgi.service.resolver.NativeCodeDescription;
import org.eclipse.osgi.service.resolver.NativeCodeSpecification;
import org.eclipse.osgi.service.resolver.Resolver;
import org.eclipse.osgi.service.resolver.State;
import org.eclipse.osgi.service.resolver.StateWire;
import org.eclipse.osgi.service.resolver.VersionConstraint;
import org.eclipse.osgi.util.ManifestElement;
import org.osgi.framework.Filter;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.hooks.resolver.ResolverHook;
import org.osgi.framework.wiring.BundleCapability;

public class ResolverImpl
  implements Resolver
{
  private static final String RESOLVER = "org.eclipse.osgi/resolver";
  private static final String OPTION_DEBUG = "org.eclipse.osgi/resolver/debug";
  private static final String OPTION_WIRING = "org.eclipse.osgi/resolver/wiring";
  private static final String OPTION_IMPORTS = "org.eclipse.osgi/resolver/imports";
  private static final String OPTION_REQUIRES = "org.eclipse.osgi/resolver/requires";
  private static final String OPTION_GENERICS = "org.eclipse.osgi/resolver/generics";
  private static final String OPTION_USES = "org.eclipse.osgi/resolver/uses";
  private static final String OPTION_CYCLES = "org.eclipse.osgi/resolver/cycles";
  public static boolean DEBUG = false;
  public static boolean DEBUG_WIRING = false;
  public static boolean DEBUG_IMPORTS = false;
  public static boolean DEBUG_REQUIRES = false;
  public static boolean DEBUG_GENERICS = false;
  public static boolean DEBUG_USES = false;
  public static boolean DEBUG_CYCLES = false;
  private static int MAX_MULTIPLE_SUPPLIERS_MERGE = 10;
  private static int MAX_USES_TIME_BASE = 30000;
  private static int MAX_USES_TIME_LIMIT = 90000;
  static final SecureAction secureAction = (SecureAction)AccessController.doPrivileged(SecureAction.createSecureAction());
  private String[][] CURRENT_EES;
  private ResolverHook hook;
  private State state;
  private final PermissionChecker permissionChecker;
  private MappedList<Long, BundleDescription> removalPending = new MappedList();
  private boolean initialized = false;
  private VersionHashMap<ResolverExport> resolverExports = null;
  private VersionHashMap<ResolverBundle> resolverBundles = null;
  private Map<String, VersionHashMap<GenericCapability>> resolverGenerics = null;
  private HashSet<ResolverBundle> unresolvedBundles = null;
  private HashMap<BundleDescription, ResolverBundle> bundleMapping = null;
  private GroupingChecker groupingChecker;
  private Comparator<BaseDescription> selectionPolicy;
  private boolean developmentMode = false;
  private boolean usesCalculationTimeout = false;
  private long usesTimeout = -1L;
  private volatile CompositeResolveHelperRegistry compositeHelpers;
  
  public ResolverImpl(boolean checkPermissions)
  {
    permissionChecker = new PermissionChecker(checkPermissions, this);
  }
  
  PermissionChecker getPermissionChecker()
  {
    return permissionChecker;
  }
  
  private void initialize()
  {
    resolverExports = new VersionHashMap(this);
    resolverBundles = new VersionHashMap(this);
    resolverGenerics = new HashMap();
    unresolvedBundles = new HashSet();
    bundleMapping = new HashMap();
    BundleDescription[] bundles = state.getBundles();
    groupingChecker = new GroupingChecker();
    
    ArrayList<ResolverBundle> fragmentBundles = new ArrayList();
    for (int i = 0; i < bundles.length; i++) {
      initResolverBundle(bundles[i], fragmentBundles, false);
    }
    List<BundleDescription> removedBundles = removalPending.getAllValues();
    for (Iterator localIterator = removedBundles.iterator(); localIterator.hasNext();)
    {
      BundleDescription removed = (BundleDescription)localIterator.next();
      initResolverBundle(removed, fragmentBundles, true);
    }
    BundleDescription[] hosts;
    int i;
    for (Iterator<ResolverBundle> iter = fragmentBundles.iterator(); iter.hasNext(); i < hosts.length)
    {
      ResolverBundle fragment = (ResolverBundle)iter.next();
      hosts = ((HostSpecification)fragment.getHost().getVersionConstraint()).getHosts();
      i = 0; continue;
      ResolverBundle host = (ResolverBundle)bundleMapping.get(hosts[i]);
      if (host != null) {
        host.attachFragment(fragment, false);
      }
      i++;
    }
    rewireBundles();
    setDebugOptions();
    initialized = true;
  }
  
  private void initResolverBundle(BundleDescription bundleDesc, ArrayList<ResolverBundle> fragmentBundles, boolean pending)
  {
    ResolverBundle bundle = new ResolverBundle(bundleDesc, this);
    bundleMapping.put(bundleDesc, bundle);
    if ((!pending) || (bundleDesc.isResolved()))
    {
      resolverExports.put(bundle.getExportPackages());
      resolverBundles.put(bundle.getName(), bundle);
      addGenerics(bundle.getGenericCapabilities());
    }
    if (bundleDesc.isResolved())
    {
      bundle.setState(2);
      if (bundleDesc.getHost() != null) {
        fragmentBundles.add(bundle);
      }
    }
    else if (!pending)
    {
      unresolvedBundles.add(bundle);
    }
  }
  
  private void rewireBundles()
  {
    List<ResolverBundle> visited = new ArrayList(bundleMapping.size());
    for (Iterator localIterator = bundleMapping.values().iterator(); localIterator.hasNext();)
    {
      ResolverBundle rb = (ResolverBundle)localIterator.next();
      if ((rb.getBundleDescription().isResolved()) && (!rb.isFragment())) {
        rewireBundle(rb, visited);
      }
    }
  }
  
  private void rewireBundle(ResolverBundle rb, List<ResolverBundle> visited)
  {
    if (visited.contains(rb)) {
      return;
    }
    visited.add(rb);
    
    BundleConstraint[] requires = rb.getRequires();
    for (int i = 0; i < requires.length; i++) {
      rewireRequire(requires[i], visited);
    }
    ResolverImport[] imports = rb.getImportPackages();
    for (int i = 0; i < imports.length; i++) {
      rewireImport(imports[i], visited);
    }
    GenericConstraint[] genericRequires = rb.getGenericRequires();
    for (int i = 0; i < genericRequires.length; i++) {
      rewireGeneric(genericRequires[i], visited);
    }
  }
  
  private void rewireGeneric(GenericConstraint constraint, List<ResolverBundle> visited)
  {
    if (constraint.getSelectedSupplier() != null) {
      return;
    }
    GenericDescription[] suppliers = ((GenericSpecification)constraint.getVersionConstraint()).getSuppliers();
    if (suppliers == null) {
      return;
    }
    VersionHashMap<GenericCapability> namespace = (VersionHashMap)resolverGenerics.get(constraint.getNameSpace());
    if (namespace == null)
    {
      System.err.println("Could not find matching capability for " + constraint.getVersionConstraint());
      
      return;
    }
    String constraintName = constraint.getName();
    List<GenericCapability> matches = constraintName == null ? namespace.get(constraintName) : namespace.getAllValues();
    int j;
    int i;
    for (Iterator localIterator = matches.iterator(); localIterator.hasNext(); i < j)
    {
      GenericCapability match = (GenericCapability)localIterator.next();
      GenericDescription[] arrayOfGenericDescription1;
      j = (arrayOfGenericDescription1 = suppliers).length;i = 0; continue;GenericDescription supplier = arrayOfGenericDescription1[i];
      if (match.getBaseDescription() == supplier) {
        constraint.addPossibleSupplier(match);
      }
      i++;
    }
    VersionSupplier[] matchingCapabilities = constraint.getPossibleSuppliers();
    if (matchingCapabilities != null) {
      for (int i = 0; i < matchingCapabilities.length; i++) {
        rewireBundle(matchingCapabilities[i].getResolverBundle(), visited);
      }
    }
  }
  
  private void rewireRequire(BundleConstraint req, List<ResolverBundle> visited)
  {
    if (req.getSelectedSupplier() != null) {
      return;
    }
    ResolverBundle matchingBundle = (ResolverBundle)bundleMapping.get(req.getVersionConstraint().getSupplier());
    req.addPossibleSupplier(matchingBundle);
    if ((matchingBundle == null) && (!req.isOptional())) {
      System.err.println("Could not find matching bundle for " + req.getVersionConstraint());
    }
    if (matchingBundle != null) {
      rewireBundle(matchingBundle, visited);
    }
  }
  
  private void rewireImport(ResolverImport imp, List<ResolverBundle> visited)
  {
    if ((imp.isDynamic()) || (imp.getSelectedSupplier() != null)) {
      return;
    }
    ResolverExport matchingExport = null;
    ExportPackageDescription importSupplier = (ExportPackageDescription)imp.getVersionConstraint().getSupplier();
    ResolverBundle exporter = importSupplier == null ? null : (ResolverBundle)bundleMapping.get(importSupplier.getExporter());
    List<ResolverExport> matches = resolverExports.get(imp.getName());
    for (Iterator localIterator = matches.iterator(); localIterator.hasNext();)
    {
      ResolverExport export = (ResolverExport)localIterator.next();
      if ((export.getExporter() == exporter) && (importSupplier == export.getExportPackageDescription()))
      {
        matchingExport = export;
        break;
      }
    }
    imp.addPossibleSupplier(matchingExport);
    if ((imp.getSelectedSupplier() == null) && (!imp.isOptional())) {
      System.err.println("Could not find matching export for " + imp.getVersionConstraint());
    }
    if (imp.getSelectedSupplier() != null) {
      rewireBundle(((ResolverExport)imp.getSelectedSupplier()).getExporter(), visited);
    }
  }
  
  private boolean isResolvable(ResolverBundle bundle, Dictionary<Object, Object>[] platformProperties, Collection<ResolverBundle> hookDisabled)
  {
    BundleDescription bundleDesc = bundle.getBundleDescription();
    if (hookDisabled.contains(bundle))
    {
      state.addResolverError(bundleDesc, 262144, "Resolver hook disabled bundle.", null);
      return false;
    }
    DisabledInfo[] disabledInfos = state.getDisabledInfos(bundleDesc);
    if (disabledInfos.length > 0)
    {
      StringBuffer message = new StringBuffer();
      for (int i = 0; i < disabledInfos.length; i++)
      {
        if (i > 0) {
          message.append(' ');
        }
        message.append('"').append(disabledInfos[i].getPolicyName()).append(':').append(disabledInfos[i].getMessage()).append('"');
      }
      state.addResolverError(bundleDesc, 262144, message.toString(), null);
      return false;
    }
    String[] ees = bundleDesc.getExecutionEnvironments();
    boolean matchedEE = ees.length == 0;
    if (!matchedEE) {
      for (int i = 0; (i < ees.length) && (!matchedEE); i++) {
        for (int j = 0; (j < CURRENT_EES.length) && (!matchedEE); j++) {
          for (int k = 0; (k < CURRENT_EES[j].length) && (!matchedEE); k++) {
            if (CURRENT_EES[j][k].equals(ees[i]))
            {
              ((BundleDescriptionImpl)bundleDesc).setEquinoxEE(j);
              matchedEE = true;
            }
          }
        }
      }
    }
    if (!matchedEE)
    {
      StringBuffer bundleEE = new StringBuffer("Bundle-RequiredExecutionEnvironment".length() + 20);
      bundleEE.append("Bundle-RequiredExecutionEnvironment").append(": ");
      for (int i = 0; i < ees.length; i++)
      {
        if (i > 0) {
          bundleEE.append(",");
        }
        bundleEE.append(ees[i]);
      }
      state.addResolverError(bundleDesc, 16384, bundleEE.toString(), null);
      return false;
    }
    NativeCodeSpecification nativeCode = bundleDesc.getNativeCodeSpecification();
    if (nativeCode != null)
    {
      NativeCodeDescription[] nativeCodeSuppliers = nativeCode.getPossibleSuppliers();
      NativeCodeDescription highestRanked = null;
      for (int i = 0; i < nativeCodeSuppliers.length; i++) {
        if ((nativeCode.isSatisfiedBy(nativeCodeSuppliers[i])) && ((highestRanked == null) || (highestRanked.compareTo(nativeCodeSuppliers[i]) < 0))) {
          highestRanked = nativeCodeSuppliers[i];
        }
      }
      if (highestRanked == null)
      {
        if (!nativeCode.isOptional())
        {
          state.addResolverError(bundleDesc, 65536, nativeCode.toString(), nativeCode);
          return false;
        }
      }
      else if (highestRanked.hasInvalidNativePaths())
      {
        state.addResolverError(bundleDesc, 131072, highestRanked.toString(), nativeCode);
        return false;
      }
      state.resolveConstraint(nativeCode, highestRanked);
    }
    String platformFilter = bundleDesc.getPlatformFilter();
    if (platformFilter == null) {
      return true;
    }
    if (platformProperties == null) {
      return false;
    }
    try
    {
      Filter filter = FilterImpl.newInstance(platformFilter);
      for (int i = 0; i < platformProperties.length; i++)
      {
        Dictionary props = platformProperties[i];
        if (filter.matchCase(props)) {
          return true;
        }
      }
    }
    catch (InvalidSyntaxException localInvalidSyntaxException) {}
    state.addResolverError(bundleDesc, 8192, platformFilter, null);
    return false;
  }
  
  private void attachFragment(ResolverBundle bundle, Collection<String> processedFragments)
  {
    if (processedFragments.contains(bundle.getName())) {
      return;
    }
    processedFragments.add(bundle.getName());
    
    List<ResolverBundle> fragments = resolverBundles.get(bundle.getName());
    for (Iterator localIterator = fragments.iterator(); localIterator.hasNext();)
    {
      ResolverBundle fragment = (ResolverBundle)localIterator.next();
      if (!fragment.isResolved()) {
        attachFragment0(fragment);
      }
    }
  }
  
  private void attachFragment0(ResolverBundle bundle)
  {
    if ((!bundle.isFragment()) || (!bundle.isResolvable())) {
      return;
    }
    boolean foundMatch = false;
    BundleConstraint hostConstraint = bundle.getHost();
    List<ResolverBundle> hosts = resolverBundles.get(hostConstraint.getVersionConstraint().getName());
    List<ResolverBundle> candidates = new ArrayList(hosts);
    List<BundleCapability> hostCapabilities = new ArrayList(hosts.size());
    for (Iterator<ResolverBundle> iCandidates = candidates.iterator(); iCandidates.hasNext();)
    {
      host = (ResolverBundle)iCandidates.next();
      if ((!host.isResolvable()) || (!host.getBundleDescription().attachFragments()) || (!hostConstraint.isSatisfiedBy(host)))
      {
        iCandidates.remove();
      }
      else
      {
        List<BundleCapability> h = host.getBundleDescription().getDeclaredCapabilities("osgi.wiring.host");
        
        hostCapabilities.add((BundleCapability)h.get(0));
      }
    }
    if (hook != null) {
      hook.filterMatches(hostConstraint.getRequirement(), asCapabilities(new ArrayMap(hostCapabilities, candidates)));
    }
    for (ResolverBundle host = candidates.iterator(); host.hasNext();)
    {
      ResolverBundle host = (ResolverBundle)host.next();
      foundMatch = true;
      host.attachFragment(bundle, true);
    }
    if (!foundMatch) {
      state.addResolverError(bundle.getBundleDescription(), 4, bundle.getHost().getVersionConstraint().toString(), bundle.getHost().getVersionConstraint());
    }
  }
  
  /* Error */
  public synchronized void resolve(BundleDescription[] reRefresh, Dictionary<Object, Object>[] platformProperties)
  {
    // Byte code:
    //   0: getstatic 1394	org/eclipse/osgi/internal/module/ResolverImpl:DEBUG	Z
    //   3: ifeq +9 -> 12
    //   6: ldc_w 692
    //   9: invokestatic 1582	org/eclipse/osgi/internal/module/ResolverImpl:log	(Ljava/lang/String;)V
    //   12: aload_0
    //   13: getfield 1416	org/eclipse/osgi/internal/module/ResolverImpl:state	Lorg/eclipse/osgi/service/resolver/State;
    //   16: ifnonnull +14 -> 30
    //   19: new 751	java/lang/IllegalStateException
    //   22: dup
    //   23: ldc_w 717
    //   26: invokespecial 1420	java/lang/IllegalStateException:<init>	(Ljava/lang/String;)V
    //   29: athrow
    //   30: aload_0
    //   31: getfield 1402	org/eclipse/osgi/internal/module/ResolverImpl:initialized	Z
    //   34: ifne +7 -> 41
    //   37: aload_0
    //   38: invokespecial 1575	org/eclipse/osgi/internal/module/ResolverImpl:initialize	()V
    //   41: aload_0
    //   42: aload_0
    //   43: getfield 1416	org/eclipse/osgi/internal/module/ResolverImpl:state	Lorg/eclipse/osgi/service/resolver/State;
    //   46: instanceof 798
    //   49: ifeq +16 -> 65
    //   52: aload_0
    //   53: getfield 1416	org/eclipse/osgi/internal/module/ResolverImpl:state	Lorg/eclipse/osgi/service/resolver/State;
    //   56: checkcast 798	org/eclipse/osgi/internal/resolver/StateImpl
    //   59: invokevirtual 1675	org/eclipse/osgi/internal/resolver/StateImpl:getResolverHook	()Lorg/osgi/framework/hooks/resolver/ResolverHook;
    //   62: goto +4 -> 66
    //   65: aconst_null
    //   66: putfield 1417	org/eclipse/osgi/internal/module/ResolverImpl:hook	Lorg/osgi/framework/hooks/resolver/ResolverHook;
    //   69: aload_0
    //   70: aload_2
    //   71: arraylength
    //   72: ifne +7 -> 79
    //   75: iconst_0
    //   76: goto +18 -> 94
    //   79: ldc_w 724
    //   82: aload_2
    //   83: iconst_0
    //   84: aaload
    //   85: ldc_w 732
    //   88: invokevirtual 1448	java/util/Dictionary:get	(Ljava/lang/Object;)Ljava/lang/Object;
    //   91: invokevirtual 1428	java/lang/String:equals	(Ljava/lang/Object;)Z
    //   94: putfield 1401	org/eclipse/osgi/internal/module/ResolverImpl:developmentMode	Z
    //   97: aload_2
    //   98: arraylength
    //   99: ifne +7 -> 106
    //   102: aconst_null
    //   103: goto +12 -> 115
    //   106: aload_2
    //   107: iconst_0
    //   108: aaload
    //   109: ldc_w 734
    //   112: invokevirtual 1448	java/util/Dictionary:get	(Ljava/lang/Object;)Ljava/lang/Object;
    //   115: astore_3
    //   116: aload_0
    //   117: aload_3
    //   118: ifnonnull +9 -> 127
    //   121: ldc2_w 663
    //   124: goto +10 -> 134
    //   127: aload_3
    //   128: invokevirtual 1426	java/lang/Object:toString	()Ljava/lang/String;
    //   131: invokestatic 1423	java/lang/Long:parseLong	(Ljava/lang/String;)J
    //   134: putfield 1393	org/eclipse/osgi/internal/module/ResolverImpl:usesTimeout	J
    //   137: goto +11 -> 148
    //   140: pop
    //   141: aload_0
    //   142: ldc2_w 663
    //   145: putfield 1393	org/eclipse/osgi/internal/module/ResolverImpl:usesTimeout	J
    //   148: aload_0
    //   149: aload_1
    //   150: invokespecial 1627	org/eclipse/osgi/internal/module/ResolverImpl:addDevConstraints	([Lorg/eclipse/osgi/service/resolver/BundleDescription;)[Lorg/eclipse/osgi/service/resolver/BundleDescription;
    //   153: astore_1
    //   154: aload_1
    //   155: ifnull +44 -> 199
    //   158: iconst_0
    //   159: istore_3
    //   160: goto +33 -> 193
    //   163: aload_0
    //   164: getfield 1406	org/eclipse/osgi/internal/module/ResolverImpl:bundleMapping	Ljava/util/HashMap;
    //   167: aload_1
    //   168: iload_3
    //   169: aaload
    //   170: invokevirtual 1453	java/util/HashMap:get	(Ljava/lang/Object;)Ljava/lang/Object;
    //   173: checkcast 789	org/eclipse/osgi/internal/module/ResolverBundle
    //   176: astore 4
    //   178: aload 4
    //   180: ifnull +10 -> 190
    //   183: aload_0
    //   184: aload 4
    //   186: iconst_0
    //   187: invokespecial 1598	org/eclipse/osgi/internal/module/ResolverImpl:unresolveBundle	(Lorg/eclipse/osgi/internal/module/ResolverBundle;Z)V
    //   190: iinc 3 1
    //   193: iload_3
    //   194: aload_1
    //   195: arraylength
    //   196: if_icmplt -33 -> 163
    //   199: aload_0
    //   200: getfield 1415	org/eclipse/osgi/internal/module/ResolverImpl:resolverExports	Lorg/eclipse/osgi/internal/module/VersionHashMap;
    //   203: invokevirtual 1660	org/eclipse/osgi/internal/module/VersionHashMap:reorder	()V
    //   206: aload_0
    //   207: getfield 1414	org/eclipse/osgi/internal/module/ResolverImpl:resolverBundles	Lorg/eclipse/osgi/internal/module/VersionHashMap;
    //   210: invokevirtual 1660	org/eclipse/osgi/internal/module/VersionHashMap:reorder	()V
    //   213: aload_0
    //   214: invokespecial 1577	org/eclipse/osgi/internal/module/ResolverImpl:reorderGenerics	()V
    //   217: aload_0
    //   218: aload_2
    //   219: invokespecial 1583	org/eclipse/osgi/internal/module/ResolverImpl:getCurrentEEs	([Ljava/util/Dictionary;)V
    //   222: aload_2
    //   223: arraylength
    //   224: ifne +7 -> 231
    //   227: iconst_0
    //   228: goto +18 -> 246
    //   231: ldc_w 740
    //   234: aload_2
    //   235: iconst_0
    //   236: aaload
    //   237: ldc_w 730
    //   240: invokevirtual 1448	java/util/Dictionary:get	(Ljava/lang/Object;)Ljava/lang/Object;
    //   243: invokevirtual 1428	java/lang/String:equals	(Ljava/lang/Object;)Z
    //   246: istore_3
    //   247: aconst_null
    //   248: checkcast 744	[Lorg/eclipse/osgi/internal/module/ResolverBundle;
    //   251: astore 4
    //   253: iload_3
    //   254: ifeq +59 -> 313
    //   257: aload_0
    //   258: getfield 1416	org/eclipse/osgi/internal/module/ResolverImpl:state	Lorg/eclipse/osgi/service/resolver/State;
    //   261: invokeinterface 1746 1 0
    //   266: astore 5
    //   268: aload 5
    //   270: arraylength
    //   271: anewarray 789	org/eclipse/osgi/internal/module/ResolverBundle
    //   274: astore 4
    //   276: iconst_0
    //   277: istore 6
    //   279: goto +26 -> 305
    //   282: aload 4
    //   284: iload 6
    //   286: aload_0
    //   287: getfield 1406	org/eclipse/osgi/internal/module/ResolverImpl:bundleMapping	Ljava/util/HashMap;
    //   290: aload 5
    //   292: iload 6
    //   294: aaload
    //   295: invokevirtual 1453	java/util/HashMap:get	(Ljava/lang/Object;)Ljava/lang/Object;
    //   298: checkcast 789	org/eclipse/osgi/internal/module/ResolverBundle
    //   301: aastore
    //   302: iinc 6 1
    //   305: iload 6
    //   307: aload 5
    //   309: arraylength
    //   310: if_icmplt -28 -> 282
    //   313: getstatic 1389	java/util/Collections:EMPTY_LIST	Ljava/util/List;
    //   316: astore 5
    //   318: aload_0
    //   319: getfield 1417	org/eclipse/osgi/internal/module/ResolverImpl:hook	Lorg/osgi/framework/hooks/resolver/ResolverHook;
    //   32
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd