org.eclipse.osgi_3.7.2.v20120110-1415

Impl$LazyData;
    //   4: astore_1
    //   5: aload_0
    //   6: getfield 630	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl:monitor	Ljava/lang/Object;
    //   9: dup
    //   10: astore_2
    //   11: monitorenter
    //   12: aload_1
    //   13: getfield 648	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl$LazyData:location	Ljava/lang/String;
    //   16: aload_2
    //   17: monitorexit
    //   18: areturn
    //   19: aload_2
    //   20: monitorexit
    //   21: athrow
    // Line number table:
    //   Java source line #84	-> byte code offset #0
    //   Java source line #85	-> byte code offset #5
    //   Java source line #86	-> byte code offset #12
    //   Java source line #85	-> byte code offset #19
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	22	0	this	BundleDescriptionImpl
    //   4	9	1	currentData	LazyData
    //   10	10	2	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   12	18	19	finally
    //   19	21	19	finally
  }
  
  /* Error */
  public String getPlatformFilter()
  {
    // Byte code:
    //   0: aload_0
    //   1: invokespecial 707	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl:loadLazyData	()Lorg/eclipse/osgi/internal/resolver/BundleDescriptionImpl$LazyData;
    //   4: astore_1
    //   5: aload_0
    //   6: getfield 630	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl:monitor	Ljava/lang/Object;
    //   9: dup
    //   10: astore_2
    //   11: monitorenter
    //   12: aload_1
    //   13: getfield 649	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl$LazyData:platformFilter	Ljava/lang/String;
    //   16: aload_2
    //   17: monitorexit
    //   18: areturn
    //   19: aload_2
    //   20: monitorexit
    //   21: athrow
    // Line number table:
    //   Java source line #91	-> byte code offset #0
    //   Java source line #92	-> byte code offset #5
    //   Java source line #93	-> byte code offset #12
    //   Java source line #92	-> byte code offset #19
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	22	0	this	BundleDescriptionImpl
    //   4	9	1	currentData	LazyData
    //   10	10	2	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   12	18	19	finally
    //   19	21	19	finally
  }
  
  public String[] getExecutionEnvironments()
  {
    LazyData currentData = loadLazyData();
    synchronized (monitor)
    {
      if (executionEnvironments == null) {
        return EMPTY_STRING;
      }
      return executionEnvironments;
    }
  }
  
  public ImportPackageSpecification[] getImportPackages()
  {
    LazyData currentData = loadLazyData();
    synchronized (monitor)
    {
      if (importPackages == null) {
        return EMPTY_IMPORTS;
      }
      return importPackages;
    }
  }
  
  public ImportPackageSpecification[] getAddedDynamicImportPackages()
  {
    LazyData currentData = loadLazyData();
    synchronized (monitor)
    {
      if (addedDynamicImports == null) {
        return EMPTY_IMPORTS;
      }
      return (ImportPackageSpecification[])addedDynamicImports.toArray(new ImportPackageSpecification[addedDynamicImports.size()]);
    }
  }
  
  public BundleSpecification[] getRequiredBundles()
  {
    LazyData currentData = loadLazyData();
    synchronized (monitor)
    {
      if (requiredBundles == null) {
        return EMPTY_BUNDLESPECS;
      }
      return requiredBundles;
    }
  }
  
  public GenericSpecification[] getGenericRequires()
  {
    LazyData currentData = loadLazyData();
    synchronized (monitor)
    {
      if (genericRequires == null) {
        return EMPTY_GENERICSPECS;
      }
      return genericRequires;
    }
  }
  
  public GenericDescription[] getGenericCapabilities()
  {
    LazyData currentData = loadLazyData();
    synchronized (monitor)
    {
      if (genericCapabilities == null) {
        return EMPTY_GENERICDESCS;
      }
      return genericCapabilities;
    }
  }
  
  /* Error */
  public NativeCodeSpecification getNativeCodeSpecification()
  {
    // Byte code:
    //   0: aload_0
    //   1: invokespecial 707	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl:loadLazyData	()Lorg/eclipse/osgi/internal/resolver/BundleDescriptionImpl$LazyData;
    //   4: astore_1
    //   5: aload_0
    //   6: getfield 630	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl:monitor	Ljava/lang/Object;
    //   9: dup
    //   10: astore_2
    //   11: monitorenter
    //   12: aload_1
    //   13: getfield 665	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl$LazyData:nativeCode	Lorg/eclipse/osgi/service/resolver/NativeCodeSpecification;
    //   16: aload_2
    //   17: monitorexit
    //   18: areturn
    //   19: aload_2
    //   20: monitorexit
    //   21: athrow
    // Line number table:
    //   Java source line #152	-> byte code offset #0
    //   Java source line #153	-> byte code offset #5
    //   Java source line #154	-> byte code offset #12
    //   Java source line #153	-> byte code offset #19
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	22	0	this	BundleDescriptionImpl
    //   4	9	1	currentData	LazyData
    //   10	10	2	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   12	18	19	finally
    //   19	21	19	finally
  }
  
  public ExportPackageDescription[] getExportPackages()
  {
    LazyData currentData = loadLazyData();
    synchronized (monitor)
    {
      return exportPackages == null ? EMPTY_EXPORTS : exportPackages;
    }
  }
  
  public boolean isResolved()
  {
    return (stateBits & 0x1) != 0;
  }
  
  public State getContainingState()
  {
    return containingState;
  }
  
  public BundleDescription[] getFragments()
  {
    if (host != null) {
      return EMPTY_BUNDLEDESCS;
    }
    StateImpl currentState = (StateImpl)getContainingState();
    if (currentState == null) {
      throw new IllegalStateException("BundleDescription does not belong to a state.");
    }
    return currentState.getFragments(this);
  }
  
  public HostSpecification getHost()
  {
    return host;
  }
  
  public boolean isSingleton()
  {
    return (stateBits & 0x2) != 0;
  }
  
  public boolean isRemovalPending()
  {
    return (stateBits & 0x4) != 0;
  }
  
  public boolean hasDynamicImports()
  {
    return (stateBits & 0x20) != 0;
  }
  
  public boolean attachFragments()
  {
    return (stateBits & 0x40) != 0;
  }
  
  public boolean dynamicFragments()
  {
    return (stateBits & 0x80) != 0;
  }
  
  public ExportPackageDescription[] getSelectedExports()
  {
    LazyData currentData = loadLazyData();
    synchronized (monitor)
    {
      if (selectedExports == null) {
        return EMPTY_EXPORTS;
      }
      return selectedExports;
    }
  }
  
  public GenericDescription[] getSelectedGenericCapabilities()
  {
    LazyData currentData = loadLazyData();
    synchronized (monitor)
    {
      if (selectedCapabilities == null) {
        return EMPTY_GENERICDESCS;
      }
      return selectedCapabilities;
    }
  }
  
  public ExportPackageDescription[] getSubstitutedExports()
  {
    LazyData currentData = loadLazyData();
    synchronized (monitor)
    {
      if (substitutedExports == null) {
        return EMPTY_EXPORTS;
      }
      return substitutedExports;
    }
  }
  
  public BundleDescription[] getResolvedRequires()
  {
    LazyData currentData = loadLazyData();
    synchronized (monitor)
    {
      if (resolvedRequires == null) {
        return EMPTY_BUNDLEDESCS;
      }
      return resolvedRequires;
    }
  }
  
  public ExportPackageDescription[] getResolvedImports()
  {
    LazyData currentData = loadLazyData();
    synchronized (monitor)
    {
      if (resolvedImports == null) {
        return EMPTY_EXPORTS;
      }
      return resolvedImports;
    }
  }
  
  public GenericDescription[] getResolvedGenericRequires()
  {
    LazyData currentData = loadLazyData();
    synchronized (monitor)
    {
      if (resolvedCapabilities == null) {
        return EMPTY_GENERICDESCS;
      }
      return resolvedCapabilities;
    }
  }
  
  public Map<String, List<StateWire>> getWires()
  {
    LazyData currentData = loadLazyData();
    synchronized (monitor)
    {
      if (stateWires == null) {
        stateWires = new HashMap(0);
      }
      return stateWires;
    }
  }
  
  /* Error */
  Map<String, List<StateWire>> getWiresInternal()
  {
    // Byte code:
    //   0: aload_0
    //   1: invokespecial 707	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl:loadLazyData	()Lorg/eclipse/osgi/internal/resolver/BundleDescriptionImpl$LazyData;
    //   4: astore_1
    //   5: aload_0
    //   6: getfield 630	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl:monitor	Ljava/lang/Object;
    //   9: dup
    //   10: astore_2
    //   11: monitorenter
    //   12: aload_1
    //   13: getfield 653	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl$LazyData:stateWires	Ljava/util/Map;
    //   16: aload_2
    //   17: monitorexit
    //   18: areturn
    //   19: aload_2
    //   20: monitorexit
    //   21: athrow
    // Line number table:
    //   Java source line #271	-> byte code offset #0
    //   Java source line #272	-> byte code offset #5
    //   Java source line #273	-> byte code offset #12
    //   Java source line #272	-> byte code offset #19
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	22	0	this	BundleDescriptionImpl
    //   4	9	1	currentData	LazyData
    //   10	10	2	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   12	18	19	finally
    //   19	21	19	finally
  }
  
  protected void setBundleId(long bundleId)
  {
    this.bundleId = bundleId;
  }
  
  protected void setSymbolicName(String symbolicName)
  {
    setName(symbolicName);
  }
  
  protected void setLocation(String location)
  {
    synchronized (monitor)
    {
      checkLazyData();
      lazyData.location = location;
    }
  }
  
  protected void setPlatformFilter(String platformFilter)
  {
    synchronized (monitor)
    {
      checkLazyData();
      lazyData.platformFilter = platformFilter;
    }
  }
  
  protected void setExecutionEnvironments(String[] executionEnvironments)
  {
    synchronized (monitor)
    {
      checkLazyData();
      lazyData.executionEnvironments = executionEnvironments;
    }
  }
  
  protected void setExportPackages(ExportPackageDescription[] exportPackages)
  {
    synchronized (monitor)
    {
      checkLazyData();
      lazyData.exportPackages = exportPackages;
      if (exportPackages != null) {
        for (int i = 0; i < exportPackages.length; i++) {
          ((ExportPackageDescriptionImpl)exportPackages[i]).setExporter(this);
        }
      }
    }
  }
  
  protected void setImportPackages(ImportPackageSpecification[] importPackages)
  {
    synchronized (monitor)
    {
      checkLazyData();
      lazyData.importPackages = importPackages;
      if (importPackages != null) {
        for (int i = 0; i < importPackages.length; i++)
        {
          ((ImportPackageSpecificationImpl)importPackages[i]).setBundle(this);
          if ("dynamic".equals(importPackages[i].getDirective("resolution"))) {
            stateBits |= 0x20;
          }
        }
      }
    }
  }
  
  protected void setRequiredBundles(BundleSpecification[] requiredBundles)
  {
    synchronized (monitor)
    {
      checkLazyData();
      lazyData.requiredBundles = requiredBundles;
      if (requiredBundles != null) {
        for (int i = 0; i < requiredBundles.length; i++) {
          ((VersionConstraintImpl)requiredBundles[i]).setBundle(this);
        }
      }
    }
  }
  
  protected void setGenericCapabilities(GenericDescription[] genericCapabilities)
  {
    synchronized (monitor)
    {
      checkLazyData();
      lazyData.genericCapabilities = genericCapabilities;
      if (genericCapabilities != null) {
        for (int i = 0; i < genericCapabilities.length; i++) {
          ((GenericDescriptionImpl)genericCapabilities[i]).setSupplier(this);
        }
      }
    }
  }
  
  protected void setGenericRequires(GenericSpecification[] genericRequires)
  {
    synchronized (monitor)
    {
      checkLazyData();
      lazyData.genericRequires = genericRequires;
      if (genericRequires != null) {
        for (int i = 0; i < genericRequires.length; i++) {
          ((VersionConstraintImpl)genericRequires[i]).setBundle(this);
        }
      }
    }
  }
  
  protected void setNativeCodeSpecification(NativeCodeSpecification nativeCode)
  {
    synchronized (monitor)
    {
      checkLazyData();
      lazyData.nativeCode = nativeCode;
      if (nativeCode != null)
      {
        ((NativeCodeSpecificationImpl)nativeCode).setBundle(this);
        NativeCodeDescription[] suppliers = nativeCode.getPossibleSuppliers();
        if (suppliers != null) {
          for (int i = 0; i < suppliers.length; i++) {
            ((NativeCodeDescriptionImpl)suppliers[i]).setSupplier(this);
          }
        }
      }
    }
  }
  
  protected int getStateBits()
  {
    return stateBits;
  }
  
  protected void setStateBit(int stateBit, boolean on)
  {
    synchronized (monitor)
    {
      if (on)
      {
        stateBits |= stateBit;
      }
      else
      {
        stateBits &= (stateBit ^ 0xFFFFFFFF);
        if (stateBit == 1)
        {
          if (bundleWiring != null) {
            bundleWiring.invalidate();
          }
          bundleWiring = null;
        }
      }
    }
  }
  
  protected void setContainingState(State value)
  {
    synchronized (monitor)
    {
      containingState = ((StateImpl)value);
      if ((containingState != null) && (containingState.getReader() != null))
      {
        if (containingState.getReader().isLazyLoaded()) {
          stateBits |= 0x10;
        } else {
          stateBits &= 0xFFFFFFEF;
        }
      }
      else {
        stateBits &= 0xFFFFFFEF;
      }
    }
  }
  
  protected void setHost(HostSpecification host)
  {
    synchronized (monitor)
    {
      this.host = host;
      if (host != null) {
        ((VersionConstraintImpl)host).setBundle(this);
      }
    }
  }
  
  protected void setLazyLoaded(boolean lazyLoad)
  {
    loadLazyData();
    synchronized (monitor)
    {
      if (lazyLoad) {
        stateBits |= 0x10;
      } else {
        stateBits &= 0xFFFFFFEF;
      }
    }
  }
  
  protected void setSelectedExports(ExportPackageDescription[] selectedExports)
  {
    synchronized (monitor)
    {
      checkLazyData();
      lazyData.selectedExports = selectedExports;
      if (selectedExports != null) {
        for (int i = 0; i < selectedExports.length; i++) {
          ((ExportPackageDescriptionImpl)selectedExports[i]).setExporter(this);
        }
      }
    }
  }
  
  protected void setSelectedCapabilities(GenericDescription[] selectedCapabilities)
  {
    synchronized (monitor)
    {
      checkLazyData();
      lazyData.selectedCapabilities = selectedCapabilities;
      if (selectedCapabilities != null)
      {
        GenericDescription[] arrayOfGenericDescription;
        int j = (arrayOfGenericDescription = selectedCapabilities).length;
        for (int i = 0; i < j; i++)
        {
          GenericDescription capability = arrayOfGenericDescription[i];
          ((GenericDescriptionImpl)capability).setSupplier(this);
        }
      }
    }
  }
  
  protected void setSubstitutedExports(ExportPackageDescription[] substitutedExports)
  {
    synchronized (monitor)
    {
      checkLazyData();
      lazyData.substitutedExports = substitutedExports;
    }
  }
  
  protected void setResolvedImports(ExportPackageDescription[] resolvedImports)
  {
    synchronized (monitor)
    {
      checkLazyData();
      lazyData.resolvedImports = resolvedImports;
    }
  }
  
  protected void setResolvedRequires(BundleDescription[] resolvedRequires)
  {
    synchronized (monitor)
    {
      checkLazyData();
      lazyData.resolvedRequires = resolvedRequires;
    }
  }
  
  protected void setResolvedCapabilities(GenericDescription[] resolvedCapabilities)
  {
    synchronized (monitor)
    {
      checkLazyData();
      lazyData.resolvedCapabilities = resolvedCapabilities;
    }
  }
  
  protected void setStateWires(Map<String, List<StateWire>> stateWires)
  {
    synchronized (monitor)
    {
      checkLazyData();
      lazyData.stateWires = stateWires;
    }
  }
  
  void clearAddedDynamicImportPackages()
  {
    synchronized (monitor)
    {
      checkLazyData();
      lazyData.addedDynamicImports = null;
    }
  }
  
  public String toString()
  {
    if (getSymbolicName() == null) {
      return "[" + getBundleId() + "]";
    }
    return getSymbolicName() + "_" + getVersion();
  }
  
  public Object getKey()
  {
    return new Long(bundleId);
  }
  
  public boolean compare(KeyedElement other)
  {
    if (!(other instanceof BundleDescriptionImpl)) {
      return false;
    }
    BundleDescriptionImpl otherBundleDescription = (BundleDescriptionImpl)other;
    return bundleId == bundleId;
  }
  
  public int getKeyHashCode()
  {
    return (int)(bundleId ^ bundleId >>> 32);
  }
  
  protected void removeDependencies()
  {
    synchronized (monitor)
    {
      if (dependencies == null) {
        return;
      }
      Iterator<BundleDescription> iter = dependencies.iterator();
      while (iter.hasNext()) {
        ((BundleDescriptionImpl)iter.next()).removeDependent(this);
      }
      dependencies = null;
    }
  }
  
  protected void addDependencies(BaseDescription[] newDependencies, boolean checkDups)
  {
    synchronized (monitor)
    {
      if (newDependencies == null) {
        return;
      }
      if ((!checkDups) && (dependencies == null)) {
        dependencies = new ArrayList(newDependencies.length);
      }
      for (int i = 0; i < newDependencies.length; i++) {
        addDependency((BaseDescriptionImpl)newDependencies[i], checkDups);
      }
    }
  }
  
  protected void addDependency(BaseDescriptionImpl dependency, boolean checkDups)
  {
    synchronized (monitor)
    {
      BundleDescriptionImpl bundle = (BundleDescriptionImpl)dependency.getSupplier();
      if (bundle == this) {
        return;
      }
      if (dependencies == null) {
        dependencies = new ArrayList(10);
      }
      if ((!checkDups) || (!dependencies.contains(bundle)))
      {
        bundle.addDependent(this);
        dependencies.add(bundle);
      }
    }
  }
  
  List<BundleDescription> getBundleDependencies()
  {
    synchronized (monitor)
    {
      if (dependencies == null) {
        return new ArrayList(0);
      }
      ArrayList<BundleDescription> required = new ArrayList(dependencies.size());
      for (Iterator<BundleDescription> iter = dependencies.iterator(); iter.hasNext();)
      {
        BundleDescription dep = (BundleDescription)iter.next();
        if ((dep != this) && (dep.getHost() == null)) {
          required.add(dep);
        }
      }
      return required;
    }
  }
  
  public Object getUserObject()
  {
    return userObject;
  }
  
  public void setUserObject(Object userObject)
  {
    this.userObject = userObject;
  }
  
  protected void addDependent(BundleDescription dependent)
  {
    synchronized (monitor)
    {
      if (dependents == null) {
        dependents = new ArrayList(10);
      }
      dependents.add(dependent);
    }
  }
  
  protected void removeDependent(BundleDescription dependent)
  {
    synchronized (monitor)
    {
      if (dependents == null) {
        return;
      }
      dependents.remove(dependent);
    }
  }
  
  public BundleDescription[] getDependents()
  {
    synchronized (monitor)
    {
      if (dependents == null) {
        return EMPTY_BUNDLEDESCS;
      }
      return (BundleDescription[])dependents.toArray(new BundleDescription[dependents.size()]);
    }
  }
  
  boolean hasDependents()
  {
    synchronized (monitor)
    {
      return dependents != null;
    }
  }
  
  void setFullyLoaded(boolean fullyLoaded)
  {
    synchronized (monitor)
    {
      if (fullyLoaded) {
        stateBits |= 0x8;
      } else {
        stateBits &= 0xFFFFFFF7;
      }
    }
  }
  
  boolean isFullyLoaded()
  {
    return (stateBits & 0x8) != 0;
  }
  
  void setLazyDataOffset(int lazyDataOffset)
  {
    this.lazyDataOffset = lazyDataOffset;
  }
  
  int getLazyDataOffset()
  {
    return lazyDataOffset;
  }
  
  void setLazyDataSize(int lazyDataSize)
  {
    this.lazyDataSize = lazyDataSize;
  }
  
  int getLazyDataSize()
  {
    return lazyDataSize;
  }
  
  private LazyData loadLazyData()
  {
    if ((stateBits & 0x10) == 0) {
      return lazyData;
    }
    StateImpl currentState = (StateImpl)getContainingState();
    StateReader reader = currentState == null ? null : currentState.getReader();
    if (reader == null) {
      throw new IllegalStateException("No valid reader for the bundle description");
    }
    synchronized (monitor)
    {
      if (isFullyLoaded())
      {
        reader.setAccessedFlag(true);
        return lazyData;
      }
      try
      {
        reader.fullyLoad(this);
        return lazyData;
      }
      catch (IOException e)
      {
        throw new RuntimeException(e.getMessage(), e);
      }
    }
  }
  
  void addDynamicResolvedImport(ExportPackageDescriptionImpl result)
  {
    synchronized (monitor)
    {
      addDependency(result, true);
      
      checkLazyData();
      if (lazyData.resolvedImports == null)
      {
        lazyData.resolvedImports = new ExportPackageDescription[] { result };
        return;
      }
      ExportPackageDescription[] newImports = new ExportPackageDescription[lazyData.resolvedImports.length + 1];
      System.arraycopy(lazyData.resolvedImports, 0, newImports, 0, lazyData.resolvedImports.length);
      newImports[(newImports.length - 1)] = result;
      lazyData.resolvedImports = newImports;
    }
    setLazyLoaded(false);
  }
  
  void addDynamicImportPackages(ImportPackageSpecification[] dynamicImport)
  {
    LazyData currentData = loadLazyData();
    synchronized (monitor)
    {
      if (addedDynamicImports == null) {
        addedDynamicImports = new ArrayList();
      }
      ImportPackageSpecification[] arrayOfImportPackageSpecification;
      int j = (arrayOfImportPackageSpecification = dynamicImport).length;
      for (int i = 0; i < j; i++)
      {
        ImportPackageSpecification addImport = arrayOfImportPackageSpecification[i];
        if (!"dynamic".equals(addImport.getDirective("resolution"))) {
          throw new IllegalArgumentException("Import must be a dynamic import.");
        }
      }
      j = (arrayOfImportPackageSpecification = dynamicImport).length;
      for (i = 0; i < j; i++)
      {
        ImportPackageSpecification addImport = arrayOfImportPackageSpecification[i];
        for (Iterator localIterator = addedDynamicImports.iterator(); localIterator.hasNext();)
        {
          ImportPackageSpecification currentImport = (ImportPackageSpecification)localIterator.next();
          if (equalImports(addImport, currentImport)) {
            break;
          }
        }
        ((ImportPackageSpecificationImpl)addImport).setBundle(this);
        addedDynamicImports.add(addImport);
      }
    }
    setLazyLoaded(false);
  }
  
  private boolean equalImports(ImportPackageSpecification addImport, ImportPackageSpecification currentImport)
  {
    if (!isEqual(addImport.getName(), currentImport.getName())) {
      return false;
    }
    if (!isEqual(addImport.getVersionRange(), currentImport.getVersionRange())) {
      return false;
    }
    if (!isEqual(addImport.getBundleSymbolicName(), currentImport.getBundleSymbolicName())) {
      return false;
    }
    if (!isEqual(addImport.getBundleVersionRange(), currentImport.getBundleVersionRange())) {
      return false;
    }
    return isEqual(addImport.getAttributes(), currentImport.getAttributes());
  }
  
  private boolean isEqual(Object o1, Object o2)
  {
    return o1 == null ? false : o2 == null ? true : o1.equals(o2);
  }
  
  void unload()
  {
    StateImpl currentState = (StateImpl)getContainingState();
    StateReader reader = currentState == null ? null : currentState.getReader();
    if (reader == null) {
      throw new IllegalStateException("BundleDescription does not belong to a reader.");
    }
    synchronized (monitor)
    {
      if ((stateBits & 0x10) == 0) {
        return;
      }
      if (!isFullyLoaded()) {
        return;
      }
      synchronized (monitor)
      {
        setFullyLoaded(false);
        lazyData = null;
      }
    }
  }
  
  void setDynamicStamps(Map<String, Long> dynamicStamps)
  {
    synchronized (monitor)
    {
      checkLazyData();
      lazyData.dynamicStamps = dynamicStamps;
    }
  }
  
  void setDynamicStamp(String requestedPackage, Long timestamp)
  {
    synchronized (monitor)
    {
      checkLazyData();
      if (lazyData.dynamicStamps == null)
      {
        if (timestamp == null) {
          return;
        }
        lazyData.dynamicStamps = new HashMap();
      }
      if (timestamp == null) {
        lazyData.dynamicStamps.remove(requestedPackage);
      } else {
        lazyData.dynamicStamps.put(requestedPackage, timestamp);
      }
    }
  }
  
  long getDynamicStamp(String requestedPackage)
  {
    LazyData currentData = loadLazyData();
    synchronized (monitor)
    {
      Long stamp = dynamicStamps == null ? null : (Long)dynamicStamps.get(requestedPackage);
      return stamp == null ? 0L : stamp.longValue();
    }
  }
  
  /* Error */
  Map<String, Long> getDynamicStamps()
  {
    // Byte code:
    //   0: aload_0
    //   1: invokespecial 707	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl:loadLazyData	()Lorg/eclipse/osgi/internal/resolver/BundleDescriptionImpl$LazyData;
    //   4: astore_1
    //   5: aload_0
    //   6: getfield 630	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl:monitor	Ljava/lang/Object;
    //   9: dup
    //   10: astore_2
    //   11: monitorenter
    //   12: aload_1
    //   13: getfield 652	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl$LazyData:dynamicStamps	Ljava/util/Map;
    //   16: aload_2
    //   17: monitorexit
    //   18: areturn
    //   19: aload_2
    //   20: monitorexit
    //   21: athrow
    // Line number table:
    //   Java source line #780	-> byte code offset #0
    //   Java source line #781	-> byte code offset #5
    //   Java source line #782	-> byte code offset #12
    //   Java source line #781	-> byte code offset #19
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	22	0	this	BundleDescriptionImpl
    //   4	9	1	currentData	LazyData
    //   10	10	2	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   12	18	19	finally
    //   19	21	19	finally
  }
  
  public void setEquinoxEE(int equinox_ee)
  {
    this.equinox_ee = equinox_ee;
  }
  
  public int getEquinoxEE()
  {
    return equinox_ee;
  }
  
  private void checkLazyData()
  {
    if (lazyData == null) {
      lazyData = new LazyData();
    }
  }
  
  /* Error */
  public Map<String, Object> getAttributes()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 630	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl:monitor	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: getfield 637	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl:attributes	Ljava/util/Map;
    //   11: aload_1
    //   12: monitorexit
    //   13: areturn
    //   14: aload_1
    //   15: monitorexit
    //   16: athrow
    // Line number table:
    //   Java source line #825	-> byte code offset #0
    //   Java source line #826	-> byte code offset #7
    //   Java source line #825	-> byte code offset #14
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	17	0	this	BundleDescriptionImpl
    //   5	10	1	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   7	13	14	finally
    //   14	16	14	finally
  }
  
  void setAttributes(Map<String, ?> attributes)
  {
    synchronized (monitor)
    {
      this.attributes = attributes;
    }
  }
  
  Object getDirective(String key)
  {
    synchronized (monitor)
    {
      if ("mandatory".equals(key)) {
        return mandatory;
      }
      if ("singleton".equals(key)) {
        return isSingleton() ? Boolean.TRUE : Boolean.FALSE;
      }
      if ("fragment-attachment".equals(key))
      {
        if (!attachFragments()) {
          return "never";
        }
        if (dynamicFragments()) {
          return "always";
        }
        return "resolve-time";
      }
    }
    return null;
  }
  
  void setDirective(String key, Object value)
  {
    if ("mandatory".equals(key)) {
      mandatory = ((String[])value);
    }
  }
  
  public Map<String, String> getDeclaredDirectives()
  {
    Map<String, String> result = new HashMap(2);
    if (!attachFragments()) {
      result.put("fragment-attachment", "never");
    } else if (dynamicFragments()) {
      result.put("fragment-attachment", "always");
    } else {
      result.put("fragment-attachment", "resolve-time");
    }
    if (isSingleton()) {
      result.put("singleton", Boolean.TRUE.toString());
    }
    String[] mandatoryDirective = (String[])getDirective("mandatory");
    if (mandatoryDirective != null) {
      result.put("mandatory", ExportPackageDescriptionImpl.toString(mandatoryDirective));
    }
    return Collections.unmodifiableMap(result);
  }
  
  public Map<String, Object> getDeclaredAttributes()
  {
    Map<String, Object> result = new HashMap(1);
    synchronized (monitor)
    {
      if (attributes != null) {
        result.putAll(attributes);
      }
    }
    result.put("osgi.wiring.bundle", getName());
    result.put("bundle-version", getVersion());
    return Collections.unmodifiableMap(result);
  }
  
  public List<BundleRequirement> getDeclaredRequirements(String namespace)
  {
    List<BundleRequirement> result = new ArrayList();
    Object localObject;
    if ((namespace == null) || ("osgi.wiring.bundle".equals(namespace)))
    {
      BundleSpecification[] requires = getRequiredBundles();
      j = (localObject = requires).length;
      for (i = 0; i < j; i++)
      {
        BundleSpecification require = localObject[i];
        result.add(require.getRequirement());
      }
    }
    if ((host != null) && ((namespace == null) || ("osgi.wiring.host".equals(namespace)))) {
      result.add(host.getRequirement());
    }
    if ((namespace == null) || ("osgi.wiring.package".equals(namespace)))
    {
      ImportPackageSpecification[] imports = getImportPackages();
      j = (localObject = imports).length;
      for (i = 0; i < j; i++)
      {
        ImportPackageSpecification importPkg = localObject[i];
        result.add(importPkg.getRequirement());
      }
    }
    GenericSpecification[] genericSpecifications = getGenericRequires();
    int j = (localObject = genericSpecifications).length;
    for (int i = 0; i < j; i++)
    {
      GenericSpecification requirement = localObject[i];
      if ((namespace == null) || (namespace.equals(requirement.getType()))) {
        result.add(requirement.getRequirement());
      }
    }
    return Collections.unmodifiableList(result);
  }
  
  public List<BundleCapability> getDeclaredCapabilities(String namespace)
  {
    List<BundleCapability> result = new ArrayList();
    if ((host == null) && 
      (getSymbolicName() != null))
    {
      if ((namespace == null) || ("osgi.wiring.bundle".equals(namespace))) {
        result.add(getCapability());
      }
      if ((attachFragments()) && ((namespace == null) || ("osgi.wiring.host".equals(namespace)))) {
        result.add(getCapability("osgi.wiring.host"));
      }
    }
    Object localObject;
    if ((namespace == null) || ("osgi.wiring.package".equals(namespace)))
    {
      ExportPackageDescription[] exports = getExportPackages();
      j = (localObject = exports).length;
      for (i = 0; i < j; i++)
      {
        ExportPackageDescription exportPkg = localObject[i];
        result.add(exportPkg.getCapability());
      }
    }
    GenericDescription[] genericCapabilities = getGenericCapabilities();
    int j = (localObject = genericCapabilities).length;
    for (int i = 0; i < j; i++)
    {
      GenericDescription capabilitiy = localObject[i];
      if ((namespace == null) || (namespace.equals(capabilitiy.getType()))) {
        result.add(capabilitiy.getCapability());
      }
    }
    return Collections.unmodifiableList(result);
  }
  
  public int getTypes()
  {
    return getHost() != null ? 1 : 0;
  }
  
  public Bundle getBundle()
  {
    Object ref = getUserObject();
    if ((ref instanceof BundleReference)) {
      return ((BundleReference)ref).getBundle();
    }
    return null;
  }
  
  String getInternalNameSpace()
  {
    return "osgi.wiring.bundle";
  }
  
  public BundleWiring getWiring()
  {
    synchronized (monitor)
    {
      if ((bundleWiring != null) || (!isResolved())) {
        return bundleWiring;
      }
      return bundleWiring = new DescriptionWiring();
    }
  }
  
  static class BundleWireImpl
    implements BundleWire
  {
    private final BundleCapability capability;
    private final BundleWiring provider;
    private final BundleRequirement requirement;
    private final BundleWiring requirer;
    
    public BundleWireImpl(StateWire wire)
    {
      VersionConstraint declaredRequirement = wire.getDeclaredRequirement();
      if ((declaredRequirement instanceof HostSpecification)) {
        capability = ((BaseDescriptionImpl)wire.getDeclaredCapability()).getCapability("osgi.wiring.host");
      } else {
        capability = wire.getDeclaredCapability().getCapability();
      }
      provider = wire.getCapabilityHost().getWiring();
      requirement = declaredRequirement.getRequirement();
      requirer = wire.getRequirementHost().getWiring();
    }
    
    public BundleCapability getCapability()
    {
      return capability;
    }
    
    public BundleRequirement getRequirement()
    {
      return requirement;
    }
    
    public BundleWiring getProviderWiring()
    {
      return provider;
    }
    
    public BundleWiring getRequirerWiring()
    {
      return requirer;
    }
    
    public int hashCode()
    {
      int hashcode = 31 + capability.hashCode();
      hashcode = hashcode * 31 + requirement.hashCode();
      hashcode = hashcode * 31 + provider.hashCode();
      hashcode = hashcode * 31 + requirer.hashCode();
      return hashcode;
    }
    
    public boolean equals(Object obj)
    {
      if (!(obj instanceof BundleWireImpl)) {
        return false;
      }
      BundleWireImpl other = (BundleWireImpl)obj;
      return (capability.equals(other.getCapability())) && (requirement.equals(other.getRequirement())) && (provider.equals(other.getProviderWiring())) && (requirer.equals(other.getRequirerWiring()));
    }
    
    public String toString()
    {
      return getRequirement() + " -> " + getCapability();
    }
  }
  
  class DescriptionWiring
    implements BundleWiring
  {
    private volatile boolean valid = true;
    
    DescriptionWiring() {}
    
    public Bundle getBundle()
    {
      return BundleDescriptionImpl.this.getBundle();
    }
    
    public boolean isInUse()
    {
      return (valid) && ((isCurrent()) || (hasDependents()));
    }
    
    void invalidate()
    {
      valid = false;
    }
    
    public boolean isCurrent()
    {
      return (valid) && (!isRemovalPending());
    }
    
    public List<BundleCapability> getCapabilities(String namespace)
    {
      if (!isInUse()) {
        return null;
      }
      List<BundleCapability> result = Collections.EMPTY_LIST;
      if (host != null) {
        return result;
      }
      result = new ArrayList();
      if (getSymbolicName() != null)
      {
        if ((namespace == null) || ("osgi.wiring.bundle".equals(namespace))) {
          result.add(getCapability());
        }
        if ((attachFragments()) && ((namespace == null) || ("osgi.wiring.host".equals(namespace)))) {
          result.add(getCapability("osgi.wiring.host"));
        }
      }
      Object localObject;
      if ((namespace == null) || ("osgi.wiring.package".equals(namespace)))
      {
        ExportPackageDescription[] exports = getSelectedExports();
        j = (localObject = exports).length;
        for (i = 0; i < j; i++)
        {
          ExportPackageDescription exportPkg = localObject[i];
          result.add(exportPkg.getCapability());
        }
      }
      GenericDescription[] genericCapabilities = getSelectedGenericCapabilities();
      int j = (localObject = genericCapabilities).length;
      for (int i = 0; i < j; i++)
      {
        GenericDescription capabilitiy = localObject[i];
        if ((namespace == null) || (namespace.equals(capabilitiy.getType()))) {
          result.add(capabilitiy.getCapability());
        }
      }
      return result;
    }
    
    public List<BundleRequirement> getRequirements(String namespace)
    {
      List<BundleWire> requiredWires = getRequiredWires(namespace);
      if (requiredWires == null) {
        return null;
      }
      List<BundleRequirement> requirements = new ArrayList(requiredWires.size());
      for (Iterator localIterator = requiredWires.iterator(); localIterator.hasNext();)
      {
        BundleWire wire = (BundleWire)localIterator.next();
        if (!requirements.contains(wire.getRequirement())) {
          requirements.add(wire.getRequirement());
        }
      }
      if (((namespace == null) || ("osgi.wiring.package".equals(namespace))) && 
        (hasDynamicImports()))
      {
        ImportPackageSpecification[] imports = getImportPackages();
        ImportPackageSpecification[] arrayOfImportPackageSpecification1;
        int j = (arrayOfImportPackageSpecification1 = imports).length;
        for (int i = 0; i < j; i++)
        {
          ImportPackageSpecification impPackage = arrayOfImportPackageSpecification1[i];
          if ("dynamic".equals(impPackage.getDirective("resolution")))
          {
            BundleRequirement req = impPackage.getRequirement();
            if (!requirements.contains(req)) {
              requirements.add(req);
            }
          }
        }
      }
      return requirements;
    }
    
    public List<BundleWire> getProvidedWires(String namespace)
    {
      if (!isInUse()) {
        return null;
      }
      BundleDescription[] dependentBundles = getDependents();
      List<BundleWire> unorderedResult = new ArrayList();
      int j = (localObject1 = dependentBundles).length;
      for (int i = 0; i < j; i++)
      {
        BundleDescription dependent = localObject1[i];
        List<BundleWire> dependentWires = dependent.getWiring().getRequiredWires(namespace);
        if (dependentWires != null) {
          for (Iterator localIterator = dependentWires.iterator(); localIterator.hasNext();)
          {
            BundleWire bundleWire = (BundleWire)localIterator.next();
            if (bundleWire.getProviderWiring() == this) {
              unorderedResult.add(bundleWire);
            }
          }
        }
      }
      List<BundleWire> orderedResult = new ArrayList(unorderedResult.size());
      Object capabilities = getCapabilities(namespace);
      Iterator<BundleWire> wires;
      for (Object localObject1 = ((List)capabilities).iterator(); ((Iterator)localObject1).hasNext(); wires.hasNext())
      {
        BundleCapability capability = (BundleCapability)((Iterator)localObject1).next();
        wires = unorderedResult.iterator(); continue;
        BundleWire wire = (BundleWire)wires.next();
        if (wire.getCapability().equals(capability))
        {
          wires.remove();
          orderedResult.add(wire);
        }
      }
      return orderedResult;
    }
    
    public List<BundleWire> getRequiredWires(String namespace
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