org.eclipse.osgi_3.8.2.v20130124-134944

pse.osgi.framework.internal.core.PackageAdminImpl;
import org.eclipse.osgi.internal.module.CompositeResolveHelper;
import org.eclipse.osgi.service.internal.composite.CompositeModule;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;

public abstract class CompositeBase
  extends BundleHost
  implements CompositeResolveHelper, CompositeModule
{
  protected static String PROP_COMPOSITE = "org.eclipse.equinox.Composite";
  protected static String PROP_PARENTFRAMEWORK = "org.eclipse.equinox.parentFramework";
  protected final org.osgi.framework.launch.Framework companionFramework;
  protected final ThreadLocal resolving = new ThreadLocal();
  
  public CompositeBase(BundleData bundledata, org.eclipse.osgi.framework.internal.core.Framework framework)
    throws BundleException
  {
    super(bundledata, framework);
    companionFramework = findCompanionFramework(framework, bundledata);
  }
  
  protected abstract org.osgi.framework.launch.Framework findCompanionFramework(org.eclipse.osgi.framework.internal.core.Framework paramFramework, BundleData paramBundleData)
    throws BundleException;
  
  protected abstract Bundle getCompanionBundle();
  
  protected boolean isSurrogate()
  {
    return false;
  }
  
  public BundleDescription getCompositeDescription()
  {
    return getBundleDescription();
  }
  
  public ClassLoaderDelegate getDelegate()
  {
    return getBundleLoader();
  }
  
  /* Error */
  public void refreshContent()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 107	org/eclipse/osgi/internal/composite/CompositeBase:resolving	Ljava/lang/ThreadLocal;
    //   4: getstatic 104	java/lang/Boolean:TRUE	Ljava/lang/Boolean;
    //   7: invokevirtual 112	java/lang/ThreadLocal:set	(Ljava/lang/Object;)V
    //   10: aload_0
    //   11: getfield 108	org/eclipse/osgi/internal/composite/CompositeBase:framework	Lorg/eclipse/osgi/framework/internal/core/Framework;
    //   14: invokevirtual 115	org/eclipse/osgi/framework/internal/core/Framework:getPackageAdmin	()Lorg/eclipse/osgi/framework/internal/core/PackageAdminImpl;
    //   17: iconst_1
    //   18: anewarray 62	org/osgi/framework/Bundle
    //   21: dup
    //   22: iconst_0
    //   23: aload_0
    //   24: aastore
    //   25: iconst_1
    //   26: aconst_null
    //   27: invokevirtual 117	org/eclipse/osgi/framework/internal/core/PackageAdminImpl:refreshPackages	([Lorg/osgi/framework/Bundle;Z[Lorg/osgi/framework/FrameworkListener;)V
    //   30: goto +14 -> 44
    //   33: astore_1
    //   34: aload_0
    //   35: getfield 107	org/eclipse/osgi/internal/composite/CompositeBase:resolving	Ljava/lang/ThreadLocal;
    //   38: aconst_null
    //   39: invokevirtual 112	java/lang/ThreadLocal:set	(Ljava/lang/Object;)V
    //   42: aload_1
    //   43: athrow
    //   44: aload_0
    //   45: getfield 107	org/eclipse/osgi/internal/composite/CompositeBase:resolving	Ljava/lang/ThreadLocal;
    //   48: aconst_null
    //   49: invokevirtual 112	java/lang/ThreadLocal:set	(Ljava/lang/Object;)V
    //   52: return
    // Line number table:
    //   Java source line #67	-> byte code offset #0
    //   Java source line #69	-> byte code offset #10
    //   Java source line #70	-> byte code offset #30
    //   Java source line #71	-> byte code offset #34
    //   Java source line #72	-> byte code offset #42
    //   Java source line #71	-> byte code offset #44
    //   Java source line #73	-> byte code offset #52
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	53	0	this	CompositeBase
    //   33	10	1	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   10	33	33	finally
  }
  
  public boolean resolveContent()
  {
    resolving.set(Boolean.TRUE);
    try
    {
      return framework.getPackageAdmin().resolveBundles(new Bundle[] { this });
    }
    finally
    {
      resolving.set(null);
    }
  }
  
  public void started(CompositeModule surrogate) {}
  
  public void stopped(CompositeModule surrogate) {}
  
  public void updateContent(InputStream content)
    throws BundleException
  {
    super.update(content);
  }
  
  public void update()
    throws BundleException
  {
    throw new BundleException("Cannot update composite bundles", 2);
  }
  
  public void update(InputStream in)
    throws BundleException
  {
    try
    {
      in.close();
    }
    catch (IOException localIOException) {}
    throw new BundleException("Cannot update composite bundles", 2);
  }
}

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

import java.io.IOException;
import java.net.URL;
import java.security.ProtectionDomain;
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.baseadaptor.BaseData;
import org.eclipse.osgi.baseadaptor.bundlefile.BundleEntry;
import org.eclipse.osgi.baseadaptor.bundlefile.BundleFile;
import org.eclipse.osgi.baseadaptor.loader.BaseClassLoader;
import org.eclipse.osgi.baseadaptor.loader.ClasspathEntry;
import org.eclipse.osgi.baseadaptor.loader.ClasspathManager;
import org.eclipse.osgi.framework.adaptor.BundleData;
import org.eclipse.osgi.framework.adaptor.ClassLoaderDelegate;
import org.osgi.framework.Bundle;

public class CompositeClassLoader
  extends ClassLoader
  implements BaseClassLoader
{
  private final ClassLoaderDelegate delegate;
  private final ClasspathManager manager;
  private final ClassLoaderDelegate companionDelegate;
  private final ThreadLocal beingLoaded = new ThreadLocal();
  
  public CompositeClassLoader(ClassLoader parent, ClassLoaderDelegate delegate, ClassLoaderDelegate companionDelegate, BaseData data)
  {
    super(parent);
    this.delegate = delegate;
    manager = new ClasspathManager(data, new String[0], this);
    this.companionDelegate = companionDelegate;
  }
  
  public ClasspathEntry createClassPathEntry(BundleFile bundlefile, ProtectionDomain cpDomain)
  {
    return null;
  }
  
  public Class defineClass(String name, byte[] classbytes, ClasspathEntry classpathEntry, BundleEntry entry)
  {
    return null;
  }
  
  public ClasspathManager getClasspathManager()
  {
    return manager;
  }
  
  public ProtectionDomain getDomain()
  {
    return null;
  }
  
  public Object publicDefinePackage(String name, String specTitle, String specVersion, String specVendor, String implTitle, String implVersion, String implVendor, URL sealBase)
  {
    return definePackage(name, specTitle, specVersion, specVendor, implTitle, implVersion, implVendor, sealBase);
  }
  
  public Class publicFindLoaded(String classname)
  {
    return findLoadedClass(classname);
  }
  
  public Object publicGetPackage(String pkgname)
  {
    return getPackage(pkgname);
  }
  
  public void attachFragment(BundleData bundledata, ProtectionDomain domain, String[] classpath) {}
  
  public void close() {}
  
  public Class findLocalClass(String classname)
    throws ClassNotFoundException
  {
    if (!startLoading(classname)) {
      throw new ClassNotFoundException(classname);
    }
    try
    {
      return companionDelegate.findClass(classname);
    }
    finally
    {
      stopLoading(classname);
    }
  }
  
  public URL findLocalResource(String resource)
  {
    if (!startLoading(resource)) {
      return null;
    }
    try
    {
      return companionDelegate.findResource(resource);
    }
    finally
    {
      stopLoading(resource);
    }
  }
  
  public Enumeration findLocalResources(String resource)
  {
    if (!startLoading(resource)) {
      return null;
    }
    try
    {
      return companionDelegate.findResources(resource);
    }
    catch (IOException localIOException)
    {
      return null;
    }
    finally
    {
      stopLoading(resource);
    }
  }
  
  public ClassLoaderDelegate getDelegate()
  {
    return delegate;
  }
  
  public URL getResource(String name)
  {
    return delegate.findResource(name);
  }
  
  public void initialize()
  {
    manager.initialize();
  }
  
  public Class loadClass(String name)
    throws ClassNotFoundException
  {
    return delegate.findClass(name);
  }
  
  private boolean startLoading(String name)
  {
    Set 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 Bundle getBundle()
  {
    return manager.getBaseData().getBundle();
  }
  
  public List<URL> findEntries(String path, String filePattern, int options)
  {
    return Collections.EMPTY_LIST;
  }
  
  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.composite.CompositeClassLoader
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.internal.composite;

import java.io.IOException;
import java.io.InputStream;
import java.net.URLConnection;
import java.security.AllPermission;
import java.security.ProtectionDomain;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import org.eclipse.osgi.baseadaptor.BaseAdaptor;
import org.eclipse.osgi.baseadaptor.BaseData;
import org.eclipse.osgi.baseadaptor.HookConfigurator;
import org.eclipse.osgi.baseadaptor.HookRegistry;
import org.eclipse.osgi.baseadaptor.bundlefile.BundleEntry;
import org.eclipse.osgi.baseadaptor.hooks.AdaptorHook;
import org.eclipse.osgi.baseadaptor.hooks.ClassLoadingHook;
import org.eclipse.osgi.baseadaptor.loader.BaseClassLoader;
import org.eclipse.osgi.baseadaptor.loader.ClasspathEntry;
import org.eclipse.osgi.baseadaptor.loader.ClasspathManager;
import org.eclipse.osgi.framework.adaptor.BundleProtectionDomain;
import org.eclipse.osgi.framework.adaptor.ClassLoaderDelegate;
import org.eclipse.osgi.framework.log.FrameworkLog;
import org.eclipse.osgi.internal.module.CompositeResolveHelper;
import org.eclipse.osgi.internal.module.CompositeResolveHelperRegistry;
import org.eclipse.osgi.internal.module.ResolverImpl;
import org.eclipse.osgi.service.internal.composite.CompositeModule;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.State;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleException;
import org.osgi.framework.ServiceRegistration;
import org.osgi.framework.SynchronousBundleListener;
import org.osgi.framework.launch.Framework;
import org.osgi.service.framework.CompositeBundle;
import org.osgi.service.framework.CompositeBundleFactory;

public class CompositeConfigurator
  implements SynchronousBundleListener, HookConfigurator, AdaptorHook, ClassLoadingHook, CompositeBundleFactory, CompositeResolveHelperRegistry
{
  private BaseAdaptor adaptor;
  private ServiceRegistration factoryService;
  private BundleContext systemContext;
  private final Collection helpers = new ArrayList(0);
  
  public void addHooks(HookRegistry hookRegistry)
  {
    hookRegistry.addAdaptorHook(this);
    
    hookRegistry.addClassLoadingHook(this);
  }
  
  public void addProperties(Properties properties) {}
  
  public FrameworkLog createFrameworkLog()
  {
    return null;
  }
  
  public void frameworkStart(BundleContext context)
    throws BundleException
  {
    systemContext = context;
    context.addBundleListener(this);
    addHelpers(context.getBundles());
    
    ((ResolverImpl)adaptor.getState().getResolver()).setCompositeResolveHelperRegistry(this);
    
    factoryService = context.registerService(new String[] { CompositeBundleFactory.class.getName() }, this, null);
  }
  
  public void frameworkStop(BundleContext context)
  {
    if (factoryService != null) {
      factoryService.unregister();
    }
    factoryService = null;
    
    stopFrameworks();
    context.removeBundleListener(this);
    removeAllHelpers();
  }
  
  public void frameworkStopping(BundleContext context) {}
  
  public void handleRuntimeError(Throwable error) {}
  
  public void initialize(BaseAdaptor initAdaptor)
  {
    adaptor = initAdaptor;
  }
  
  public URLConnection mapLocationToURLConnection(String location)
  {
    return null;
  }
  
  public boolean matchDNChain(String pattern, String[] dnChain)
  {
    return false;
  }
  
  public CompositeBundle installCompositeBundle(Map frameworkConfig, String location, Map compositeManifest)
    throws BundleException
  {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
      sm.checkPermission(new AllPermission());
    }
    compositeManifest = new HashMap(compositeManifest);
    
    CompositeHelper.validateCompositeManifest(compositeManifest);
    try
    {
      InputStream content = CompositeHelper.getCompositeInput(frameworkConfig, compositeManifest);
      CompositeBundle result = (CompositeBundle)systemContext.installBundle(location, content);
      
      CompositeHelper.setCompositePermissions(location, systemContext);
      return result;
    }
    catch (IOException e)
    {
      throw new BundleException("Error creating composite bundle", e);
    }
  }
  
  private void stopFrameworks()
  {
    Bundle[] allBundles = systemContext.getBundles();
    for (int i = 0; i < allBundles.length; i++) {
      if ((allBundles[i] instanceof CompositeBundle))
      {
        CompositeBundle composite = (CompositeBundle)allBundles[i];
        try
        {
          Framework child = composite.getCompositeFramework();
          child.stop();
          
          child.waitForStop(30000L);
        }
        catch (Throwable t)
        {
          t.printStackTrace();
        }
      }
    }
  }
  
  public CompositeResolveHelper getCompositeResolveHelper(BundleDescription bundle)
  {
    synchronized (helpers)
    {
      if (helpers.size() == 0) {
        return null;
      }
      for (Iterator iHelpers = helpers.iterator(); iHelpers.hasNext();)
      {
        CompositeBase composite = (CompositeBase)iHelpers.next();
        if (composite.getBundleId() == bundle.getBundleId()) {
          return composite;
        }
      }
      return null;
    }
  }
  
  public boolean addClassPathEntry(ArrayList cpEntries, String cp, ClasspathManager hostmanager, BaseData sourcedata, ProtectionDomain sourcedomain)
  {
    return false;
  }
  
  public BaseClassLoader createClassLoader(ClassLoader parent, ClassLoaderDelegate delegate, BundleProtectionDomain domain, BaseData data, String[] bundleclasspath)
  {
    if ((data.getType() & 0x60) == 0) {
      return null;
    }
    CompositeModule compositeModule = (CompositeModule)((CompositeBase)data.getBundle()).getCompanionBundle();
    if (compositeModule == null) {
      throw new IllegalStateException("Could not find companion bundle for " + data.getBundle());
    }
    ClassLoaderDelegate companionDelegate = compositeModule.getDelegate();
    if (companionDelegate == null) {
      throw new IllegalStateException("Could not find the companion bundle delegate for" + compositeModule);
    }
    return new CompositeClassLoader(parent, delegate, companionDelegate, data);
  }
  
  public String findLibrary(BaseData data, String libName)
  {
    return null;
  }
  
  public ClassLoader getBundleClassLoaderParent()
  {
    return null;
  }
  
  public void initializedClassLoader(BaseClassLoader baseClassLoader, BaseData data) {}
  
  public byte[] processClass(String name, byte[] classbytes, ClasspathEntry classpathEntry, BundleEntry entry, ClasspathManager manager)
  {
    return null;
  }
  
  private void addHelpers(Bundle[] bundles)
  {
    synchronized (helpers)
    {
      for (int i = 0; i < bundles.length; i++) {
        addHelper(bundles[i]);
      }
    }
  }
  
  private void addHelper(Bundle bundle)
  {
    if (!(bundle instanceof CompositeBase)) {
      return;
    }
    synchronized (helpers)
    {
      if (!helpers.contains(bundle)) {
        helpers.add(bundle);
      }
    }
  }
  
  private void removeHelper(Bundle bundle)
  {
    if (!(bundle instanceof CompositeBase)) {
      return;
    }
    synchronized (helpers)
    {
      helpers.remove(bundle);
    }
  }
  
  private void removeAllHelpers()
  {
    synchronized (helpers)
    {
      helpers.clear();
    }
  }
  
  public void bundleChanged(BundleEvent event)
  {
    switch (event.getType())
    {
    case 1: 
      addHelper(event.getBundle());
      break;
    case 16: 
      removeHelper(event.getBundle());
      break;
    }
  }
}

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

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.jar.Attributes;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
import org.eclipse.osgi.internal.baseadaptor.BaseStorageHook;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.DisabledInfo;
import org.eclipse.osgi.service.resolver.ExportPackageDescription;
import org.eclipse.osgi.service.resolver.State;
import org.osgi.framework.BundleException;
import org.osgi.framework.PackagePermission;
import org.osgi.framework.ServicePermission;
import org.osgi.framework.Version;
import org.osgi.service.permissionadmin.PermissionInfo;

public class CompositeHelper
{
  private static final PermissionInfo[] COMPOSITE_PERMISSIONS = { new PermissionInfo(PackagePermission.class.getName(), "*", "export"), new PermissionInfo(ServicePermission.class.getName(), "*", "register,get") };
  private static final String COMPOSITE_POLICY = "org.eclipse.osgi.composite";
  private static String ELEMENT_SEPARATOR = "; ";
  private static final Object EQUALS_QUOTE = "=\"";
  private static final String[] INVALID_COMPOSITE_HEADERS = { "DynamicImport-Package", "Fragment-Host", "Require-Bundle", "Bundle-NativeCode", "Bundle-ClassPath", "Bundle-Activator", "Bundle-Localization", "Bundle-ActivationPolicy" };
  static Class class$2;
  static Class class$3;
  
  private static Manifest getCompositeManifest(Map compositeManifest)
  {
    Manifest manifest = new Manifest();
    Attributes attributes = manifest.getMainAttributes();
    attributes.putValue("Manifest-Version", "1.0");
    
    String manifestVersion = (String)compositeManifest.remove("Bundle-ManifestVersion");
    
    attributes.putValue("Bundle-ManifestVersion", manifestVersion);
    
    compositeManifest.remove(BaseStorageHook.COMPOSITE_HEADER);
    attributes.putValue(BaseStorageHook.COMPOSITE_HEADER, BaseStorageHook.COMPOSITE_BUNDLE);
    for (Iterator entries = compositeManifest.entrySet().iterator(); entries.hasNext();)
    {
      Map.Entry entry = (Map.Entry)entries.next();
      if (((entry.getKey() instanceof String)) && ((entry.getValue() instanceof String))) {
        attributes.putValue((String)entry.getKey(), (String)entry.getValue());
      }
    }
    return manifest;
  }
  
  private static Manifest getSurrogateManifest(Dictionary compositeManifest, BundleDescription compositeDesc, ExportPackageDescription[] matchingExports)
  {
    Manifest manifest = new Manifest();
    Attributes attributes = manifest.getMainAttributes();
    attributes.putValue("Manifest-Version", "1.0");
    
    attributes.putValue("Bundle-ManifestVersion", "2");
    
    attributes.putValue(BaseStorageHook.COMPOSITE_HEADER, BaseStorageHook.SURROGATE_BUNDLE);
    if ((compositeDesc != null) && (matchingExports != null))
    {
      addImports(attributes, compositeDesc, matchingExports);
      
      addExports(attributes, compositeDesc, matchingExports);
    }
    for (Enumeration keys = compositeManifest.keys(); keys.hasMoreElements();)
    {
      Object header = keys.nextElement();
      if ((!"Bundle-ManifestVersion".equals(header)) && (!BaseStorageHook.COMPOSITE_HEADER.equals(header)) && (!"Import-Package".equals(header)) && (!"Export-Package".equals(header))) {
        if (((header instanceof String)) && ((compositeManifest.get(header) instanceof String))) {
          attributes.putValue((String)header, (String)compositeManifest.get(header));
        }
      }
    }
    return manifest;
  }
  
  /* Error */
  static InputStream getCompositeInput(Map frameworkConfig, Map compositeManifest)
    throws IOException
  {
    // Byte code:
    //   0: new 254	java/io/ByteArrayOutputStream
    //   3: dup
    //   4: invokespecial 471	java/io/ByteArrayOutputStream:<init>	()V
    //   7: astore_2
    //   8: aload_1
    //   9: invokestatic 510	org/eclipse/osgi/internal/composite/CompositeHelper:getCompositeManifest	(Ljava/util/Map;)Ljava/util/jar/Manifest;
    //   12: astore_3
    //   13: new 279	java/util/jar/JarOutputStream
    //   16: dup
    //   17: aload_2
    //   18: aload_3
    //   19: invokespecial 503	java/util/jar/JarOutputStream:<init>	(Ljava/io/OutputStream;Ljava/util/jar/Manifest;)V
    //   22: astore 4
    //   24: new 275	java/util/Properties
    //   27: dup
    //   28: invokespecial 494	java/util/Properties:<init>	()V
    //   31: astore 5
    //   33: aload_0
    //   34: ifnull +9 -> 43
    //   37: aload 5
    //   39: aload_0
    //   40: invokevirtual 495	java/util/Properties:putAll	(Ljava/util/Map;)V
    //   43: new 278	java/util/jar/JarEntry
    //   46: dup
    //   47: getstatic 469	org/eclipse/osgi/internal/composite/CompositeImpl:COMPOSITE_CONFIGURATION	Ljava/lang/String;
    //   50: invokespecial 498	java/util/jar/JarEntry:<init>	(Ljava/lang/String;)V
    //   53: astore 6
    //   55: aload 4
    //   57: aload 6
    //   59: invokevirtual 502	java/util/jar/JarOutputStream:putNextEntry	(Ljava/util/zip/ZipEntry;)V
    //   62: aload 5
    //   64: aload 4
    //   66: aconst_null
    //   67: invokevirtual 496	java/util/Properties:store	(Ljava/io/OutputStream;Ljava/lang/String;)V
    //   70: aload 4
    //   72: invokevirtual 500	java/util/jar/JarOutputStream:closeEntry	()V
    //   75: aload 4
    //   77: invokevirtual 501	java/util/jar/JarOutputStream:flush	()V
    //   80: goto +17 -> 97
    //   83: astore 7
    //   85: aload 4
    //   87: invokevirtual 499	java/util/jar/JarOutputStream:close	()V
    //   90: goto +4 -> 94
    //   93: pop
    //   94: aload 7
    //   96: athrow
    //   97: aload 4
    //   99: invokevirtual 499	java/util/jar/JarOutputStream:close	()V
    //   102: goto +4 -> 106
    //   105: pop
    //   106: new 253	java/io/ByteArrayInputStream
    //   109: dup
    //   110: aload_2
    //   111: invokevirtual 472	java/io/ByteArrayOutputStream:toByteArray	()[B
    //   114: invokespecial 470	java/io/ByteArrayInputStream:<init>	([B)V
    //   117: areturn
    // Line number table:
    //   Java source line #81	-> byte code offset #0
    //   Java source line #84	-> byte code offset #8
    //   Java source line #85	-> byte code offset #13
    //   Java source line #88	-> byte code offset #24
    //   Java source line #89	-> byte code offset #33
    //   Java source line #90	-> byte code offset #37
    //   Java source line #91	-> byte code offset #43
    //   Java source line #92	-> byte code offset #55
    //   Java source line #93	-> byte code offset #62
    //   Java source line #94	-> byte code offset #70
    //   Java source line #95	-> byte code offset #75
    //   Java source line #96	-> byte code offset #80
    //   Java source line #98	-> byte code offset #85
    //   Java source line #99	-> byte code offset #90
    //   Java source line #102	-> byte code offset #94
    //   Java source line #98	-> byte code offset #97
    //   Java source line #99	-> byte code offset #102
    //   Java source line #103	-> byte code offset #106
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	118	0	frameworkConfig	Map
    //   0	118	1	compositeManifest	Map
    //   7	104	2	bytesOut	ByteArrayOutputStream
    //   12	7	3	manifest	Manifest
    //   22	76	4	jarOut	JarOutputStream
    //   31	32	5	fwProps	java.util.Properties
    //   53	5	6	entry	java.util.jar.JarEntry
    //   83	12	7	localObject	Object
    //   93	1	8	localIOException1	IOException
    //   105	1	9	localIOException2	IOException
    // Exception table:
    //   from	to	target	type
    //   24	83	83	finally
    //   85	90	93	java/io/IOException
    //   97	102	105	java/io/IOException
  }
  
  static InputStream getSurrogateInput(Dictionary compositeManifest, BundleDescription compositeDesc, ExportPackageDescription[] matchingExports)
    throws IOException
  {
    ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
    Manifest manifest = getSurrogateManifest(compositeManifest, compositeDesc, matchingExports);
    JarOutputStream jarOut = new JarOutputStream(bytesOut, manifest);
    jarOut.flush();
    jarOut.close();
    return new ByteArrayInputStream(bytesOut.toByteArray());
  }
  
  private static void addImports(Attributes attrigutes, BundleDescription compositeDesc, ExportPackageDescription[] matchingExports)
  {
    ExportPackageDescription[] exports = compositeDesc.getExportPackages();
    List systemExports = getSystemExports(matchingExports);
    if ((exports.length == 0) && (systemExports.size() == 0)) {
      return;
    }
    StringBuffer importStatement = new StringBuffer();
    Collection importedNames = new ArrayList(exports.length);
    for (int i = 0; i < exports.length; i++)
    {
      if (i != 0) {
        importStatement.append(',');
      }
      importedNames.add(exports[i].getName());
      getImportFrom(exports[i], importStatement);
    }
    for (Iterator iSystemExports = systemExports.iterator(); iSystemExports.hasNext();)
    {
      ExportPackageDescription systemExport = (ExportPackageDescription)iSystemExports.next();
      if (!importedNames.contains(systemExport.getName()))
      {
        if (i != 0) {
          importStatement.append(',');
        }
        i++;
        importStatement.append(systemExport.getName()).append(ELEMENT_SEPARATOR).append("bundle-symbolic-name").append('=').append("system.bundle");
      }
    }
    attrigutes.putValue("Import-Package", importStatement.toString());
  }
  
  private static List getSystemExports(ExportPackageDescription[] matchingExports)
  {
    ArrayList list = null;
    for (int i = 0; i < matchingExports.length; i++) {
      if (matchingExports[i].getExporter().getBundleId() == 0L)
      {
        if (list == null) {
          list = new ArrayList();
        }
        list.add(matchingExports[i]);
      }
    }
    return list == null ? Collections.EMPTY_LIST : list;
  }
  
  private static void getImportFrom(ExportPackageDescription export, StringBuffer importStatement)
  {
    importStatement.append(export.getName()).append(ELEMENT_SEPARATOR);
    Version version = export.getVersion();
    importStatement.append("version").append(EQUALS_QUOTE).append('[').append(version).append(',').append(new Version(version.getMajor(), version.getMinor(), version.getMicro() + 1)).append(')').append('"');
    addMap(importStatement, export.getAttributes(), "=");
  }
  
  private static void addExports(Attributes attributes, BundleDescription compositeDesc, ExportPackageDescription[] matchingExports)
  {
    if (matchingExports.length == 0) {
      return;
    }
    StringBuffer exportStatement = new StringBuffer();
    for (int i = 0; i < matchingExports.length; i++) {
      if (matchingExports[i].getExporter() != compositeDesc)
      {
        if (exportStatement.length() > 0) {
          exportStatement.append(',');
        }
        getExportFrom(matchingExports[i], exportStatement);
      }
    }
    if (exportStatement.length() > 0) {
      attributes.putValue("Export-Package", exportStatement.toString());
    }
  }
  
  private static void getExportFrom(ExportPackageDescription export, StringBuffer exportStatement)
  {
    exportStatement.append(export.getName()).append(ELEMENT_SEPARATOR);
    exportStatement.append("version").append(EQUALS_QUOTE).append(export.getVersion()).append('"');
    addMap(exportStatement, export.getDirectives(), ":=");
    addMap(exportStatement, export.getAttributes(), "=");
  }
  
  private static void addMap(StringBuffer manifest, Map values, String assignment)
  {
    if (values == null) {
      return;
    }
    for (Iterator iEntries = values.entrySet().iterator(); iEntries.hasNext();)
    {
      manifest.append(ELEMENT_SEPARATOR);
      Map.Entry entry = (Map.Entry)iEntries.next();
      manifest.append(entry.getKey()).append(assignment).append('"');
      Object value = entry.getValue();
      if ((value instanceof String[]))
      {
        String[] strings = (String[])value;
        for (int i = 0; i < strings.length; i++)
        {
          if (i != 0) {
            manifest.append(',');
          }
          manifest.append(strings[i]);
        }
      }
      else
      {
        manifest.append(value);
      }
      manifest.append('"');
    }
  }
  
  /* Error */
  static void setCompositePermissions(String bundleLocation, org.osgi.framework.BundleContext systemContext)
  {
    // Byte code:
    //   0: aload_1
    //   1: getstatic 463	org/eclipse/osgi/internal/composite/CompositeHelper:class$2	Ljava/lang/Class;
    //   4: dup
    //   5: ifnonnull +29 -> 34
    //   8: pop
    //   9: ldc_w 249
    //   12: invokestatic 474	java/lang/Class:forName	(Ljava/lang/String;)Ljava/lang/Class;
    //   15: dup
    //   16: putstatic 463	org/eclipse/osgi/internal/composite/CompositeHelper:class$2	Ljava/lang/Class;
    //   19: goto +15 -> 34
    //   22: new 259	java/lang/NoClassDefFoundError
    //   25: dup_x1
    //   26: swap
    //   27: invokevirtual 488	java/lang/Throwable:getMessage	()Ljava/lang/String;
    //   30: invokespecial 477	java/lang/NoClassDefFoundError:<init>	(Ljava/lang/String;)V
    //   33: athrow
    //   34: invokevirtual 473	java/lang/Class:getName	()Ljava/lang/String;
    //   37: invokeinterface 554 2 0
    //   42: astore_2
    //   43: aload_2
    //   44: ifnonnull +7 -> 51
    //   47: aconst_null
    //   48: goto +10 -> 58
    //   51: aload_1
    //   52: aload_2
    //   53: invokeinterface 553 2 0
    //   58: checkcast 293	org/osgi/service/permissionadmin/PermissionAdmin
    //   61: astore_3
    //   62: aload_3
    //   63: ifnonnull +14 -> 77
    //   66: new 262	java/lang/RuntimeException
    //   69: dup
    //   70: ldc_w 242
    //   73: invokespecial 479	java/lang/RuntimeException:<init>	(Ljava/lang/String;)V
    //   76: athrow
    //   77: aload_3
    //   78: aload_0
    //   79: getstatic 468	org/eclipse/osgi/internal/composite/CompositeHelper:COMPOSITE_PERMISSIONS	[Lorg/osgi/service/permissionadmin/PermissionInfo;
    //   82: invokeinterface 555 3 0
    //   87: goto +16 -> 103
    //   90: astore 4
    //   92: aload_1
    //   93: aload_2
    //   94: invokeinterface 552 2 0
    //   99: pop
    //   100: aload 4
    //   102: athrow
    //   103: aload_1
    //   104: aload_2
    //   105: invokeinterface 552 2 0
    //   110: pop
    //   111: return
    // Line number table:
    //   Java source line #209	-> byte code offset #0
    //   Java source line #210	-> byte code offset #43
    //   Java source line #211	-> byte code offset #62
    //   Java source line #212	-> byte code offset #66
    //   Java source line #214	-> byte code offset #77
    //   Java source line #215	-> byte code offset #87
    //   Java source line #216	-> byte code offset #92
    //   Java source line #217	-> byte code offset #100
    //   Java source line #216	-> byte code offset #103
    //   Java source line #218	-> byte code offset #111
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	112	0	bundleLocation	String
    //   0	112	1	systemContext	org.osgi.framework.BundleContext
    //   42	63	2	ref	org.osgi.framework.ServiceReference
    //   61	17	3	permAdmin	org.osgi.service.permissionadmin.PermissionAdmin
    //   90	11	4	localObject	Object
    //   22	1	5	localClassNotFoundException	ClassNotFoundException
    // Exception table:
    //   from	to	target	type
    //   9	15	22	java/lang/ClassNotFoundException
    //   77	90	90	finally
  }
  
  /* Error */
  static void setDisabled(boolean disable, org.osgi.framework.Bundle bundle, org.osgi.framework.BundleContext systemContext)
  {
    // Byte code:
    //   0: aload_2
    //   1: getstatic 464	org/eclipse/osgi/internal/composite/CompositeHelper:class$3	Ljava/lang/Class;
    //   4: dup
    //   5: ifnonnull +29 -> 34
    //   8: pop
    //   9: ldc_w 248
    //   12: invokestatic 474	java/lang/Class:forName	(Ljava/lang/String;)Ljava/lang/Class;
    //   15: dup
    //   16: putstatic 464	org/eclipse/osgi/internal/composite/CompositeHelper:class$3	Ljava/lang/Class;
    //   19: goto +15 -> 34
    //   22: new 259	java/lang/NoClassDefFoundError
    //   25: dup_x1
    //   26: swap
    //   27: invokevirtual 488	java/lang/Throwable:getMessage	()Ljava/lang/String;
    //   30: invokespecial 477	java/lang/NoClassDefFoundError:<init>	(Ljava/lang/String;)V
    //   33: athrow
    //   34: invokevirtual 473	java/lang/Class:getName	()Ljava/lang/String;
    //   37: invokeinterface 554 2 0
    //   42: astore_3
    //   43: aload_3
    //   44: ifnonnull +7 -> 51
    //   47: aconst_null
    //   48: goto +10 -> 58
    //   51: aload_2
    //   52: aload_3
    //   53: invokeinterface 553 2 0
    //   58: checkcast 287	org/eclipse/osgi/service/resolver/PlatformAdmin
    //   61: astore 4
    //   63: aload 4
    //   65: ifnonnull +14 -> 79
    //   68: new 262	java/lang/RuntimeException
    //   71: dup
    //   72: ldc_w 243
    //   75: invokespecial 479	java/lang/RuntimeException:<init>	(Ljava/lang/String;)V
    //   78: athrow
    //   79: aload 4
    //   81: iconst_0
    //   82: invokeinterface 546 2 0
    //   87: astore 5
    //   89: aload 5
    //   91: aload_1
    //   92: invokeinterface 551 1 0
    //   97: invokeinterface 547 3 0
    //   102: astore 6
    //   104: iload_0
    //   105: aload 6
    //   107: invokestatic 506	org/eclipse/osgi/internal/composite/CompositeHelper:setDisabled	(ZLorg/eclipse/osgi/service/resolver/BundleDescription;)V
    //   110: goto +16 -> 126
    //   113: astore 7
    //   115: aload_2
    //   116: aload_3
    //   117: invokeinterface 552 2 0
    //   122: pop
    //   123: aload 7
    //   125: athrow
    //   126: aload_2
    //   127: aload_3
    //   128: invokeinterface 552 2 0
    //   133: pop
    //   134: return
    // Line number table:
    //   Java source line #221	-> byte code offset #0
    //   Java source line #222	-> byte code offset #43
    //   Java source line #223	-> byte code offset #63
    //   Java source line #224	-> byte code offset #68
    //   Java source line #226	-> byte code offset #79
    //   Java source line #227	-> byte code offset #89
    //   Java source line #228	-> byte code offset #104
    //   Java source line #229	-> byte code offset #110
    //   Java source line #230	-> byte code offset #115
    //   Java source line #231	-> byte code offset #123
    //   Java source line #230	-> byte code offset #126
    //   Java source line #232	-> byte code offset #134
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	135	0	disable	boolean
    //   0	135	1	bundle	org.osgi.framework.Bundle
    //   0	135	2	systemContext	org.osgi.framework.BundleContext
    //   42	86	3	ref	org.osgi.framework.ServiceReference
    //   61	19	4	pa	org.eclipse.osgi.service.resolver.PlatformAdmin
    //   87	3	5	state	State
    //   102	4	6	desc	BundleDescription
    //   113	11	7	localObject	Object
    //   22	1	8	localClassNotFoundException	ClassNotFoundException
    // Exception table:
    //   from	to	target	type
    //   9	15	22	java/lang/ClassNotFoundException
    //   79	113	113	finally
  }
  
  static void setDisabled(boolean disable, BundleDescription bundle)
  {
    State state = bundle.getContainingState();
    if (disable)
    {
      state.addDisabledInfo(new DisabledInfo("org.eclipse.osgi.composite", "Composite companion bundle is not resolved.", bundle));
    }
    else
    {
      DisabledInfo toRemove = state.getDisabledInfo(bundle, "org.eclipse.osgi.composite");
      if (toRemove != null) {
        state.removeDisabledInfo(toRemove);
      }
    }
  }
  
  static void validateCompositeManifest(Map compositeManifest)
    throws BundleException
  {
    if (compositeManifest == null) {
      throw new BundleException("The composite manifest cannot be null.", 3);
    }
    if (compositeManifest.get("Bundle-SymbolicName") == null) {
      throw new BundleException("The composite manifest must contain a Bundle-SymbolicName header.", 3);
    }
    for (int i = 0; i < INVALID_COMPOSITE_HEADERS.length; i++) {
      if (compositeManifest.get(INVALID_COMPOSITE_HEADERS[i]) != null) {
        throw new BundleException("The composite manifest must not contain the header " + INVALID_COMPOSITE_HEADERS[i], 3);
      }
    }
    String manifestVersion = (String)compositeManifest.get("Bundle-ManifestVersion");
    if (manifestVersion == null) {
      compositeManifest.put("Bundle-ManifestVersion", "2");
    } else {
      try
      {
        Integer parsed = Integer.valueOf(manifestVersion);
        if ((parsed.intValue() > 2) || (parsed.intValue() < 2)) {
          throw new BundleException("Invalid Bundle-ManifestVersion: " + manifestVersion);
        }
      }
      catch (NumberFormatException localNumberFormatException)
      {
        throw new BundleException("Invalid Bundle-ManifestVersion: " + manifestVersion);
      }
    }
  }
}

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

import java.util.Dictionary;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.service.framework.SurrogateBundle;

class CompositeImpl$ServiceTrackerManager
{
  static final int COMPOSITE_ACTIVE = 1;
  static final int SURROGATE_ACTIVE = 2;
  private int bundlesActive = 0;
  private CompositeServiceTracker shareToChildServices;
  private CompositeServiceTracker shareToParentServices;
  final CompositeImpl this$0;
  
  CompositeImpl$ServiceTrackerManager(CompositeImpl paramCompositeImpl) {}
  
  void startedComposite()
    throws BundleException
  {
    open(1);
    this$0.getSurrogateBundle().start(1);
  }
  
  void startedSurrogate()
  {
    open(2);
  }
  
  void stoppedComposite()
  {
    try
    {
      this$0.getSurrogateBundle().stop(1);
    }
    catch (BundleException localBundleException) {}catch (IllegalStateException localIllegalStateException) {}
    close(1);
  }
  
  void stoppedSurrogate()
  {
    close(2);
  }
  
  private synchronized void open(int bundleActive)
  {
    bundlesActive |= bundleActive;
    if ((bun
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-2019. Infinite Loop Ltd