org.eclipse.osgi_3.8.2.v20130124-134944

resolver.extras.DescriptionReference;
import org.osgi.framework.Version;
import org.osgi.framework.wiring.BundleCapability;
import org.osgi.framework.wiring.BundleRevision;

public abstract class BaseDescriptionImpl
  implements BaseDescription
{
  protected final Object monitor = new Object();
  private volatile String name;
  private volatile Version version;
  private volatile Object userObject;
  
  public String getName()
  {
    return name;
  }
  
  public Version getVersion()
  {
    synchronized (monitor)
    {
      if (version == null) {
        return Version.emptyVersion;
      }
      return version;
    }
  }
  
  protected void setName(String name)
  {
    this.name = name;
  }
  
  protected void setVersion(Version version)
  {
    this.version = version;
  }
  
  static <V> String toString(Map<String, V> map, boolean directives)
  {
    if (map.size() == 0) {
      return "";
    }
    String assignment = directives ? ":=" : "=";
    Set<Map.Entry<String, V>> set = map.entrySet();
    StringBuffer sb = new StringBuffer();
    for (Iterator localIterator1 = set.iterator(); localIterator1.hasNext();)
    {
      Map.Entry<String, V> entry = (Map.Entry)localIterator1.next();
      sb.append("; ");
      String key = (String)entry.getKey();
      Object value = entry.getValue();
      if ((value instanceof List))
      {
        List<Object> list = (List)value;
        if (list.size() != 0)
        {
          Object component = list.get(0);
          String className = component.getClass().getName();
          String type = className.substring(className.lastIndexOf('.') + 1);
          sb.append(key).append(':').append("List<").append(type).append(">").append(assignment).append('"');
          for (Iterator localIterator2 = list.iterator(); localIterator2.hasNext();)
          {
            Object object = localIterator2.next();
            sb.append(object).append(',');
          }
          sb.setLength(sb.length() - 1);
          sb.append('"');
        }
      }
      else
      {
        String type = "";
        if (!(value instanceof String))
        {
          String className = value.getClass().getName();
          type = ":" + className.substring(className.lastIndexOf('.') + 1);
        }
        sb.append(key).append(type).append(assignment).append('"').append(value).append('"');
      }
    }
    return sb.toString();
  }
  
  String getInternalNameSpace()
  {
    return null;
  }
  
  public BaseDescription getFragmentDeclaration()
  {
    return null;
  }
  
  public BundleCapability getCapability()
  {
    return getCapability(null);
  }
  
  BundleCapability getCapability(String namespace)
  {
    BaseDescriptionImpl fragmentDeclaration = (BaseDescriptionImpl)getFragmentDeclaration();
    if (fragmentDeclaration != null) {
      return fragmentDeclaration.getCapability(namespace);
    }
    if (namespace == null) {
      namespace = getInternalNameSpace();
    }
    if (namespace == null) {
      return null;
    }
    return new BaseCapability(namespace);
  }
  
  public Object getUserObject()
  {
    return userObject;
  }
  
  public void setUserObject(Object userObject)
  {
    this.userObject = userObject;
  }
  
  class BaseCapability
    implements BundleCapability, DescriptionReference
  {
    private final String namespace;
    
    public BaseCapability(String namespace)
    {
      this.namespace = namespace;
    }
    
    public BundleRevision getRevision()
    {
      return getSupplier();
    }
    
    public String getNamespace()
    {
      return namespace;
    }
    
    public Map<String, String> getDirectives()
    {
      return getDeclaredDirectives();
    }
    
    public Map<String, Object> getAttributes()
    {
      Map<String, Object> attrs = getDeclaredAttributes();
      String internalName = getInternalNameSpace();
      if (namespace.equals(internalName)) {
        return attrs;
      }
      attrs = new HashMap(attrs);
      Object nameValue = attrs.remove(internalName);
      if (nameValue != null) {
        attrs.put(namespace, nameValue);
      }
      return Collections.unmodifiableMap(attrs);
    }
    
    public int hashCode()
    {
      return System.identityHashCode(BaseDescriptionImpl.this);
    }
    
    protected BaseDescriptionImpl getBaseDescription()
    {
      return BaseDescriptionImpl.this;
    }
    
    public boolean equals(Object obj)
    {
      if (this == obj) {
        return true;
      }
      if (!(obj instanceof BaseCapability)) {
        return false;
      }
      return (((BaseCapability)obj).getBaseDescription() == BaseDescriptionImpl.this) && (namespace.equals(((BaseCapability)obj).getNamespace()));
    }
    
    public String toString()
    {
      return getNamespace() + BaseDescriptionImpl.toString(getAttributes(), false) + BaseDescriptionImpl.toString(getDirectives(), true);
    }
    
    public BundleRevision getResource()
    {
      return getRevision();
    }
    
    public BaseDescription getDescription()
    {
      return BaseDescriptionImpl.this;
    }
  }
}

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

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

final class BundleDeltaImpl
  implements BundleDelta
{
  private volatile BundleDescription bundleDescription;
  private volatile int type;
  
  public BundleDeltaImpl(BundleDescription bundleDescription)
  {
    this(bundleDescription, 0);
  }
  
  public BundleDeltaImpl(BundleDescription bundleDescription, int type)
  {
    this.bundleDescription = bundleDescription;
    this.type = type;
  }
  
  public BundleDescription getBundle()
  {
    return bundleDescription;
  }
  
  public int getType()
  {
    return type;
  }
  
  protected void setBundle(BundleDescription bundleDescription)
  {
    this.bundleDescription = bundleDescription;
  }
  
  protected void setType(int type)
  {
    this.type = type;
  }
  
  public String toString()
  {
    return bundleDescription.getSymbolicName() + '_' + bundleDescription.getVersion() + " (" + toTypeString(type) + ")";
  }
  
  private static String toTypeString(int type)
  {
    StringBuffer typeStr = new StringBuffer();
    if ((type & 0x1) != 0) {
      typeStr.append("ADDED,");
    }
    if ((type & 0x2) != 0) {
      typeStr.append("REMOVED,");
    }
    if ((type & 0x8) != 0) {
      typeStr.append("RESOLVED,");
    }
    if ((type & 0x10) != 0) {
      typeStr.append("UNRESOLVED,");
    }
    if ((type & 0x20) != 0) {
      typeStr.append("LINKAGE_CHANGED,");
    }
    if ((type & 0x4) != 0) {
      typeStr.append("UPDATED,");
    }
    if ((type & 0x80) != 0) {
      typeStr.append("REMOVAL_PENDING,");
    }
    if ((type & 0x100) != 0) {
      typeStr.append("REMOVAL_COMPLETE,");
    }
    if (typeStr.length() > 0) {
      typeStr.deleteCharAt(typeStr.length() - 1);
    }
    return typeStr.toString();
  }
  
  public int compareTo(BundleDelta obj)
  {
    long idcomp = getBundle().getBundleId() - obj.getBundle().getBundleId();
    return idcomp > 0L ? 1 : idcomp < 0L ? -1 : 0;
  }
}

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

import org.eclipse.osgi.service.resolver.BaseDescription;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.HostSpecification;
import org.eclipse.osgi.service.resolver.StateWire;
import org.eclipse.osgi.service.resolver.VersionConstraint;
import org.osgi.framework.wiring.BundleCapability;
import org.osgi.framework.wiring.BundleRequirement;
import org.osgi.framework.wiring.BundleRevision;
import org.osgi.framework.wiring.BundleWire;
import org.osgi.framework.wiring.BundleWiring;

class BundleDescriptionImpl$BundleWireImpl
  implements BundleWire
{
  private final BundleCapability capability;
  private final BundleWiring provider;
  private final BundleRequirement requirement;
  private final BundleWiring requirer;
  
  public BundleDescriptionImpl$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();
  }
  
  public BundleRevision getProvider()
  {
    return provider.getRevision();
  }
  
  public BundleRevision getRequirer()
  {
    return requirer.getRevision();
  }
}

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

import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.osgi.framework.adaptor.BundleClassLoader;
import org.eclipse.osgi.framework.internal.core.BundleHost;
import org.eclipse.osgi.internal.loader.BundleLoader;
import org.eclipse.osgi.internal.loader.BundleLoaderProxy;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.ExportPackageDescription;
import org.eclipse.osgi.service.resolver.GenericDescription;
import org.eclipse.osgi.service.resolver.ImportPackageSpecification;
import org.eclipse.osgi.service.resolver.StateWire;
import org.osgi.framework.AdminPermission;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleReference;
import org.osgi.framework.wiring.BundleCapability;
import org.osgi.framework.wiring.BundleRequirement;
import org.osgi.framework.wiring.BundleRevision;
import org.osgi.framework.wiring.BundleWire;
import org.osgi.framework.wiring.BundleWiring;
import org.osgi.resource.Capability;
import org.osgi.resource.Requirement;
import org.osgi.resource.Wire;

class BundleDescriptionImpl$DescriptionWiring
  implements BundleWiring
{
  private volatile boolean valid = true;
  final BundleDescriptionImpl this$0;
  
  BundleDescriptionImpl$DescriptionWiring(BundleDescriptionImpl paramBundleDescriptionImpl) {}
  
  public Bundle getBundle()
  {
    return this$0.getBundle();
  }
  
  public boolean isInUse()
  {
    return (valid) && ((isCurrent()) || (this$0.hasDependents()));
  }
  
  void invalidate()
  {
    valid = false;
  }
  
  public boolean isCurrent()
  {
    return (valid) && (!this$0.isRemovalPending());
  }
  
  public List<BundleCapability> getCapabilities(String namespace)
  {
    if (!isInUse()) {
      return null;
    }
    List<BundleCapability> result = new ArrayList();
    GenericDescription[] genericCapabilities = this$0.getSelectedGenericCapabilities();
    GenericDescription[] arrayOfGenericDescription1;
    int j = (arrayOfGenericDescription1 = genericCapabilities).length;
    for (int i = 0; i < j; i++)
    {
      GenericDescription capabilitiy = arrayOfGenericDescription1[i];
      if ((namespace == null) || (namespace.equals(capabilitiy.getType()))) {
        result.add(capabilitiy.getCapability());
      }
    }
    if (this$0.host != null) {
      return result;
    }
    if (this$0.getSymbolicName() != null)
    {
      if ((namespace == null) || ("osgi.wiring.bundle".equals(namespace))) {
        result.add(this$0.getCapability());
      }
      if ((this$0.attachFragments()) && ((namespace == null) || ("osgi.wiring.host".equals(namespace)))) {
        result.add(this$0.getCapability("osgi.wiring.host"));
      }
    }
    if ((namespace == null) || ("osgi.wiring.package".equals(namespace)))
    {
      ExportPackageDescription[] exports = this$0.getSelectedExports();
      ExportPackageDescription[] arrayOfExportPackageDescription1;
      int k = (arrayOfExportPackageDescription1 = exports).length;
      for (j = 0; j < k; j++)
      {
        ExportPackageDescription exportPkg = arrayOfExportPackageDescription1[j];
        result.add(exportPkg.getCapability());
      }
    }
    return result;
  }
  
  public List<Capability> getResourceCapabilities(String namespace)
  {
    return BundleDescriptionImpl.asListCapability(getCapabilities(namespace));
  }
  
  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 ((this$0.getHost() == null) && ((namespace == null) || ("osgi.wiring.package".equals(namespace))))
    {
      ImportPackageSpecification[] arrayOfImportPackageSpecification1;
      if (this$0.hasDynamicImports())
      {
        ImportPackageSpecification[] imports = this$0.getImportPackages();
        j = (arrayOfImportPackageSpecification1 = imports).length;
        for (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);
            }
          }
        }
      }
      ImportPackageSpecification[] addedDynamic = this$0.getAddedDynamicImportPackages();
      int j = (arrayOfImportPackageSpecification1 = addedDynamic).length;
      for (int i = 0; i < j; i++)
      {
        ImportPackageSpecification dynamicImport = arrayOfImportPackageSpecification1[i];
        BundleRequirement req = dynamicImport.getRequirement();
        if (!requirements.contains(req)) {
          requirements.add(req);
        }
      }
    }
    return requirements;
  }
  
  public List<Requirement> getResourceRequirements(String namespace)
  {
    return BundleDescriptionImpl.asListRequirement(getRequirements(namespace));
  }
  
  public List<BundleWire> getProvidedWires(String namespace)
  {
    if (!isInUse()) {
      return null;
    }
    BundleDescription[] dependentBundles = this$0.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<Wire> getProvidedResourceWires(String namespace)
  {
    return BundleDescriptionImpl.asListWire(getProvidedWires(namespace));
  }
  
  public List<BundleWire> getRequiredWires(String namespace)
  {
    if (!isInUse()) {
      return null;
    }
    List<BundleWire> result = Collections.EMPTY_LIST;
    Map<String, List<StateWire>> wireMap = this$0.getWires();
    if (namespace == null)
    {
      result = new ArrayList();
      Iterator localIterator2;
      for (Iterator localIterator1 = wireMap.values().iterator(); localIterator1.hasNext(); localIterator2.hasNext())
      {
        List<StateWire> wires = (List)localIterator1.next();
        localIterator2 = wires.iterator(); continue;wire = (StateWire)localIterator2.next();
        result.add(new BundleDescriptionImpl.BundleWireImpl(wire));
      }
      return result;
    }
    List<StateWire> wires = (List)wireMap.get(namespace);
    if (wires == null) {
      return result;
    }
    result = new ArrayList(wires.size());
    for (StateWire wire = wires.iterator(); wire.hasNext();)
    {
      StateWire wire = (StateWire)wire.next();
      result.add(new BundleDescriptionImpl.BundleWireImpl(wire));
    }
    return result;
  }
  
  public List<Wire> getRequiredResourceWires(String namespace)
  {
    return BundleDescriptionImpl.asListWire(getRequiredWires(namespace));
  }
  
  public BundleRevision getRevision()
  {
    return this$0;
  }
  
  public BundleRevision getResource()
  {
    return getRevision();
  }
  
  public ClassLoader getClassLoader()
  {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
      sm.checkPermission(BundleDescriptionImpl.GET_CLASSLOADER_PERM);
    }
    if (!isInUse()) {
      return null;
    }
    return (ClassLoader)getBundleClassLoader();
  }
  
  private BundleClassLoader getBundleClassLoader()
  {
    Object o = this$0.getUserObject();
    if (!(o instanceof BundleLoaderProxy))
    {
      if ((o instanceof BundleReference)) {
        o = ((BundleReference)o).getBundle();
      }
      if ((o instanceof BundleHost)) {
        o = ((BundleHost)o).getLoaderProxy();
      }
    }
    if ((o instanceof BundleLoaderProxy)) {
      return ((BundleLoaderProxy)o).getBundleLoader().createClassLoader();
    }
    return null;
  }
  
  private boolean hasResourcePermission()
  {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
      try
      {
        sm.checkPermission(new AdminPermission(getBundle(), "resource"));
      }
      catch (SecurityException localSecurityException)
      {
        return false;
      }
    }
    return true;
  }
  
  public List<URL> findEntries(String path, String filePattern, int options)
  {
    if ((!hasResourcePermission()) || (!isInUse())) {
      return null;
    }
    List<URL> result = Collections.EMPTY_LIST;
    BundleClassLoader bcl = getBundleClassLoader();
    if (bcl != null) {
      result = bcl.findEntries(path, filePattern, options);
    }
    return Collections.unmodifiableList(result);
  }
  
  public Collection<String> listResources(String path, String filePattern, int options)
  {
    if ((!hasResourcePermission()) || (!isInUse())) {
      return null;
    }
    Collection<String> result = Collections.EMPTY_LIST;
    BundleClassLoader bcl = getBundleClassLoader();
    if (bcl != null) {
      result = bcl.listResources(path, filePattern, options);
    }
    return Collections.unmodifiableCollection(result);
  }
  
  public String toString()
  {
    return this$0.toString();
  }
}

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

import java.util.List;
import java.util.Map;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.BundleSpecification;
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.ImportPackageSpecification;
import org.eclipse.osgi.service.resolver.NativeCodeSpecification;
import org.eclipse.osgi.service.resolver.StateWire;

final class BundleDescriptionImpl$LazyData
{
  String location;
  String platformFilter;
  BundleSpecification[] requiredBundles;
  ExportPackageDescription[] exportPackages;
  ImportPackageSpecification[] importPackages;
  GenericDescription[] genericCapabilities;
  GenericSpecification[] genericRequires;
  NativeCodeSpecification nativeCode;
  ExportPackageDescription[] selectedExports;
  GenericDescription[] selectedCapabilities;
  BundleDescription[] resolvedRequires;
  ExportPackageDescription[] resolvedImports;
  GenericDescription[] resolvedCapabilities;
  ExportPackageDescription[] substitutedExports;
  String[] executionEnvironments;
  Map<String, Long> dynamicStamps;
  Map<String, List<StateWire>> stateWires;
  List<ImportPackageSpecification> addedDynamicImports;
  final BundleDescriptionImpl this$0;
  
  BundleDescriptionImpl$LazyData(BundleDescriptionImpl paramBundleDescriptionImpl) {}
}

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

import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.osgi.framework.adaptor.BundleClassLoader;
import org.eclipse.osgi.framework.internal.core.BundleHost;
import org.eclipse.osgi.framework.util.KeyedElement;
import org.eclipse.osgi.internal.loader.BundleLoader;
import org.eclipse.osgi.internal.loader.BundleLoaderProxy;
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.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.State;
import org.eclipse.osgi.service.resolver.StateWire;
import org.eclipse.osgi.service.resolver.VersionConstraint;
import org.osgi.framework.AdminPermission;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleReference;
import org.osgi.framework.wiring.BundleCapability;
import org.osgi.framework.wiring.BundleRequirement;
import org.osgi.framework.wiring.BundleRevision;
import org.osgi.framework.wiring.BundleWire;
import org.osgi.framework.wiring.BundleWiring;
import org.osgi.resource.Capability;
import org.osgi.resource.Requirement;
import org.osgi.resource.Wire;

public final class BundleDescriptionImpl
  extends BaseDescriptionImpl
  implements BundleDescription, KeyedElement
{
  static final String[] EMPTY_STRING = new String[0];
  static final ImportPackageSpecification[] EMPTY_IMPORTS = new ImportPackageSpecification[0];
  static final BundleSpecification[] EMPTY_BUNDLESPECS = new BundleSpecification[0];
  static final ExportPackageDescription[] EMPTY_EXPORTS = new ExportPackageDescription[0];
  static final BundleDescription[] EMPTY_BUNDLEDESCS = new BundleDescription[0];
  static final GenericSpecification[] EMPTY_GENERICSPECS = new GenericSpecification[0];
  static final GenericDescription[] EMPTY_GENERICDESCS = new GenericDescription[0];
  static final RuntimePermission GET_CLASSLOADER_PERM = new RuntimePermission("getClassLoader");
  static final int RESOLVED = 1;
  static final int SINGLETON = 2;
  static final int REMOVAL_PENDING = 4;
  static final int FULLY_LOADED = 8;
  static final int LAZY_LOADED = 16;
  static final int HAS_DYNAMICIMPORT = 32;
  static final int ATTACH_FRAGMENTS = 64;
  static final int DYNAMIC_FRAGMENTS = 128;
  private volatile int stateBits = 200;
  private volatile long bundleId = -1L;
  volatile HostSpecification host;
  private volatile StateImpl containingState;
  private volatile int lazyDataOffset = -1;
  private volatile int lazyDataSize = -1;
  private List<BundleDescription> dependencies;
  private List<BundleDescription> dependents;
  private String[] mandatory;
  private Map<String, Object> attributes;
  private Map<String, String> arbitraryDirectives;
  private volatile LazyData lazyData;
  private volatile int equinox_ee = -1;
  private DescriptionWiring bundleWiring;
  
  public long getBundleId()
  {
    return bundleId;
  }
  
  public String getSymbolicName()
  {
    return getName();
  }
  
  public BundleDescription getSupplier()
  {
    return this;
  }
  
  /* Error */
  public String getLocation()
  {
    // Byte code:
    //   0: aload_0
    //   1: invokespecial 727	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl:loadLazyData	()Lorg/eclipse/osgi/internal/resolver/BundleDescriptionImpl$LazyData;
    //   4: astore_1
    //   5: aload_0
    //   6: getfield 650	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl:monitor	Ljava/lang/Object;
    //   9: dup
    //   10: astore_2
    //   11: monitorenter
    //   12: aload_1
    //   13: getfield 668	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 #85	-> byte code offset #0
    //   Java source line #86	-> byte code offset #5
    //   Java source line #87	-> byte code offset #12
    //   Java source line #86	-> 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 727	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl:loadLazyData	()Lorg/eclipse/osgi/internal/resolver/BundleDescriptionImpl$LazyData;
    //   4: astore_1
    //   5: aload_0
    //   6: getfield 650	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl:monitor	Ljava/lang/Object;
    //   9: dup
    //   10: astore_2
    //   11: monitorenter
    //   12: aload_1
    //   13: getfield 669	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 #92	-> byte code offset #0
    //   Java source line #93	-> byte code offset #5
    //   Java source line #94	-> byte code offset #12
    //   Java source line #93	-> 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 727	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl:loadLazyData	()Lorg/eclipse/osgi/internal/resolver/BundleDescriptionImpl$LazyData;
    //   4: astore_1
    //   5: aload_0
    //   6: getfield 650	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl:monitor	Ljava/lang/Object;
    //   9: dup
    //   10: astore_2
    //   11: monitorenter
    //   12: aload_1
    //   13: getfield 685	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 #153	-> byte code offset #0
    //   Java source line #154	-> byte code offset #5
    //   Java source line #155	-> byte code offset #12
    //   Java source line #154	-> 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 727	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl:loadLazyData	()Lorg/eclipse/osgi/internal/resolver/BundleDescriptionImpl$LazyData;
    //   4: astore_1
    //   5: aload_0
    //   6: getfield 650	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl:monitor	Ljava/lang/Object;
    //   9: dup
    //   10: astore_2
    //   11: monitorenter
    //   12: aload_1
    //   13: getfield 673	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 #272	-> byte code offset #0
    //   Java source line #273	-> byte code offset #5
    //   Java source line #274	-> byte code offset #12
    //   Java source line #273	-> 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;
        }
      }
    }
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 85 86 87

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-2017. Infinite Loop Ltd