org.eclipse.osgi_3.7.2.v20120110-1415

et();
  private final Map<BundleDescription, List<DisabledInfo>> disabledBundles = new HashMap();
  private boolean fullyLoaded = false;
  private boolean dynamicCacheChanged = false;
  private StateReader reader;
  private Dictionary<Object, Object>[] platformProperties = { new Hashtable(PROPS.length) };
  private long highestBundleId = -1L;
  private final Set<String> platformPropertyKeys = new HashSet(PROPS.length);
  private ResolverHookFactory hookFactory;
  private ResolverHook hook;
  private boolean developmentMode = false;
  private static long cumulativeTime;
  final Object monitor = new Object();
  
  protected StateImpl()
  {
    addPlatformPropertyKeys(PROPS);
  }
  
  public boolean addBundle(BundleDescription description)
  {
    synchronized (monitor)
    {
      if (!basicAddBundle(description)) {
        return false;
      }
      String platformFilter = description.getPlatformFilter();
      if (platformFilter != null) {
        try
        {
          FilterImpl filter = FilterImpl.newInstance(platformFilter);
          addPlatformPropertyKeys(filter.getAttributes());
        }
        catch (InvalidSyntaxException localInvalidSyntaxException) {}
      }
      NativeCodeSpecification nativeCode = description.getNativeCodeSpecification();
      if (nativeCode != null)
      {
        NativeCodeDescription[] suppliers = nativeCode.getPossibleSuppliers();
        for (int i = 0; i < suppliers.length; i++)
        {
          FilterImpl filter = (FilterImpl)suppliers[i].getFilter();
          if (filter != null) {
            addPlatformPropertyKeys(filter.getAttributes());
          }
        }
      }
      resolved = false;
      getDelta().recordBundleAdded((BundleDescriptionImpl)description);
      if (getSystemBundle().equals(description.getSymbolicName())) {
        resetAllSystemCapabilities();
      }
      if (resolver != null) {
        resolver.bundleAdded(description);
      }
      updateTimeStamp();
      return true;
    }
  }
  
  public boolean updateBundle(BundleDescription newDescription)
  {
    synchronized (monitor)
    {
      BundleDescriptionImpl existing = (BundleDescriptionImpl)bundleDescriptions.get((BundleDescriptionImpl)newDescription);
      if (existing == null) {
        return false;
      }
      if (!bundleDescriptions.remove(existing)) {
        return false;
      }
      resolvedBundles.remove(existing);
      List<DisabledInfo> infos = (List)disabledBundles.remove(existing);
      if (infos != null)
      {
        List<DisabledInfo> newInfos = new ArrayList(infos.size());
        for (iInfos = infos.iterator(); iInfos.hasNext();)
        {
          DisabledInfo info = (DisabledInfo)iInfos.next();
          newInfos.add(new DisabledInfo(info.getPolicyName(), info.getMessage(), newDescription));
        }
        disabledBundles.put(newDescription, newInfos);
      }
      existing.setStateBit(4, true);
      if (!basicAddBundle(newDescription)) {
        return false;
      }
      resolved = false;
      getDelta().recordBundleUpdated((BundleDescriptionImpl)newDescription);
      if (getSystemBundle().equals(newDescription.getSymbolicName())) {
        resetAllSystemCapabilities();
      }
      if (resolver != null)
      {
        boolean pending = isInUse(existing);
        resolver.bundleUpdated(newDescription, existing, pending);
        if (pending)
        {
          getDelta().recordBundleRemovalPending(existing);
          addRemovalPending(existing);
        }
        else
        {
          try
          {
            resolving = true;
            resolverErrors.remove(existing);
            resolveBundle(existing, false, null, null, null, null, null, null, null, null);
          }
          finally
          {
            resolving = false;
          }
        }
      }
      updateTimeStamp();
      return true;
    }
  }
  
  public BundleDescription removeBundle(long bundleId)
  {
    synchronized (monitor)
    {
      BundleDescription toRemove = getBundle(bundleId);
      if ((toRemove == null) || (!removeBundle(toRemove))) {
        return null;
      }
      return toRemove;
    }
  }
  
  /* Error */
  public boolean removeBundle(BundleDescription toRemove)
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 974	org/eclipse/osgi/internal/resolver/StateImpl:monitor	Ljava/lang/Object;
    //   4: dup
    //   5: astore_2
    //   6: monitorenter
    //   7: aload_0
    //   8: getfield 981	org/eclipse/osgi/internal/resolver/StateImpl:bundleDescriptions	Lorg/eclipse/osgi/framework/util/KeyedHashSet;
    //   11: aload_1
    //   12: checkcast 528	org/eclipse/osgi/framework/util/KeyedElement
    //   15: invokevirtual 1050	org/eclipse/osgi/framework/util/KeyedHashSet:get	(Lorg/eclipse/osgi/framework/util/KeyedElement;)Lorg/eclipse/osgi/framework/util/KeyedElement;
    //   18: checkcast 548	org/eclipse/osgi/service/resolver/BundleDescription
    //   21: astore_1
    //   22: aload_1
    //   23: ifnull +17 -> 40
    //   26: aload_0
    //   27: getfield 981	org/eclipse/osgi/internal/resolver/StateImpl:bundleDescriptions	Lorg/eclipse/osgi/framework/util/KeyedHashSet;
    //   30: aload_1
    //   31: checkcast 528	org/eclipse/osgi/framework/util/KeyedElement
    //   34: invokevirtual 1047	org/eclipse/osgi/framework/util/KeyedHashSet:remove	(Lorg/eclipse/osgi/framework/util/KeyedElement;)Z
    //   37: ifne +7 -> 44
    //   40: aload_2
    //   41: monitorexit
    //   42: iconst_0
    //   43: ireturn
    //   44: aload_0
    //   45: getfield 982	org/eclipse/osgi/internal/resolver/StateImpl:resolvedBundles	Lorg/eclipse/osgi/framework/util/KeyedHashSet;
    //   48: aload_1
    //   49: checkcast 528	org/eclipse/osgi/framework/util/KeyedElement
    //   52: invokevirtual 1047	org/eclipse/osgi/framework/util/KeyedHashSet:remove	(Lorg/eclipse/osgi/framework/util/KeyedElement;)Z
    //   55: pop
    //   56: aload_0
    //   57: getfield 978	org/eclipse/osgi/internal/resolver/StateImpl:disabledBundles	Ljava/util/Map;
    //   60: aload_1
    //   61: invokeinterface 1175 2 0
    //   66: pop
    //   67: aload_0
    //   68: iconst_0
    //   69: putfield 972	org/eclipse/osgi/internal/resolver/StateImpl:resolved	Z
    //   72: aload_0
    //   73: invokespecial 1119	org/eclipse/osgi/internal/resolver/StateImpl:getDelta	()Lorg/eclipse/osgi/internal/resolver/StateDeltaImpl;
    //   76: aload_1
    //   77: checkcast 532	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl
    //   80: invokevirtual 1092	org/eclipse/osgi/internal/resolver/StateDeltaImpl:recordBundleRemoved	(Lorg/eclipse/osgi/internal/resolver/BundleDescriptionImpl;)V
    //   83: aload_1
    //   84: checkcast 532	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl
    //   87: iconst_4
    //   88: iconst_1
    //   89: invokevirtual 1055	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl:setStateBit	(IZ)V
    //   92: aload_0
    //   93: getfield 986	org/eclipse/osgi/internal/resolver/StateImpl:resolver	Lorg/eclipse/osgi/service/resolver/Resolver;
    //   96: ifnull +88 -> 184
    //   99: aload_0
    //   100: aload_1
    //   101: invokespecial 1126	org/eclipse/osgi/internal/resolver/StateImpl:isInUse	(Lorg/eclipse/osgi/service/resolver/BundleDescription;)Z
    //   104: istore_3
    //   105: aload_0
    //   106: getfield 986	org/eclipse/osgi/internal/resolver/StateImpl:resolver	Lorg/eclipse/osgi/service/resolver/Resolver;
    //   109: aload_1
    //   110: iload_3
    //   111: invokeinterface 1203 3 0
    //   116: iload_3
    //   117: ifeq +22 -> 139
    //   120: aload_0
    //   121: invokespecial 1119	org/eclipse/osgi/internal/resolver/StateImpl:getDelta	()Lorg/eclipse/osgi/internal/resolver/StateDeltaImpl;
    //   124: aload_1
    //   125: checkcast 532	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl
    //   128: invokevirtual 1091	org/eclipse/osgi/internal/resolver/StateDeltaImpl:recordBundleRemovalPending	(Lorg/eclipse/osgi/internal/resolver/BundleDescriptionImpl;)V
    //   131: aload_0
    //   132: aload_1
    //   133: invokespecial 1124	org/eclipse/osgi/internal/resolver/StateImpl:addRemovalPending	(Lorg/eclipse/osgi/service/resolver/BundleDescription;)V
    //   136: goto +48 -> 184
    //   139: aload_0
    //   140: iconst_1
    //   141: putfield 973	org/eclipse/osgi/internal/resolver/StateImpl:resolving	Z
    //   144: aload_0
    //   145: getfield 979	org/eclipse/osgi/internal/resolver/StateImpl:resolverErrors	Ljava/util/Map;
    //   148: aload_1
    //   149: invokeinterface 1175 2 0
    //   154: pop
    //   155: aload_0
    //   156: aload_1
    //   157: iconst_0
    //   158: aconst_null
    //   159: aconst_null
    //   160: aconst_null
    //   161: aconst_null
    //   162: aconst_null
    //   163: invokevirtual 1140	org/eclipse/osgi/internal/resolver/StateImpl:resolveBundle	(Lorg/eclipse/osgi/service/resolver/BundleDescription;Z[Lorg/eclipse/osgi/service/resolver/BundleDescription;[Lorg/eclipse/osgi/service/resolver/ExportPackageDescription;[Lorg/eclipse/osgi/service/resolver/ExportPackageDescription;[Lorg/eclipse/osgi/service/resolver/BundleDescription;[Lorg/eclipse/osgi/service/resolver/ExportPackageDescription;)V
    //   166: goto +13 -> 179
    //   169: astore 4
    //   171: aload_0
    //   172: iconst_0
    //   173: putfield 973	org/eclipse/osgi/internal/resolver/StateImpl:resolving	Z
    //   176: aload 4
    //   178: athrow
    //   179: aload_0
    //   180: iconst_0
    //   181: putfield 973	org/eclipse/osgi/internal/resolver/StateImpl:resolving	Z
    //   184: aload_0
    //   185: invokespecial 1105	org/eclipse/osgi/internal/resolver/StateImpl:updateTimeStamp	()V
    //   188: aload_2
    //   189: monitorexit
    //   190: iconst_1
    //   191: ireturn
    //   192: aload_2
    //   193: monitorexit
    //   194: athrow
    // Line number table:
    //   Java source line #163	-> byte code offset #0
    //   Java source line #164	-> byte code offset #7
    //   Java source line #165	-> byte code offset #22
    //   Java source line #166	-> byte code offset #40
    //   Java source line #167	-> byte code offset #44
    //   Java source line #168	-> byte code offset #56
    //   Java source line #169	-> byte code offset #67
    //   Java source line #170	-> byte code offset #72
    //   Java source line #171	-> byte code offset #83
    //   Java source line #172	-> byte code offset #92
    //   Java source line #173	-> byte code offset #99
    //   Java source line #174	-> byte code offset #105
    //   Java source line #175	-> byte code offset #116
    //   Java source line #176	-> byte code offset #120
    //   Java source line #177	-> byte code offset #131
    //   Java source line #181	-> byte code offset #139
    //   Java source line #182	-> byte code offset #144
    //   Java source line #183	-> byte code offset #155
    //   Java source line #184	-> byte code offset #169
    //   Java source line #185	-> byte code offset #171
    //   Java source line #186	-> byte code offset #176
    //   Java source line #185	-> byte code offset #179
    //   Java source line #189	-> byte code offset #184
    //   Java source line #190	-> byte code offset #188
    //   Java source line #163	-> byte code offset #192
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	195	0	this	StateImpl
    //   0	195	1	toRemove	BundleDescription
    //   5	188	2	Ljava/lang/Object;	Object
    //   104	13	3	pending	boolean
    //   169	8	4	localObject1	Object
    // Exception table:
    //   from	to	target	type
    //   139	169	169	finally
    //   7	42	192	finally
    //   44	190	192	finally
    //   192	194	192	finally
  }
  
  private boolean isInUse(BundleDescription bundle)
  {
    Object userObject = bundle.getUserObject();
    if ((userObject instanceof BundleLoaderProxy)) {
      return ((BundleLoaderProxy)userObject).inUse();
    }
    return bundle.getDependents().length > 0;
  }
  
  /* Error */
  public StateDelta getChanges()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 974	org/eclipse/osgi/internal/resolver/StateImpl:monitor	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: invokespecial 1119	org/eclipse/osgi/internal/resolver/StateImpl:getDelta	()Lorg/eclipse/osgi/internal/resolver/StateDeltaImpl;
    //   11: aload_1
    //   12: monitorexit
    //   13: areturn
    //   14: aload_1
    //   15: monitorexit
    //   16: athrow
    // Line number table:
    //   Java source line #202	-> byte code offset #0
    //   Java source line #203	-> byte code offset #7
    //   Java source line #202	-> byte code offset #14
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	17	0	this	StateImpl
    //   5	10	1	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   7	13	14	finally
    //   14	16	14	finally
  }
  
  private StateDeltaImpl getDelta()
  {
    if (changes == null) {
      changes = new StateDeltaImpl(this);
    }
    return changes;
  }
  
  public BundleDescription[] getBundles(String symbolicName)
  {
    synchronized (monitor)
    {
      if ("system.bundle".equals(symbolicName)) {
        symbolicName = getSystemBundle();
      }
      List<BundleDescription> bundles = new ArrayList();
      for (Iterator<KeyedElement> iter = bundleDescriptions.iterator(); iter.hasNext();)
      {
        BundleDescription bundle = (BundleDescription)iter.next();
        if (symbolicName.equals(bundle.getSymbolicName())) {
          bundles.add(bundle);
        }
      }
      return (BundleDescription[])bundles.toArray(new BundleDescription[bundles.size()]);
    }
  }
  
  /* Error */
  public BundleDescription[] getBundles()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 974	org/eclipse/osgi/internal/resolver/StateImpl:monitor	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: getfield 981	org/eclipse/osgi/internal/resolver/StateImpl:bundleDescriptions	Lorg/eclipse/osgi/framework/util/KeyedHashSet;
    //   11: aload_0
    //   12: getfield 981	org/eclipse/osgi/internal/resolver/StateImpl:bundleDescriptions	Lorg/eclipse/osgi/framework/util/KeyedHashSet;
    //   15: invokevirtual 1040	org/eclipse/osgi/framework/util/KeyedHashSet:size	()I
    //   18: anewarray 548	org/eclipse/osgi/service/resolver/BundleDescription
    //   21: invokevirtual 1048	org/eclipse/osgi/framework/util/KeyedHashSet:elements	([Ljava/lang/Object;)[Ljava/lang/Object;
    //   24: checkcast 495	[Lorg/eclipse/osgi/service/resolver/BundleDescription;
    //   27: aload_1
    //   28: monitorexit
    //   29: areturn
    //   30: aload_1
    //   31: monitorexit
    //   32: athrow
    // Line number table:
    //   Java source line #228	-> byte code offset #0
    //   Java source line #229	-> byte code offset #7
    //   Java source line #228	-> byte code offset #30
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	33	0	this	StateImpl
    //   5	26	1	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   7	29	30	finally
    //   30	32	30	finally
  }
  
  public BundleDescription getBundle(long id)
  {
    synchronized (monitor)
    {
      BundleDescription result = (BundleDescription)bundleDescriptions.getByKey(new Long(id));
      if (result != null) {
        return result;
      }
      for (Iterator<BundleDescription> iter = removalPendings.iterator(); iter.hasNext();)
      {
        BundleDescription removedBundle = (BundleDescription)iter.next();
        if (removedBundle.getBundleId() == id) {
          return removedBundle;
        }
      }
      return null;
    }
  }
  
  public BundleDescription getBundle(String name, Version version)
  {
    synchronized (monitor)
    {
      BundleDescription[] allBundles = getBundles(name);
      if (allBundles.length == 1) {
        return (version == null) || (allBundles[0].getVersion().equals(version)) ? allBundles[0] : null;
      }
      if (allBundles.length == 0) {
        return null;
      }
      BundleDescription unresolvedFound = null;
      BundleDescription resolvedFound = null;
      for (int i = 0; i < allBundles.length; i++)
      {
        BundleDescription current = allBundles[i];
        BundleDescription base;
        BundleDescription base;
        if (current.isResolved()) {
          base = resolvedFound;
        } else {
          base = unresolvedFound;
        }
        if ((version == null) || (current.getVersion().equals(version))) {
          if ((base != null) && ((base.getVersion().compareTo(current.getVersion()) <= 0) || (base.getBundleId() > current.getBundleId())))
          {
            if (base == resolvedFound) {
              resolvedFound = current;
            } else {
              unresolvedFound = current;
            }
          }
          else if (current.isResolved()) {
            resolvedFound = current;
          } else {
            unresolvedFound = current;
          }
        }
      }
      if (resolvedFound != null) {
        return resolvedFound;
      }
      return unresolvedFound;
    }
  }
  
  /* Error */
  public long getTimeStamp()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 974	org/eclipse/osgi/internal/resolver/StateImpl:monitor	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: getfield 968	org/eclipse/osgi/internal/resolver/StateImpl:timeStamp	J
    //   11: aload_1
    //   12: monitorexit
    //   13: lreturn
    //   14: aload_1
    //   15: monitorexit
    //   16: athrow
    // Line number table:
    //   Java source line #288	-> byte code offset #0
    //   Java source line #289	-> byte code offset #7
    //   Java source line #288	-> byte code offset #14
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	17	0	this	StateImpl
    //   5	10	1	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   7	13	14	finally
    //   14	16	14	finally
  }
  
  public boolean isResolved()
  {
    synchronized (monitor)
    {
      return (resolved) || (isEmpty());
    }
  }
  
  public void resolveConstraint(VersionConstraint constraint, BaseDescription supplier)
  {
    ((VersionConstraintImpl)constraint).setSupplier(supplier);
  }
  
  /**
   * @deprecated
   */
  public void resolveBundle(BundleDescription bundle, boolean status, BundleDescription[] hosts, ExportPackageDescription[] selectedExports, BundleDescription[] resolvedRequires, ExportPackageDescription[] resolvedImports)
  {
    resolveBundle(bundle, status, hosts, selectedExports, null, resolvedRequires, resolvedImports);
  }
  
  /**
   * @deprecated
   */
  public void resolveBundle(BundleDescription bundle, boolean status, BundleDescription[] hosts, ExportPackageDescription[] selectedExports, ExportPackageDescription[] substitutedExports, BundleDescription[] resolvedRequires, ExportPackageDescription[] resolvedImports)
  {
    resolveBundle(bundle, status, hosts, selectedExports, substitutedExports, null, resolvedRequires, resolvedImports, null, null);
  }
  
  public void resolveBundle(BundleDescription bundle, boolean status, BundleDescription[] hosts, ExportPackageDescription[] selectedExports, ExportPackageDescription[] substitutedExports, GenericDescription[] selectedCapabilities, BundleDescription[] resolvedRequires, ExportPackageDescription[] resolvedImports, GenericDescription[] resolvedCapabilities, Map<String, List<StateWire>> resolvedWires)
  {
    synchronized (monitor)
    {
      if (!resolving) {
        throw new IllegalStateException();
      }
      BundleDescriptionImpl modifiable = (BundleDescriptionImpl)bundle;
      
      getDelta().recordBundleResolved(modifiable, status);
      
      modifiable.setLazyLoaded(false);
      modifiable.setStateBit(1, status);
      if (status)
      {
        resolverErrors.remove(modifiable);
        resolvedBundles.add(modifiable);
      }
      else
      {
        resolvedBundles.remove(modifiable);
        modifiable.removeDependencies();
      }
      if ((selectedExports == null) || (resolvedRequires == null) || (resolvedImports == null)) {
        unresolveConstraints(modifiable);
      } else {
        resolveConstraints(modifiable, hosts, selectedExports, substitutedExports, selectedCapabilities, resolvedRequires, resolvedImports, resolvedCapabilities, resolvedWires);
      }
    }
  }
  
  public void removeBundleComplete(BundleDescription bundle)
  {
    synchronized (monitor)
    {
      if (!resolving) {
        throw new IllegalStateException();
      }
      getDelta().recordBundleRemovalComplete((BundleDescriptionImpl)bundle);
      removalPendings.remove(bundle);
    }
  }
  
  private void resolveConstraints(BundleDescriptionImpl bundle, BundleDescription[] hosts, ExportPackageDescription[] selectedExports, ExportPackageDescription[] substitutedExports, GenericDescription[] selectedCapabilities, BundleDescription[] resolvedRequires, ExportPackageDescription[] resolvedImports, GenericDescription[] resolvedCapabilities, Map<String, List<StateWire>> resolvedWires)
  {
    HostSpecificationImpl hostSpec = (HostSpecificationImpl)bundle.getHost();
    if ((hostSpec != null) && 
      (hosts != null))
    {
      hostSpec.setHosts(hosts);
      for (int i = 0; i < hosts.length; i++)
      {
        ((BundleDescriptionImpl)hosts[i]).addDependency(bundle, true);
        checkHostForSubstitutedExports((BundleDescriptionImpl)hosts[i], bundle);
      }
    }
    bundle.setSelectedExports(selectedExports);
    bundle.setResolvedRequires(resolvedRequires);
    bundle.setResolvedImports(resolvedImports);
    bundle.setSubstitutedExports(substitutedExports);
    bundle.setSelectedCapabilities(selectedCapabilities);
    bundle.setResolvedCapabilities(resolvedCapabilities);
    bundle.setStateWires(resolvedWires);
    
    bundle.addDependencies(hosts, true);
    bundle.addDependencies(resolvedRequires, true);
    bundle.addDependencies(resolvedImports, true);
    bundle.addDependencies(resolvedCapabilities, true);
  }
  
  private void checkHostForSubstitutedExports(BundleDescriptionImpl host, BundleDescriptionImpl fragment) {}
  
  private void unresolveConstraints(BundleDescriptionImpl bundle)
  {
    HostSpecificationImpl host = (HostSpecificationImpl)bundle.getHost();
    if (host != null) {
      host.setHosts(null);
    }
    bundle.setSelectedExports(null);
    bundle.setResolvedImports(null);
    bundle.setResolvedRequires(null);
    bundle.setSubstitutedExports(null);
    bundle.setSelectedCapabilities(null);
    bundle.setResolvedCapabilities(null);
    bundle.setStateWires(null);
    bundle.clearAddedDynamicImportPackages();
    
    NativeCodeSpecificationImpl nativeCode = (NativeCodeSpecificationImpl)bundle.getNativeCodeSpecification();
    if (nativeCode != null) {
      nativeCode.setSupplier(null);
    }
    ImportPackageSpecification[] imports = bundle.getImportPackages();
    for (int i = 0; i < imports.length; i++) {
      ((ImportPackageSpecificationImpl)imports[i]).setSupplier(null);
    }
    BundleSpecification[] requires = bundle.getRequiredBundles();
    for (int i = 0; i < requires.length; i++) {
      ((BundleSpecificationImpl)requires[i]).setSupplier(null);
    }
    GenericSpecification[] genericRequires = bundle.getGenericRequires();
    if (genericRequires.length > 0) {
      for (int i = 0; i < genericRequires.length; i++) {
        ((GenericSpecificationImpl)genericRequires[i]).setSupplers(null);
      }
    }
    bundle.removeDependencies();
  }
  
  private StateDelta resolve(boolean incremental, BundleDescription[] reResolve, BundleDescription[] triggers)
  {
    fullyLoad();
    synchronized (monitor)
    {
      if (resolver == null) {
        throw new IllegalStateException("no resolver set");
      }
      if (resolving) {
        throw new IllegalStateException("An attempt to start a nested resolve process has been detected.");
      }
      ResolverHook currentHook = null;
      try
      {
        resolving = true;
        long start = 0L;
        if (StateManager.DEBUG_PLATFORM_ADMIN_RESOLVER) {
          start = System.currentTimeMillis();
        }
        long start;
        if (!incremental)
        {
          resolved = false;
          reResolve = getBundles();
          if (removalPendings.size() > 0)
          {
            BundleDescription[] removed = internalGetRemovalPending();
            reResolve = mergeBundles(reResolve, removed);
          }
          flush(reResolve);
        }
        else
        {
          if ((resolved) && (reResolve == null))
          {
            localStateDeltaImpl1 = new StateDeltaImpl(this);
            if (currentHook != null) {
              currentHook.end();
            }
            resolving = false;return localStateDeltaImpl1;
          }
          if (developmentMode) {
            if (removalPendings.size() > 0)
            {
              BundleDescription[] removed = internalGetRemovalPending();
              reResolve = mergeBundles(reResolve, removed);
            }
          }
          if (reResolve == null) {
            reResolve = internalGetRemovalPending();
          }
          if (triggers == null)
          {
            Set<BundleDescription> triggerSet = new HashSet();
            Collection<BundleDescription> closure = getDependencyClosure(Arrays.asList(reResolve));
            for (Iterator localIterator = closure.iterator(); localIterator.hasNext();)
            {
              BundleDescription toRefresh = (BundleDescription)localIterator.next();
              Bundle bundle = toRefresh.getBundle();
              if ((bundle != null) && ((bundle.getState() & 0x7) == 0)) {
                triggerSet.add(toRefresh);
              }
            }
            triggers = (BundleDescription[])triggerSet.toArray(new BundleDescription[triggerSet.size()]);
          }
        }
        Headers[] tmpPlatformProperties = new Headers[platformProperties.length];
        for (int i = 0; i < platformProperties.length; i++)
        {
          tmpPlatformProperties[i] = new Headers(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)
        {
          Collection<BundleRevision> triggerRevisions = Collections.unmodifiableCollection(triggers == null ? Collections.EMPTY_LIST : Arrays.asList(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);
          cumulativeTime += time;
          FrameworkDebugOptions.getDefault().setOption("org.eclipse.core.runtime.adaptor/resolver/timing/value", Long.toString(cumulativeTime));
        }
        if (savedChanges.getChanges().length > 0) {
          updateTimeStamp();
        }
        StateDeltaImpl localStateDeltaImpl1 = savedChanges;
        if (currentHook != null) {
          currentHook.end();
        }
        resolving = false;return localStateDeltaImpl1;
      }
      finally
      {
        if (currentHook != null) {
          currentHook.end();
        }
        resolving = false;
      }
    }
  }
  
  private BundleDescription[] mergeBundles(BundleDescription[] reResolve, BundleDescription[] removed)
  {
    if (reResolve == null) {
      return removed;
    }
    if (reResolve.length == 0) {
      return reResolve;
    }
    List<BundleDescription> result = new ArrayList(reResolve.length + removed.length);
    for (int i = 0; i < reResolve.length; i++) {
      result.add(reResolve[i]);
    }
    for (int i = 0; i < removed.length; i++)
    {
      boolean found = false;
      for (int j = 0; j < reResolve.length; j++) {
        if (removed[i] == reResolve[j])
        {
          found = true;
          break;
        }
      }
      if (!found) {
        result.add(removed[i]);
      }
    }
    return (BundleDescription[])result.toArray(new BundleDescription[result.size()]);
  }
  
  private void flush(BundleDescription[] bundles)
  {
    resolver.flush();
    resolved = false;
    resolverErrors.clear();
    if (resolvedBundles.isEmpty()) {
      return;
    }
    for (int i = 0; i < bundles.length; i++) {
      resolveBundle(bundles[i], false, null, null, null, null, null);
    }
    resolvedBundles.clear();
  }
  
  public StateDelta resolve()
  {
    return resolve(true, null, null);
  }
  
  public StateDelta resolve(boolean incremental)
  {
    return resolve(incremental, null, null);
  }
  
  public StateDelta resolve(BundleDescription[] reResolve)
  {
    return resolve(true, reResolve, null);
  }
  
  public StateDelta resolve(BundleDescription[] resolve, boolean discard)
  {
    BundleDescription[] reResolve = discard ? resolve : new BundleDescription[0];
    BundleDescription[] triggers = discard ? null : resolve;
    return resolve(true, reResolve, triggers);
  }
  
  public void setOverrides(Object value)
  {
    throw new UnsupportedOperationException();
  }
  
  public void setResolverHookFactory(ResolverHookFactory hookFactory)
  {
    synchronized (monitor)
    {
      if (this.hookFactory != null) {
        throw new IllegalStateException("Resolver hook factory is already set.");
      }
      this.hookFactory = hookFactory;
    }
  }
  
  private ResolverHook begin(Collection<BundleRevision> triggers)
  {
    ResolverHookFactory current;
    synchronized (monitor)
    {
      current = hookFactory;
    }
    ResolverHookFactory current;
    ResolverHook newHook = current.begin(triggers);
    synchronized (monitor)
    {
      hook = newHook;
    }
    return newHook;
  }
  
  /* Error */
  ResolverHookFactory getResolverHookFactory()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 974	org/eclipse/osgi/internal/resolver/StateImpl:monitor	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: getfield 989	org/eclipse/osgi/internal/resolver/StateImpl:hookFactory	Lorg/osgi/framework/hooks/resolver/ResolverHookFactory;
    //   11: aload_1
    //   12: monitorexit
    //   13: areturn
    //   14: aload_1
    //   15: monitorexit
    //   16: athrow
    // Line number table:
    //   Java source line #588	-> byte code offset #0
    //   Java source line #589	-> byte code offset #7
    //   Java source line #588	-> byte code offset #14
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	17	0	this	StateImpl
    //   5	10	1	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   7	13	14	finally
    //   14	16	14	finally
  }
  
  /* Error */
  public ResolverHook getResolverHook()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 974	org/eclipse/osgi/internal/resolver/StateImpl:monitor	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: getfield 988	org/eclipse/osgi/internal/resolver/StateImpl:hook	Lorg/osgi/framework/hooks/resolver/ResolverHook;
    //   11: aload_1
    //   12: monitorexit
    //   13: areturn
    //   14: aload_1
    //   15: monitorexit
    //   16: athrow
    // Line number table:
    //   Java source line #594	-> byte code offset #0
    //   Java source line #595	-> byte code offset #7
    //   Java source line #594	-> byte code offset #14
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	17	0	this	StateImpl
    //   5	10	1	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   7	13	14	finally
    //   14	16	14	finally
  }
  
  /* Error */
  public BundleDescription[] getResolvedBundles()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 974	org/eclipse/osgi/internal/resolver/StateImpl:monitor	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: getfield 982	org/eclipse/osgi/internal/resolver/StateImpl:resolvedBundles	Lorg/eclipse/osgi/framework/util/KeyedHashSet;
    //   11: aload_0
    //   12: getfield 982	org/eclipse/osgi/internal/resolver/StateImpl:resolvedBundles	Lorg/eclipse/osgi/framework/util/KeyedHashSet;
    //   15: invokevirtual 1040	org/eclipse/osgi/framework/util/KeyedHashSet:size	()I
    //   18: anewarray 548	org/eclipse/osgi/service/resolver/BundleDescription
    //   21: invokevirtual 1048	org/eclipse/osgi/framework/util/KeyedHashSet:elements	([Ljava/lang/Object;)[Ljava/lang/Object;
    //   24: checkcast 495	[Lorg/eclipse/osgi/service/resolver/BundleDescription;
    //   27: aload_1
    //   28: monitorexit
    //   29: areturn
    //   30: aload_1
    //   31: monitorexit
    //   32: athrow
    // Line number table:
    //   Java source line #600	-> byte code offset #0
    //   Java source line #601	-> byte code offset #7
    //   Java source line #600	-> byte code offset #30
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	33	0	this	StateImpl
    //   5	26	1	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   7	29	30	finally
    //   30	32	30	finally
  }
  
  /* Error */
  public boolean isEmpty()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 974	org/eclipse/osgi/internal/resolver/StateImpl:monitor	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: getfield 981	org/eclipse/osgi/internal/resolver/StateImpl:bundleDescriptions	Lorg/eclipse/osgi/framework/util/KeyedHashSet;
    //   11: invokevirtual 1043	org/eclipse/osgi/framework/util/KeyedHashSet:isEmpty	()Z
    //   14: aload_1
    //   15: monitorexit
    //   16: ireturn
    //   17: aload_1
    //   18: monitorexit
    //   19: athrow
    // Line number table:
    //   Java source line #606	-> byte code offset #0
    //   Java source line #607	-> byte code offset #7
    //   Java source line #606	-> byte code offset #17
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	20	0	this	StateImpl
    //   5	13	1	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   7	16	17	finally
    //   17	19	17	finally
  }
  
  void setResolved(boolean resolved)
  {
    synchronized (monitor)
    {
      this.resolved = resolved;
    }
  }
  
  boolean basicAddBundle(BundleDescription description)
  {
    synchronized (monitor)
    {
      StateImpl origState = (StateImpl)description.getContainingState();
      if ((origState != null) && (origState != this))
      {
        if (removalPendings.contains(description)) {
          throw new IllegalStateException(NLS.bind(StateMsg.BUNDLE_PENDING_REMOVE_STATE, description.toString()));
        }
        if (origState.getBundle(description.getBundleId()) == description) {
          throw new IllegalStateException(NLS.bind(StateMsg.BUNDLE_IN_OTHER_STATE, description.toString()));
        }
      }
      ((BundleDescriptionImpl)description).setContainingState(this);
      ((BundleDescriptionImpl)description).setStateBit(4, false);
      if (bundleDescriptions.add((BundleDescriptionImpl)description))
      {
        if (description.getBundleId() > getHighestBundleId()) {
          highestBundleId = description.getBundleId();
        }
        return true;
      }
      return false;
    }
  }
  
  void addResolvedBundle(BundleDescriptionImpl resolvedBundle)
  {
    synchronized (monitor)
    {
      resolvedBundles.add(resolvedBundle);
    }
  }
  
  public ExportPackageDescription[] getExportedPackages()
  {
    fullyLoad();
    synchronized (monitor)
    {
      List<ExportPackageDescription> allExportedPackages = new ArrayList();
      for (Iterator<KeyedElement> iter = resolvedBundles.iterator(); iter.hasNext();)
      {
        BundleDescription bundle = (BundleDescription)iter.next();
        ExportPackageDescription[] bundlePackages = bundle.getSelectedExports();
        if (bundlePackages != null) {
          for (int i = 0; i < bundlePackages.length; i++) {
            allExportedPackages.add(bundlePackages[i]);
          }
        }
      }
      for (Iterator<BundleDescription> iter = removalPendings.iterator(); iter.hasNext();)
      {
        BundleDescription bundle = (BundleDescription)iter.next();
        ExportPackageDescription[] bundlePackages = bundle.getSelectedExports();
        if (bundlePackages != null) {
          for (int i = 0; i < bundlePackages.length; i++) {
            allExportedPackages.add(bundlePackages[i]);
          }
        }
      }
      return (ExportPackageDescription[])allExportedPackages.toArray(new ExportPackageDescription[allExportedPackages.size()]);
    }
  }
  
  BundleDescription[] getFragments(BundleDescription host)
  {
    List<BundleDescription> fragments = new ArrayList();
    for (Iterator<KeyedElement> iter = bundleDescriptions.iterator(); iter.hasNext();)
    {
      BundleDescription bundle = (BundleDescription)iter.next();
      HostSpecification hostSpec = bundle.getHost();
      if (hostSpec != null)
      {
        BundleDescription[] hosts = hostSpec.getHosts();
        if (hosts != null) {
          for (int i = 0; i < hosts.length; i++) {
            if (hosts[i] == host)
            {
              fragments.add(bundle);
              break;
            }
          }
        }
      }
    }
    return (BundleDescription[])fragments.toArray(new BundleDescription[fragments.size()]);
  }
  
  public void setTimeStamp(long newTimeStamp)
  {
    synchronized (monitor)
    {
      timeStamp = newTimeStamp;
    }
  }
  
  private void updateTimeStamp()
  {
    synchronized (monitor)
    {
      if (getTimeStamp() == Long.MAX_VALUE) {
        setTimeStamp(0L);
      }
      setTimeStamp(getTimeStamp() + 1L);
    }
  }
  
  public StateObjectFactory getFactory()
  {
    return factory;
  }
  
  void setFactory(StateObjectFactory factory)
  {
    this.factory = factory;
  }
  
  public BundleDescription getBundleByLocation(String location)
  {
    synchronized (monitor)
    {
      for (Iterator<KeyedElement> i = bundleDescriptions.iterator(); i.hasNext();)
      {
        BundleDescription current = (BundleDescription)i.next();
        if (location.equals(current.getLocation())) {
          return current;
        }
      }
      return null;
    }
  }
  
  /* Error */
  public Resolver getResolver()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 974	org/eclipse/osgi/internal/resolver/StateImpl:monitor	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: getfield 986	org/eclipse/osgi/internal/resolver/StateImpl:resolver	Lorg/eclipse/osgi/service/resolver/Resolver;
    //   11: aload_1
    //   12: monitorexit
    //   13: areturn
    //   14: aload_1
    //   15: monitorexit
    //   16: athrow
    // Line number table:
    //   Java source line #720	-> byte code offset #0
    //   Java source line #721	-> byte code offset #7
    //   Java source line #720	-> byte code of
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