org.eclipse.osgi_3.8.2.v20130124-134944

Name = lastSlash >= 0 ? resource.substring(lastSlash + 1) : resource;
      if ((!isIncluded(fileName)) || (isExcluded(fileName))) {
        resources.remove();
      }
    }
    return result;
  }
}

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

import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;

public class MultiSourcePackage
  extends PackageSource
{
  SingleSourcePackage[] suppliers;
  
  MultiSourcePackage(String id, SingleSourcePackage[] suppliers)
  {
    super(id);
    this.suppliers = suppliers;
  }
  
  public SingleSourcePackage[] getSuppliers()
  {
    return suppliers;
  }
  
  public Class<?> loadClass(String name)
    throws ClassNotFoundException
  {
    Class<?> result = null;
    for (int i = 0; i < suppliers.length; i++)
    {
      result = suppliers[i].loadClass(name);
      if (result != null) {
        return result;
      }
    }
    return result;
  }
  
  public URL getResource(String name)
  {
    URL result = null;
    for (int i = 0; i < suppliers.length; i++)
    {
      result = suppliers[i].getResource(name);
      if (result != null) {
        return result;
      }
    }
    return result;
  }
  
  public Enumeration<URL> getResources(String name)
  {
    Enumeration<URL> results = null;
    for (int i = 0; i < suppliers.length; i++) {
      results = BundleLoader.compoundEnumerations(results, suppliers[i].getResources(name));
    }
    return results;
  }
  
  public Collection<String> listResources(String path, String filePattern)
  {
    List<String> result = new ArrayList();
    SingleSourcePackage[] arrayOfSingleSourcePackage;
    int j = (arrayOfSingleSourcePackage = suppliers).length;
    for (int i = 0; i < j; i++)
    {
      SingleSourcePackage source = arrayOfSingleSourcePackage[i];
      Collection<String> sourceResources = source.listResources(path, filePattern);
      for (Iterator localIterator = sourceResources.iterator(); localIterator.hasNext();)
      {
        String resource = (String)localIterator.next();
        if (!result.contains(resource)) {
          result.add(resource);
        }
      }
    }
    return result;
  }
}

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

import java.net.URL;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import org.eclipse.osgi.framework.util.KeyedHashSet;

public class NullPackageSource
  extends PackageSource
{
  static KeyedHashSet sources;
  
  private NullPackageSource(String name)
  {
    super(name);
  }
  
  public SingleSourcePackage[] getSuppliers()
  {
    return null;
  }
  
  public boolean isNullSource()
  {
    return true;
  }
  
  public String toString()
  {
    return id + " -> null";
  }
  
  public Class<?> loadClass(String name)
  {
    return null;
  }
  
  public URL getResource(String name)
  {
    return null;
  }
  
  public Enumeration<URL> getResources(String name)
  {
    return null;
  }
  
  public static synchronized NullPackageSource getNullPackageSource(String name)
  {
    if (sources == null) {
      sources = new KeyedHashSet();
    }
    NullPackageSource result = (NullPackageSource)sources.getByKey(name);
    if (result != null) {
      return result;
    }
    result = new NullPackageSource(name);
    sources.add(result);
    return result;
  }
  
  public List<String> listResources(String path, String filePattern)
  {
    return Collections.EMPTY_LIST;
  }
}

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

import java.io.IOException;
import java.net.URL;
import java.util.Collection;
import java.util.Enumeration;
import org.eclipse.osgi.framework.util.KeyedElement;

public abstract class PackageSource
  implements KeyedElement
{
  protected String id;
  
  public PackageSource(String id)
  {
    this.id = id.intern();
  }
  
  public String getId()
  {
    return id;
  }
  
  public abstract SingleSourcePackage[] getSuppliers();
  
  public boolean compare(KeyedElement other)
  {
    return id.equals(((PackageSource)other).getId());
  }
  
  public int getKeyHashCode()
  {
    return id.hashCode();
  }
  
  public Object getKey()
  {
    return id;
  }
  
  public boolean isNullSource()
  {
    return false;
  }
  
  public boolean isFriend(String symbolicName)
  {
    return true;
  }
  
  public abstract Class<?> loadClass(String paramString)
    throws ClassNotFoundException;
  
  public abstract URL getResource(String paramString);
  
  public abstract Enumeration<URL> getResources(String paramString)
    throws IOException;
  
  public boolean hasCommonSource(PackageSource other)
  {
    if (other == null) {
      return false;
    }
    if (this == other) {
      return true;
    }
    SingleSourcePackage[] suppliers1 = getSuppliers();
    SingleSourcePackage[] suppliers2 = other.getSuppliers();
    if ((suppliers1 == null) || (suppliers2 == null)) {
      return false;
    }
    for (int i = 0; i < suppliers1.length; i++) {
      for (int j = 0; j < suppliers2.length; j++) {
        if (suppliers2[j].equals(suppliers1[i])) {
          return true;
        }
      }
    }
    return false;
  }
  
  public abstract Collection<String> listResources(String paramString1, String paramString2);
}

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

import java.net.URL;
import java.util.Collection;
import java.util.Enumeration;
import org.eclipse.osgi.framework.adaptor.BundleClassLoader;

public class SingleSourcePackage
  extends PackageSource
{
  BundleLoaderProxy supplier;
  
  public SingleSourcePackage(String id, BundleLoaderProxy supplier)
  {
    super(id);
    this.supplier = supplier;
  }
  
  public SingleSourcePackage[] getSuppliers()
  {
    return new SingleSourcePackage[] { this };
  }
  
  public String toString()
  {
    return id + " -> " + supplier;
  }
  
  public Class<?> loadClass(String name)
    throws ClassNotFoundException
  {
    return supplier.getBundleLoader().findLocalClass(name);
  }
  
  public URL getResource(String name)
  {
    return supplier.getBundleLoader().findLocalResource(name);
  }
  
  public Enumeration<URL> getResources(String name)
  {
    return supplier.getBundleLoader().findLocalResources(name);
  }
  
  public boolean equals(Object source)
  {
    if (this == source) {
      return true;
    }
    if (!(source instanceof SingleSourcePackage)) {
      return false;
    }
    SingleSourcePackage singleSource = (SingleSourcePackage)source;
    
    return (supplier == supplier) && (id == singleSource.getId());
  }
  
  public int hashCode()
  {
    int result = 1;
    result = 31 * result + id.hashCode();
    result = 31 * result + supplier.hashCode();
    return result;
  }
  
  public Collection<String> listResources(String path, String filePattern)
  {
    BundleClassLoader bcl = supplier.getBundleLoader().createClassLoader();
    return bcl.listLocalResources(path, filePattern, 0);
  }
}

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

import java.io.IOException;
import java.net.URL;
import java.security.ProtectionDomain;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import org.eclipse.osgi.framework.adaptor.BundleClassLoader;
import org.eclipse.osgi.framework.adaptor.BundleData;
import org.eclipse.osgi.framework.adaptor.ClassLoaderDelegate;
import org.osgi.framework.Bundle;

class SystemBundleLoader$1
  implements BundleClassLoader
{
  final SystemBundleLoader this$0;
  
  SystemBundleLoader$1(SystemBundleLoader paramSystemBundleLoader) {}
  
  public Bundle getBundle()
  {
    return this$0.getBundle();
  }
  
  public Class<?> loadClass(String name)
    throws ClassNotFoundException
  {
    return this$0.loadClass(name);
  }
  
  public void initialize() {}
  
  public Enumeration<URL> getResources(String name)
    throws IOException
  {
    return findLocalResources(name);
  }
  
  public URL getResource(String name)
  {
    return this$0.findLocalResource(name);
  }
  
  public ClassLoader getParent()
  {
    return this$0.classLoader.getParent();
  }
  
  public ClassLoaderDelegate getDelegate()
  {
    return this$0;
  }
  
  public Enumeration<URL> findLocalResources(String resource)
  {
    return this$0.findLocalResources(resource);
  }
  
  public URL findLocalResource(String resource)
  {
    return getResource(resource);
  }
  
  public Class<?> findLocalClass(String classname)
    throws ClassNotFoundException
  {
    return this$0.findLocalClass(classname);
  }
  
  public void close() {}
  
  public void attachFragment(BundleData bundledata, ProtectionDomain domain, String[] classpath) {}
  
  public List<URL> findEntries(String path, String filePattern, int options)
  {
    Bundle systemBundle = this$0.getBundle();
    boolean recurse = (options & 0x1) != 0;
    
    List<URL> result = Collections.EMPTY_LIST;
    Enumeration<URL> entries = systemBundle.findEntries(path, filePattern, recurse);
    if (entries != null)
    {
      result = new ArrayList();
      while (entries.hasMoreElements()) {
        result.add((URL)entries.nextElement());
      }
    }
    return Collections.unmodifiableList(result);
  }
  
  public Collection<String> listResources(String path, String filePattern, int options)
  {
    return Collections.EMPTY_LIST;
  }
  
  public Collection<String> listLocalResources(String path, String filePattern, int options)
  {
    return Collections.EMPTY_LIST;
  }
}

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

import java.io.IOException;
import java.net.URL;
import java.security.ProtectionDomain;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.eclipse.osgi.framework.adaptor.BundleClassLoader;
import org.eclipse.osgi.framework.adaptor.BundleData;
import org.eclipse.osgi.framework.adaptor.BundleProtectionDomain;
import org.eclipse.osgi.framework.adaptor.ClassLoaderDelegate;
import org.eclipse.osgi.framework.internal.core.BundleFragment;
import org.eclipse.osgi.framework.internal.core.BundleHost;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.ExportPackageDescription;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;

public class SystemBundleLoader
  extends BundleLoader
{
  public static final String EQUINOX_EE = "x-equinox-ee";
  final ClassLoader classLoader;
  private final Set<String> eePackages;
  private final Set<String> extPackages;
  private final ClassLoader extClassLoader;
  
  protected SystemBundleLoader(BundleHost bundle, BundleLoaderProxy proxy)
    throws BundleException
  {
    super(bundle, proxy);
    ExportPackageDescription[] exports = proxy.getBundleDescription().getSelectedExports();
    if ((exports == null) || (exports.length == 0))
    {
      eePackages = null;
    }
    else
    {
      eePackages = new HashSet(exports.length);
      for (int i = 0; i < exports.length; i++) {
        if (((Integer)exports[i].getDirective("x-equinox-ee")).intValue() >= 0) {
          eePackages.add(exports[i].getName());
        }
      }
    }
    classLoader = getClass().getClassLoader();
    extPackages = new HashSet(0);
    BundleFragment[] fragments = bundle.getFragments();
    if (fragments != null) {
      for (int i = 0; i < fragments.length; i++) {
        addExtPackages(fragments[i]);
      }
    }
    ClassLoader extCL = ClassLoader.getSystemClassLoader();
    if (extCL == null)
    {
      extClassLoader = null;
    }
    else
    {
      while (extCL.getParent() != null) {
        extCL = extCL.getParent();
      }
      boolean found = false;
      ClassLoader systemExtCL = classLoader;
      while ((systemExtCL.getParent() != null) && (!found)) {
        if (systemExtCL.getParent() == extCL) {
          found = true;
        } else {
          systemExtCL = systemExtCL.getParent();
        }
      }
      extClassLoader = (found ? null : extCL);
    }
  }
  
  private void addExtPackages(BundleFragment fragment)
  {
    if ((fragment.getBundleData().getType() & 0x10) == 0) {
      return;
    }
    ExportPackageDescription[] extExports = fragment.getBundleDescription().getExportPackages();
    for (int j = 0; j < extExports.length; j++) {
      extPackages.add(extExports[j].getName());
    }
  }
  
  public synchronized void attachFragment(BundleFragment fragment)
    throws BundleException
  {
    super.attachFragment(fragment);
    synchronized (extPackages)
    {
      addExtPackages(fragment);
    }
  }
  
  public Class<?> findClass(String name)
    throws ClassNotFoundException
  {
    Class<?> result = findLocalClass(name);
    if (result == null) {
      throw new ClassNotFoundException(name);
    }
    return result;
  }
  
  public String findLibrary(String name)
  {
    return null;
  }
  
  Class<?> findLocalClass(String name)
  {
    try
    {
      return classLoader.loadClass(name);
    }
    catch (ClassNotFoundException localClassNotFoundException1)
    {
      if (extClassLoader != null) {
        synchronized (extPackages)
        {
          if ((extPackages.size() > 0) && (extPackages.contains(BundleLoader.getPackageName(name)))) {
            try
            {
              return extClassLoader.loadClass(name);
            }
            catch (ClassNotFoundException localClassNotFoundException2)
            {
              return null;
            }
          }
        }
      }
    }
    return null;
  }
  
  URL findLocalResource(String name)
  {
    URL result = classLoader.getResource(name);
    if ((result == null) && (extClassLoader != null)) {
      synchronized (extPackages)
      {
        if ((extPackages.size() > 0) && (extPackages.contains(BundleLoader.getResourcePackageName(name)))) {
          result = extClassLoader.getResource(name);
        }
      }
    }
    return result;
  }
  
  Enumeration<URL> findLocalResources(String name)
  {
    Enumeration<URL> result = null;
    try
    {
      result = classLoader.getResources(name);
    }
    catch (IOException localIOException1) {}
    if (((result == null) || (!result.hasMoreElements())) && (extClassLoader != null)) {
      synchronized (extPackages)
      {
        if ((extPackages.size() > 0) && (extPackages.contains(BundleLoader.getResourcePackageName(name)))) {
          try
          {
            result = extClassLoader.getResources(name);
          }
          catch (IOException localIOException2) {}
        }
      }
    }
    return result;
  }
  
  public URL findResource(String name)
  {
    return findLocalResource(name);
  }
  
  public Enumeration<URL> findResources(String name)
    throws IOException
  {
    return findLocalResources(name);
  }
  
  protected void close() {}
  
  public boolean isEEPackage(String pkgName)
  {
    return eePackages.contains(pkgName);
  }
  
  BundleClassLoader createBCL(BundleProtectionDomain pd, String[] cp)
  {
    new BundleClassLoader()
    {
      public Bundle getBundle()
      {
        return getBundle();
      }
      
      public Class<?> loadClass(String name)
        throws ClassNotFoundException
      {
        return SystemBundleLoader.this.loadClass(name);
      }
      
      public void initialize() {}
      
      public Enumeration<URL> getResources(String name)
        throws IOException
      {
        return findLocalResources(name);
      }
      
      public URL getResource(String name)
      {
        return SystemBundleLoader.this.findLocalResource(name);
      }
      
      public ClassLoader getParent()
      {
        return classLoader.getParent();
      }
      
      public ClassLoaderDelegate getDelegate()
      {
        return SystemBundleLoader.this;
      }
      
      public Enumeration<URL> findLocalResources(String resource)
      {
        return SystemBundleLoader.this.findLocalResources(resource);
      }
      
      public URL findLocalResource(String resource)
      {
        return getResource(resource);
      }
      
      public Class<?> findLocalClass(String classname)
        throws ClassNotFoundException
      {
        return SystemBundleLoader.this.findLocalClass(classname);
      }
      
      public void close() {}
      
      public void attachFragment(BundleData bundledata, ProtectionDomain domain, String[] classpath) {}
      
      public List<URL> findEntries(String path, String filePattern, int options)
      {
        Bundle systemBundle = getBundle();
        boolean recurse = (options & 0x1) != 0;
        
        List<URL> result = Collections.EMPTY_LIST;
        Enumeration<URL> entries = systemBundle.findEntries(path, filePattern, recurse);
        if (entries != null)
        {
          result = new ArrayList();
          while (entries.hasMoreElements()) {
            result.add((URL)entries.nextElement());
          }
        }
        return Collections.unmodifiableList(result);
      }
      
      public Collection<String> listResources(String path, String filePattern, int options)
      {
        return Collections.EMPTY_LIST;
      }
      
      public Collection<String> listLocalResources(String path, String filePattern, int options)
      {
        return Collections.EMPTY_LIST;
      }
    };
  }
}

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

import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import org.eclipse.osgi.framework.internal.core.AbstractBundle;
import org.eclipse.osgi.internal.loader.BundleLoader;
import org.eclipse.osgi.internal.loader.BundleLoaderProxy;
import org.eclipse.osgi.service.resolver.BundleDescription;

public class DependentPolicy
  implements IBuddyPolicy
{
  BundleLoader buddyRequester;
  int lastDependentOfAdded = -1;
  List<BundleDescription> allDependents = null;
  
  public DependentPolicy(BundleLoader requester)
  {
    buddyRequester = requester;
    
    allDependents = new ArrayList();
    basicAddImmediateDependents(buddyRequester.getBundle().getBundleDescription());
    if (allDependents.size() == 0) {
      allDependents = null;
    }
  }
  
  public Class<?> loadClass(String name)
  {
    if (allDependents == null) {
      return null;
    }
    Class<?> result = null;
    for (int i = 0; (i < allDependents.size()) && (result == null); i++)
    {
      BundleDescription searchedBundle = (BundleDescription)allDependents.get(i);
      try
      {
        BundleLoaderProxy proxy = buddyRequester.getLoaderProxy(searchedBundle);
        if (proxy != null) {
          result = proxy.getBundleLoader().findClass(name);
        }
      }
      catch (ClassNotFoundException localClassNotFoundException)
      {
        if (result == null) {
          addDependent(i, searchedBundle);
        }
      }
    }
    return result;
  }
  
  private synchronized void addDependent(int i, BundleDescription searchedBundle)
  {
    if (i > lastDependentOfAdded)
    {
      lastDependentOfAdded = i;
      basicAddImmediateDependents(searchedBundle);
    }
  }
  
  public URL loadResource(String name)
  {
    if (allDependents == null) {
      return null;
    }
    URL result = null;
    for (int i = 0; (i < allDependents.size()) && (result == null); i++)
    {
      BundleDescription searchedBundle = (BundleDescription)allDependents.get(i);
      BundleLoaderProxy proxy = buddyRequester.getLoaderProxy(searchedBundle);
      if (proxy != null)
      {
        result = proxy.getBundleLoader().findResource(name);
        if (result == null) {
          addDependent(i, searchedBundle);
        }
      }
    }
    return result;
  }
  
  public Enumeration<URL> loadResources(String name)
  {
    if (allDependents == null) {
      return null;
    }
    Enumeration<URL> results = null;
    for (int i = 0; i < allDependents.size(); i++)
    {
      BundleDescription searchedBundle = (BundleDescription)allDependents.get(i);
      try
      {
        BundleLoaderProxy proxy = buddyRequester.getLoaderProxy(searchedBundle);
        if (proxy != null)
        {
          results = BundleLoader.compoundEnumerations(results, proxy.getBundleLoader().findResources(name));
          addDependent(i, searchedBundle);
        }
      }
      catch (IOException localIOException) {}
    }
    return results;
  }
  
  private void basicAddImmediateDependents(BundleDescription root)
  {
    BundleDescription[] dependents = root.getDependents();
    for (int i = 0; i < dependents.length; i++)
    {
      BundleDescription toAdd = dependents[i];
      if ((toAdd.getHost() == null) && (!allDependents.contains(toAdd))) {
        allDependents.add(toAdd);
      }
    }
  }
}

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

import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;
import org.eclipse.osgi.internal.loader.BundleLoader;
import org.osgi.framework.Bundle;
import org.osgi.service.packageadmin.ExportedPackage;
import org.osgi.service.packageadmin.PackageAdmin;

public class GlobalPolicy
  implements IBuddyPolicy
{
  private PackageAdmin admin;
  
  public GlobalPolicy(PackageAdmin admin)
  {
    this.admin = admin;
  }
  
  public Class<?> loadClass(String name)
  {
    ExportedPackage pkg = admin.getExportedPackage(BundleLoader.getPackageName(name));
    if (pkg == null) {
      return null;
    }
    try
    {
      return pkg.getExportingBundle().loadClass(name);
    }
    catch (ClassNotFoundException localClassNotFoundException) {}
    return null;
  }
  
  public URL loadResource(String name)
  {
    ExportedPackage pkg = admin.getExportedPackage(BundleLoader.getResourcePackageName(name));
    if (pkg == null) {
      return null;
    }
    return pkg.getExportingBundle().getResource(name);
  }
  
  public Enumeration<URL> loadResources(String name)
  {
    ExportedPackage[] pkgs = admin.getExportedPackages(BundleLoader.getResourcePackageName(name));
    if ((pkgs == null) || (pkgs.length == 0)) {
      return null;
    }
    Enumeration<URL> results = null;
    for (int i = 0; i < pkgs.length; i++) {
      try
      {
        results = BundleLoader.compoundEnumerations(results, pkgs[i].getExportingBundle().getResources(name));
      }
      catch (IOException localIOException) {}
    }
    return results;
  }
}

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

import java.net.URL;
import java.util.Enumeration;

public abstract interface IBuddyPolicy
{
  public abstract Class<?> loadClass(String paramString);
  
  public abstract URL loadResource(String paramString);
  
  public abstract Enumeration<URL> loadResources(String paramString);
}

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

import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
import org.eclipse.osgi.framework.adaptor.BundleData;
import org.eclipse.osgi.framework.internal.core.AbstractBundle;
import org.eclipse.osgi.internal.loader.BundleLoader;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleException;
import org.osgi.framework.SynchronousBundleListener;
import org.osgi.service.packageadmin.PackageAdmin;

public class PolicyHandler
  implements SynchronousBundleListener
{
  private static final String DEPENDENT_POLICY = "dependent";
  private static final String GLOBAL_POLICY = "global";
  private static final String REGISTERED_POLICY = "registered";
  private static final String APP_POLICY = "app";
  private static final String EXT_POLICY = "ext";
  private static final String BOOT_POLICY = "boot";
  private static final String PARENT_POLICY = "parent";
  private final BundleLoader policedLoader;
  private volatile Object[] policies = null;
  private final ThreadLocal<Set<String>> beingLoaded;
  private final PackageAdmin packageAdmin;
  
  public PolicyHandler(BundleLoader loader, String buddyList, PackageAdmin packageAdmin)
  {
    policedLoader = loader;
    policies = getArrayFromList(buddyList);
    beingLoaded = new ThreadLocal();
    this.packageAdmin = packageAdmin;
  }
  
  static Object[] getArrayFromList(String stringList)
  {
    if ((stringList == null) || (stringList.trim().equals(""))) {
      return null;
    }
    List<Object> list = new ArrayList();
    StringTokenizer tokens = new StringTokenizer(stringList, ",");
    while (tokens.hasMoreTokens())
    {
      String token = tokens.nextToken().trim();
      if (!token.equals("")) {
        list.add(token);
      }
    }
    return list.isEmpty() ? new Object[0] : list.toArray(new Object[list.size()]);
  }
  
  private IBuddyPolicy getPolicyImplementation(Object[] policiesSnapshot, int policyOrder)
  {
    synchronized (policiesSnapshot)
    {
      if (policyOrder >= policiesSnapshot.length) {
        return null;
      }
      if ((policiesSnapshot[policyOrder] instanceof String))
      {
        String buddyName = (String)policiesSnapshot[policyOrder];
        if ("registered".equals(buddyName))
        {
          policiesSnapshot[policyOrder] = new RegisteredPolicy(policedLoader);
          return (IBuddyPolicy)policiesSnapshot[policyOrder];
        }
        if ("boot".equals(buddyName))
        {
          policiesSnapshot[policyOrder] = SystemPolicy.getInstance(0);
          return (IBuddyPolicy)policiesSnapshot[policyOrder];
        }
        if ("app".equals(buddyName))
        {
          policiesSnapshot[policyOrder] = SystemPolicy.getInstance(2);
          return (IBuddyPolicy)policiesSnapshot[policyOrder];
        }
        if ("ext".equals(buddyName))
        {
          policiesSnapshot[policyOrder] = SystemPolicy.getInstance(1);
          return (IBuddyPolicy)policiesSnapshot[policyOrder];
        }
        if ("dependent".equals(buddyName))
        {
          policiesSnapshot[policyOrder] = new DependentPolicy(policedLoader);
          return (IBuddyPolicy)policiesSnapshot[policyOrder];
        }
        if ("global".equals(buddyName))
        {
          policiesSnapshot[policyOrder] = new GlobalPolicy(packageAdmin);
          return (IBuddyPolicy)policiesSnapshot[policyOrder];
        }
        if ("parent".equals(buddyName))
        {
          policiesSnapshot[policyOrder] = new SystemPolicy(policedLoader.getParentClassLoader());
          return (IBuddyPolicy)policiesSnapshot[policyOrder];
        }
      }
      return (IBuddyPolicy)policiesSnapshot[policyOrder];
    }
  }
  
  public Class<?> doBuddyClassLoading(String name)
  {
    if (!startLoading(name)) {
      return null;
    }
    Class<?> result = null;
    Object[] policiesSnapshot = policies;
    int policyCount = policiesSnapshot == null ? 0 : policiesSnapshot.length;
    for (int i = 0; (i < policyCount) && (result == null); i++)
    {
      IBuddyPolicy policy = getPolicyImplementation(policiesSnapshot, i);
      if (policy != null) {
        result = policy.loadClass(name);
      }
    }
    stopLoading(name);
    return result;
  }
  
  public URL doBuddyResourceLoading(String name)
  {
    if (!startLoading(name)) {
      return null;
    }
    URL result = null;
    Object[] policiesSnapshot = policies;
    int policyCount = policiesSnapshot == null ? 0 : policiesSnapshot.length;
    for (int i = 0; (i < policyCount) && (result == null); i++)
    {
      IBuddyPolicy policy = getPolicyImplementation(policiesSnapshot, i);
      if (policy != null) {
        result = policy.loadResource(name);
      }
    }
    stopLoading(name);
    return result;
  }
  
  public Enumeration<URL> doBuddyResourcesLoading(String name)
  {
    if (!startLoading(name)) {
      return null;
    }
    List<URL> results = null;
    Object[] policiesSnapshot = policies;
    int policyCount = policiesSnapshot == null ? 0 : policiesSnapshot.length;
    for (int i = 0; i < policyCount; i++)
    {
      IBuddyPolicy policy = getPolicyImplementation(policiesSnapshot, i);
      if (policy != null)
      {
        Enumeration<URL> result = policy.loadResources(name);
        if (result != null)
        {
          if (results == null) {
            results = new ArrayList(policyCount);
          }
          while (result.hasMoreElements())
          {
            URL url = (URL)result.nextElement();
            if (!results.contains(url)) {
              results.add(url);
            }
          }
        }
      }
    }
    stopLoading(name);
    return (results == null) || (results.isEmpty()) ? null : Collections.enumeration(results);
  }
  
  private boolean startLoading(String name)
  {
    Set<String> classesAndResources = (Set)beingLoaded.get();
    if ((classesAndResources != null) && (classesAndResources.contains(name))) {
      return false;
    }
    if (classesAndResources == null)
    {
      classesAndResources = new HashSet(3);
      beingLoaded.set(classesAndResources);
    }
    classesAndResources.add(name);
    return true;
  }
  
  private void stopLoading(String name)
  {
    ((Set)beingLoaded.get()).remove(name);
  }
  
  public void open(BundleContext context)
  {
    context.addBundleListener(this);
  }
  
  public void close(BundleContext context)
  {
    context.removeBundleListener(this);
  }
  
  public void bundleChanged(BundleEvent event)
  {
    if ((event.getType() & 0x60) == 0) {
      return;
    }
    try
    {
      String list = (String)policedLoader.getBundle().getBundleData().getManifest().get("Eclipse-BuddyPolicy");
      policies = getArrayFromList(list);
    }
    catch (BundleException localBundleException) {}
  }
}

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

import java.io.IOException;
import java.net.URL;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import org.eclipse.osgi.framework.adaptor.BundleData;
import org.eclipse.osgi.framework.internal.core.AbstractBundle;
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.util.ManifestElement;
import org.osgi.framework.BundleException;

public class RegisteredPolicy
  extends DependentPolicy
{
  public RegisteredPolicy(BundleLoader requester)
  {
    super(requester);
    if (allDependents == null) {
      return;
    }
    for (Iterator<BundleDescription> iter = allDependents.iterator(); iter.hasNext();)
    {
      BundleLoaderProxy proxy = buddyRequester.getLoaderProxy((BundleDescription)iter.next());
      if (proxy == null) {
        iter.remove();
      }
      try
      {
        String[] allContributions = ManifestElement.getArrayFromList((String)((AbstractBundle)proxy.getBundle()).getBundleData().getManifest().get("Eclipse-RegisterBuddy"));
        if (allContributions == null)
        {
          iter.remove();
        }
        else
        {
          boolean contributes = false;
          for (int j = 0; (j < allContributions.length) && (!contributes); j++) {
            if (allContributions[j].equals(buddyRequester.getBundle().getSymbolicName())) {
              contributes = true;
            }
          }
          if (!contributes) {
            iter.remove();
          }
        }
      }
      catch (BundleException localBundleException)
      {
        iter.remove();
      }
    }
    if (allDependents.size() == 0) {
      allDependents = null;
    }
  }
  
  public Class<?> loadClass(String name)
  {
    if (allDependents == null) {
      return null;
    }
    Class<?> result = null;
    int size = allDependents.size();
    for (int i = 0; (i < size) && (result == null); i++) {
      try
      {
        BundleLoaderProxy proxy = buddyRequester.getLoaderProxy((BundleDescription)allDependents.get(i));
        if (proxy != null) {
          result = proxy.getBundleLoader().findClass(name);
        }
      }
      catch (ClassNotFoundException localClassNotFoundException) {}
    }
    return result;
  }
  
  public URL loadResource(String name)
  {
    if (allDependents == null) {
      return null;
    }
    URL result = null;
    int size = allDependents.size();
    for (int i = 0; (i < size) && (result == null); i++)
    {
      BundleLoaderProxy proxy = buddyRequester.getLoaderProxy((BundleDescription)allDependents.get(i));
      if (proxy != null) {
        result = proxy.getBundleLoader().findResource(name);
      }
    }
    return result;
  }
  
  public Enumeration<URL> loadResources(String name)
  {
    if (allDependents == null) {
      return null;
    }
    Enumeration<URL> results = null;
    int size = allDependents.size();
    for (int i = 0; i < size; i++) {
      try
      {
        BundleLoaderProxy proxy = buddyRequester.getLoaderProxy((BundleDescription)allDependents.get(i));
        if (proxy != null) {
          results = BundleLoader.compoundEnumerations(results, proxy.getBundleLoader().findResources(name));
        }
      }
      catch (IOException localIOException) {}
    }
    return results;
  }
}

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

import java.security.PrivilegedAction;

class SystemPolicy$1
  implements PrivilegedAction<ClassLoader>
{
  private final byte val$type;
  
  SystemPolicy$1(byte paramByte) {}
  
  public ClassLoader run()
  {
    return SystemPolicy.createClassLoader(val$type);
  }
}

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

class SystemPolicy$ParentClassLoader
  extends ClassLoader
{
  protected SystemPolicy$ParentClassLoader()
  {
    super(tmp4_1.getClassLoader());
  }
}

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

import java.io.IOException;
import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Enumeration;

public class SystemPolicy
  implements IBuddyPolicy
{
  public static final byte BOOT = 0;
  public static final byte EXT = 1;
  public static final byte APP = 2;
  
  private static class ParentClassLoader
    extends ClassLoader
  {
    protected ParentClassLoader()
    {
      super();
    }
  }
  
  private static SystemPolicy[] instances = new SystemPolicy[3];
  private ClassLoader classLoader;
  static Class class$0;
  
  public static SystemPolicy getInstance(byte type)
  {
    if (instances[type] == null)
    {
      instances[type] = new SystemPolicy();
      instancesclassLoader = ((ClassLoader)AccessController.doPrivileged(new PrivilegedAction()
      {
        private final byte val$type;
        
        public ClassLoader run()
        {
          return SystemPolicy.createClassLoader(val$type);
        }
      }));
    }
    return instances[type];
  }
  
  public SystemPolicy() {}
  
  public SystemPolicy(ClassLoader parent)
  {
    classLoader = parent;
  }
  
  static ClassLoader createClassLoader(byte type)
  {
    switch (type)
    {
    case 2: 
      if (ClassLoader.getSystemClassLoader() != null) {
        return ClassLoader.getSystemClassLoader();
      }
      return new ParentClassLoader();
    case 0: 
      return new ParentClassLoader();
    case 1: 
      if (ClassLoader.getSystemClassLoader() != null) {
        return ClassLoader.getSystemClassLoader().getParent();
      }
      return new ParentClassLoader();
    }
    return null;
  }
  
  public Class<?> loadClass(String name)
  {
    try
    {
      return classLoader.loadClass(name);
    }
    catch (ClassNotFoundException localClassNotFoundException) {}
    return null;
  }
  
  public URL loadResource(String name)
  {
    return classLoader.getResource(name);
  }
  
  public Enumeration<URL> loadResources(String name)
  {
    try
    {
      return classLoader.getResources(name);
    }
    catch (IOException localIOException) {}
    return null;
  }
}

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

import org.eclipse.osgi.service.resolver.BundleSpecification;
import org.eclipse.osgi.service.resolver.HostSpecification;
import org.eclipse.osgi.service.resolver.VersionConstraint;

public class BundleConstraint
  extends ResolverConstraint
{
  BundleConstraint(ResolverBundle bundle, VersionConstraint bundleConstraint)
  {
    super(bundle, bundleConstraint);
  }
  
  boolean isOptional()
  {
    if ((constraint instanceof HostSpecification)) {
      return false;
    }
    return ((BundleSpecification)constraint).isOptional();
  }
}

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

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

public abstract interface CompositeResolveHelper
{
  public abstract boolean giveExports(ExportPackageDescription[] paramArrayOfExportPackageDescription);
}

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

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

public abstract interface CompositeResolveHelperRegistry
{
  public abstract CompositeResolveHelper getCompositeResolveHelper(BundleDescription paramBundleDescription);
}

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

import java.util.Map;
import org.eclipse.osgi.service.resolver.BaseDescription;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org
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