org.eclipse.osgi_3.7.2.v20120110-1415

tService(reference);
      }
    }, controlContext);
  }
  
  public Class<?> forName(final String name)
    throws ClassNotFoundException
  {
    if (System.getSecurityManager() == null) {
      return Class.forName(name);
    }
    try
    {
      (Class)AccessController.doPrivileged(new PrivilegedExceptionAction()
      {
        public Class<?> run()
          throws Exception
        {
          return Class.forName(name);
        }
      }, controlContext);
    }
    catch (PrivilegedActionException e)
    {
      if ((e.getException() instanceof ClassNotFoundException)) {
        throw ((ClassNotFoundException)e.getException());
      }
      throw ((RuntimeException)e.getException());
    }
  }
  
  public Class<?> loadSystemClass(final String name)
    throws ClassNotFoundException
  {
    if (System.getSecurityManager() == null)
    {
      ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
      return systemClassLoader != null ? systemClassLoader.loadClass(name) : bootClassLoader.loadClass(name);
    }
    try
    {
      (Class)AccessController.doPrivileged(new PrivilegedExceptionAction()
      {
        public Class<?> run()
          throws Exception
        {
          ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
          return systemClassLoader != null ? systemClassLoader.loadClass(name) : SecureAction.bootClassLoader.loadClass(name);
        }
      }, controlContext);
    }
    catch (PrivilegedActionException e)
    {
      if ((e.getException() instanceof ClassNotFoundException)) {
        throw ((ClassNotFoundException)e.getException());
      }
      throw ((RuntimeException)e.getException());
    }
  }
  
  public void open(final ServiceTracker<?, ?> tracker)
  {
    if (System.getSecurityManager() == null)
    {
      tracker.open();
      return;
    }
    AccessController.doPrivileged(new PrivilegedAction()
    {
      public Object run()
      {
        tracker.open();
        return null;
      }
    }, controlContext);
  }
  
  public void start(final Bundle bundle, final int options)
    throws BundleException
  {
    if (System.getSecurityManager() == null)
    {
      bundle.start(options);
      return;
    }
    try
    {
      AccessController.doPrivileged(new PrivilegedExceptionAction()
      {
        public Object run()
          throws BundleException
        {
          bundle.start(options);
          return null;
        }
      }, controlContext);
      return;
    }
    catch (PrivilegedActionException e)
    {
      if ((e.getException() instanceof BundleException)) {
        throw ((BundleException)e.getException());
      }
      throw ((RuntimeException)e.getException());
    }
  }
  
  public void start(Bundle bundle)
    throws BundleException
  {
    start(bundle, 0);
  }
}

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

import org.eclipse.osgi.util.NLS;

public class AdaptorMsg
  extends NLS
{
  public static String ADAPTER_FILEEXIST_EXCEPTION;
  public static String ADAPTOR_DIRECTORY_CREATE_EXCEPTION;
  public static String ADAPTOR_DIRECTORY_EXCEPTION;
  public static String ADAPTOR_EXTENSION_IMPORT_ERROR;
  public static String ADAPTOR_EXTENSION_NATIVECODE_ERROR;
  public static String ADAPTOR_EXTENSION_REQUIRE_ERROR;
  public static String ADAPTOR_STORAGE_EXCEPTION;
  public static String ADAPTOR_STORAGE_INIT_FAILED_MSG;
  public static String ADAPTOR_STORAGE_INIT_FAILED_TITLE;
  public static String ADAPTOR_URL_CREATE_EXCEPTION;
  public static String BUNDLE_CLASSPATH_ENTRY_NOT_FOUND_EXCEPTION;
  public static String BUNDLE_NATIVECODE_EXCEPTION;
  public static String BUNDLE_READ_EXCEPTION;
  public static String MANIFEST_NOT_FOUND_EXCEPTION;
  public static String RESOURCE_NOT_FOUND_EXCEPTION;
  public static String SYSTEMBUNDLE_MISSING_MANIFEST;
  public static String SYSTEMBUNDLE_NOTRESOLVED;
  public static String URL_INVALID_BUNDLE_ID;
  public static String URL_NO_BUNDLE_FOUND;
  public static String URL_NO_BUNDLE_ID;
  private static final String BUNDLE_NAME = "org.eclipse.osgi.internal.baseadaptor.ExternalMessages";
  
  static
  {
    NLS.initializeMessages("org.eclipse.osgi.internal.baseadaptor.ExternalMessages", AdaptorMsg.class);
  }
}

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

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Dictionary;
import java.util.Hashtable;
import org.eclipse.core.runtime.internal.adaptor.EclipseAdaptorMsg;
import org.eclipse.osgi.baseadaptor.BaseData;
import org.eclipse.osgi.framework.debug.Debug;
import org.eclipse.osgi.framework.util.Headers;
import org.eclipse.osgi.framework.util.ObjectPool;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.ServiceRegistration;
import org.osgi.framework.Version;

public class AdaptorUtil
{
  public static final byte NULL = 0;
  public static final byte OBJECT = 1;
  
  public static void copyDir(File inDir, File outDir)
    throws IOException
  {
    String[] files = inDir.list();
    if ((files != null) && (files.length > 0))
    {
      outDir.mkdir();
      for (int i = 0; i < files.length; i++)
      {
        File inFile = new File(inDir, files[i]);
        File outFile = new File(outDir, files[i]);
        if (inFile.isDirectory())
        {
          copyDir(inFile, outFile);
        }
        else
        {
          InputStream in = new FileInputStream(inFile);
          readFile(in, outFile);
        }
      }
    }
  }
  
  /* Error */
  public static void readFile(InputStream in, File file)
    throws IOException
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_2
    //   2: new 180	java/io/FileOutputStream
    //   5: dup
    //   6: aload_1
    //   7: invokespecial 346	java/io/FileOutputStream:<init>	(Ljava/io/File;)V
    //   10: astore_2
    //   11: sipush 1024
    //   14: newarray <illegal type>
    //   16: astore_3
    //   17: goto +11 -> 28
    //   20: aload_2
    //   21: aload_3
    //   22: iconst_0
    //   23: iload 4
    //   25: invokevirtual 345	java/io/FileOutputStream:write	([BII)V
    //   28: aload_0
    //   29: aload_3
    //   30: iconst_0
    //   31: aload_3
    //   32: arraylength
    //   33: invokevirtual 348	java/io/InputStream:read	([BII)I
    //   36: dup
    //   37: istore 4
    //   39: ifgt -19 -> 20
    //   42: goto +50 -> 92
    //   45: astore_3
    //   46: getstatic 327	org/eclipse/osgi/framework/debug/Debug:DEBUG_GENERAL	Z
    //   49: ifeq +12 -> 61
    //   52: ldc 5
    //   54: invokestatic 371	org/eclipse/osgi/framework/debug/Debug:println	(Ljava/lang/String;)V
    //   57: aload_3
    //   58: invokestatic 372	org/eclipse/osgi/framework/debug/Debug:printStackTrace	(Ljava/lang/Throwable;)V
    //   61: aload_3
    //   62: athrow
    //   63: astore 5
    //   65: aload_0
    //   66: ifnull +11 -> 77
    //   69: aload_0
    //   70: invokevirtual 347	java/io/InputStream:close	()V
    //   73: goto +4 -> 77
    //   76: pop
    //   77: aload_2
    //   78: ifnull +11 -> 89
    //   81: aload_2
    //   82: invokevirtual 344	java/io/FileOutputStream:close	()V
    //   85: goto +4 -> 89
    //   88: pop
    //   89: aload 5
    //   91: athrow
    //   92: aload_0
    //   93: ifnull +11 -> 104
    //   96: aload_0
    //   97: invokevirtual 347	java/io/InputStream:close	()V
    //   100: goto +4 -> 104
    //   103: pop
    //   104: aload_2
    //   105: ifnull +11 -> 116
    //   108: aload_2
    //   109: invokevirtual 344	java/io/FileOutputStream:close	()V
    //   112: goto +4 -> 116
    //   115: pop
    //   116: return
    // Line number table:
    //   Java source line #70	-> byte code offset #0
    //   Java source line #72	-> byte code offset #2
    //   Java source line #74	-> byte code offset #11
    //   Java source line #76	-> byte code offset #17
    //   Java source line #77	-> byte code offset #20
    //   Java source line #76	-> byte code offset #28
    //   Java source line #79	-> byte code offset #45
    //   Java source line #80	-> byte code offset #46
    //   Java source line #81	-> byte code offset #52
    //   Java source line #82	-> byte code offset #57
    //   Java source line #85	-> byte code offset #61
    //   Java source line #86	-> byte code offset #63
    //   Java source line #87	-> byte code offset #65
    //   Java source line #89	-> byte code offset #69
    //   Java source line #90	-> byte code offset #76
    //   Java source line #95	-> byte code offset #77
    //   Java source line #97	-> byte code offset #81
    //   Java source line #98	-> byte code offset #88
    //   Java source line #102	-> byte code offset #89
    //   Java source line #87	-> byte code offset #92
    //   Java source line #89	-> byte code offset #96
    //   Java source line #90	-> byte code offset #103
    //   Java source line #95	-> byte code offset #104
    //   Java source line #97	-> byte code offset #108
    //   Java source line #98	-> byte code offset #115
    //   Java source line #103	-> byte code offset #116
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	117	0	in	InputStream
    //   0	117	1	file	File
    //   1	108	2	fos	java.io.FileOutputStream
    //   16	16	3	buffer	byte[]
    //   45	17	3	e	IOException
    //   20	4	4	count	int
    //   37	3	4	count	int
    //   63	27	5	localObject	Object
    //   76	1	8	localIOException1	IOException
    //   88	1	9	localIOException2	IOException
    //   103	1	10	localIOException3	IOException
    //   115	1	11	localIOException4	IOException
    // Exception table:
    //   from	to	target	type
    //   2	42	45	java/io/IOException
    //   2	63	63	finally
    //   69	73	76	java/io/IOException
    //   81	85	88	java/io/IOException
    //   96	100	103	java/io/IOException
    //   108	112	115	java/io/IOException
  }
  
  public static boolean rm(File file)
  {
    if (file.exists())
    {
      if (file.isDirectory())
      {
        String[] list = file.list();
        if (list != null)
        {
          int len = list.length;
          for (int i = 0; i < len; i++) {
            rm(new File(file, list[i]));
          }
        }
      }
      if (Debug.DEBUG_GENERAL) {
        if (file.isDirectory()) {
          Debug.println("rmdir " + file.getPath());
        } else {
          Debug.println("rm " + file.getPath());
        }
      }
      boolean success = file.delete();
      if ((Debug.DEBUG_GENERAL) && 
        (!success)) {
        Debug.println("  rm failed!!");
      }
      return success;
    }
    return true;
  }
  
  public static String readString(DataInputStream in, boolean intern)
    throws IOException
  {
    byte type = in.readByte();
    if (type == 0) {
      return null;
    }
    return intern ? in.readUTF().intern() : in.readUTF();
  }
  
  public static void writeStringOrNull(DataOutputStream out, String string)
    throws IOException
  {
    if (string == null)
    {
      out.writeByte(0);
    }
    else
    {
      out.writeByte(1);
      out.writeUTF(string);
    }
  }
  
  public static Version loadVersion(DataInputStream in)
    throws IOException
  {
    String versionString = readString(in, false);
    try
    {
      return (Version)ObjectPool.intern(Version.parseVersion(versionString));
    }
    catch (IllegalArgumentException localIllegalArgumentException) {}
    return new InvalidVersion(versionString);
  }
  
  public static ServiceRegistration<?> register(String name, Object service, BundleContext context)
  {
    Dictionary<String, Object> properties = new Hashtable(7);
    Dictionary<String, String> headers = context.getBundle().getHeaders();
    properties.put("service.vendor", headers.get("Bundle-Vendor"));
    properties.put("service.ranking", new Integer(Integer.MAX_VALUE));
    properties.put("service.pid", context.getBundle().getBundleId() + "." + service.getClass().getName());
    return context.registerService(name, service, properties);
  }
  
  public static Dictionary<String, String> loadManifestFrom(BaseData bundledata)
    throws BundleException
  {
    URL url = bundledata.getEntry("META-INF/MANIFEST.MF");
    if (url == null) {
      return null;
    }
    try
    {
      return Headers.parseManifest(url.openStream());
    }
    catch (IOException e)
    {
      throw new BundleException(NLS.bind(EclipseAdaptorMsg.ECLIPSE_DATA_ERROR_READING_MANIFEST, bundledata.getLocation()), 3, e);
    }
  }
  
  /* Error */
  public static boolean canWrite(File installDir)
  {
    // Byte code:
    //   0: aload_0
    //   1: invokevirtual 333	java/io/File:canWrite	()Z
    //   4: ifne +5 -> 9
    //   7: iconst_0
    //   8: ireturn
    //   9: aload_0
    //   10: invokevirtual 336	java/io/File:isDirectory	()Z
    //   13: ifne +5 -> 18
    //   16: iconst_0
    //   17: ireturn
    //   18: aconst_null
    //   19: astore_1
    //   20: ldc_w 175
    //   23: ldc_w 170
    //   26: aload_0
    //   27: invokestatic 342	java/io/File:createTempFile	(Ljava/lang/String;Ljava/lang/String;Ljava/io/File;)Ljava/io/File;
    //   30: astore_1
    //   31: goto +27 -> 58
    //   34: pop
    //   35: aload_1
    //   36: ifnull +8 -> 44
    //   39: aload_1
    //   40: invokevirtual 334	java/io/File:delete	()Z
    //   43: pop
    //   44: iconst_0
    //   45: ireturn
    //   46: astore_2
    //   47: aload_1
    //   48: ifnull +8 -> 56
    //   51: aload_1
    //   52: invokevirtual 334	java/io/File:delete	()Z
    //   55: pop
    //   56: aload_2
    //   57: athrow
    //   58: aload_1
    //   59: ifnull +8 -> 67
    //   62: aload_1
    //   63: invokevirtual 334	java/io/File:delete	()Z
    //   66: pop
    //   67: iconst_1
    //   68: ireturn
    // Line number table:
    //   Java source line #198	-> byte code offset #0
    //   Java source line #199	-> byte code offset #7
    //   Java source line #201	-> byte code offset #9
    //   Java source line #202	-> byte code offset #16
    //   Java source line #204	-> byte code offset #18
    //   Java source line #208	-> byte code offset #20
    //   Java source line #209	-> byte code offset #34
    //   Java source line #213	-> byte code offset #35
    //   Java source line #214	-> byte code offset #39
    //   Java source line #211	-> byte code offset #44
    //   Java source line #212	-> byte code offset #46
    //   Java source line #213	-> byte code offset #47
    //   Java source line #214	-> byte code offset #51
    //   Java source line #215	-> byte code offset #56
    //   Java source line #213	-> byte code offset #58
    //   Java source line #214	-> byte code offset #62
    //   Java source line #216	-> byte code offset #67
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	69	0	installDir	File
    //   19	44	1	fileTest	File
    //   46	11	2	localObject	Object
    //   34	1	3	localIOException	IOException
    // Exception table:
    //   from	to	target	type
    //   20	31	34	java/io/IOException
    //   20	35	46	finally
  }
  
  public static URL encodeFileURL(File file)
    throws MalformedURLException
  {
    try
    {
      Method toURI = File.class.getMethod("toURI", null);
      Object uri = toURI.invoke(file, null);
      Method toURL = uri.getClass().getMethod("toURL", null);
      return (URL)toURL.invoke(uri, null);
    }
    catch (NoSuchMethodException localNoSuchMethodException) {}catch (IllegalAccessException localIllegalAccessException) {}catch (InvocationTargetException e)
    {
      if ((e.getTargetException() instanceof MalformedURLException)) {
        throw ((MalformedURLException)e.getTargetException());
      }
    }
    return file.toURL();
  }
  
  /* Error */
  public static byte[] getBytes(InputStream in, int length, int BUF_SIZE)
    throws IOException
  {
    // Byte code:
    //   0: iconst_0
    //   1: istore 4
    //   3: iload_1
    //   4: ifle +47 -> 51
    //   7: iload_1
    //   8: newarray <illegal type>
    //   10: astore_3
    //   11: goto +31 -> 42
    //   14: aload_0
    //   15: aload_3
    //   16: iload 4
    //   18: iload_1
    //   19: iload 4
    //   21: isub
    //   22: invokevirtual 348	java/io/InputStream:read	([BII)I
    //   25: istore 5
    //   27: iload 5
    //   29: ifgt +6 -> 35
    //   32: goto +86 -> 118
    //   35: iload 4
    //   37: iload 5
    //   39: iadd
    //   40: istore 4
    //   42: iload 4
    //   44: iload_1
    //   45: if_icmplt -31 -> 14
    //   48: goto +70 -> 118
    //   51: iload_2
    //   52: istore_1
    //   53: iload_1
    //   54: newarray <illegal type>
    //   56: astore_3
    //   57: goto +31 -> 88
    //   60: aload_0
    //   61: aload_3
    //   62: iload 4
    //   64: iload_1
    //   65: iload 4
    //   67: isub
    //   68: invokevirtual 348	java/io/InputStream:read	([BII)I
    //   71: istore 5
    //   73: iload 5
    //   75: ifgt +6 -> 81
    //   78: goto +40 -> 118
    //   81: iload 4
    //   83: iload 5
    //   85: iadd
    //   86: istore 4
    //   88: iload 4
    //   90: iload_1
    //   91: if_icmplt -31 -> 60
    //   94: aload_3
    //   95: astore 6
    //   97: iload_1
    //   98: iload_2
    //   99: iadd
    //   100: istore_1
    //   101: iload_1
    //   102: newarray <illegal type>
    //   104: astore_3
    //   105: aload 6
    //   107: iconst_0
    //   108: aload_3
    //   109: iconst_0
    //   110: iload 4
    //   112: invokestatic 361	java/lang/System:arraycopy	(Ljava/lang/Object;ILjava/lang/Object;II)V
    //   115: goto -27 -> 88
    //   118: aload_3
    //   119: arraylength
    //   120: iload 4
    //   122: if_icmple +37 -> 159
    //   125: aload_3
    //   126: astore 6
    //   128: iload 4
    //   130: newarray <illegal type>
    //   132: astore_3
    //   133: aload 6
    //   135: iconst_0
    //   136: aload_3
    //   137: iconst_0
    //   138: iload 4
    //   140: invokestatic 361	java/lang/System:arraycopy	(Ljava/lang/Object;ILjava/lang/Object;II)V
    //   143: goto +16 -> 159
    //   146: astore 7
    //   148: aload_0
    //   149: invokevirtual 347	java/io/InputStream:close	()V
    //   152: goto +4 -> 156
    //   155: pop
    //   156: aload 7
    //   158: athrow
    //   159: aload_0
    //   160: invokevirtual 347	java/io/InputStream:close	()V
    //   163: goto +4 -> 167
    //   166: pop
    //   167: aload_3
    //   168: areturn
    // Line number table:
    //   Java source line #241	-> byte code offset #0
    //   Java source line #244	-> byte code offset #3
    //   Java source line #245	-> byte code offset #7
    //   Java source line #246	-> byte code offset #11
    //   Java source line #247	-> byte code offset #14
    //   Java source line #248	-> byte code offset #27
    //   Java source line #249	-> byte code offset #32
    //   Java source line #246	-> byte code offset #35
    //   Java source line #252	-> byte code offset #51
    //   Java source line #253	-> byte code offset #53
    //   Java source line #255	-> byte code offset #57
    //   Java source line #256	-> byte code offset #60
    //   Java source line #257	-> byte code offset #73
    //   Java source line #258	-> byte code offset #78
    //   Java source line #255	-> byte code offset #81
    //   Java source line #260	-> byte code offset #94
    //   Java source line #261	-> byte code offset #97
    //   Java source line #262	-> byte code offset #101
    //   Java source line #263	-> byte code offset #105
    //   Java source line #254	-> byte code offset #115
    //   Java source line #266	-> byte code offset #118
    //   Java source line #267	-> byte code offset #125
    //   Java source line #268	-> byte code offset #128
    //   Java source line #269	-> byte code offset #133
    //   Java source line #271	-> byte code offset #146
    //   Java source line #273	-> byte code offset #148
    //   Java source line #274	-> byte code offset #155
    //   Java source line #277	-> byte code offset #156
    //   Java source line #273	-> byte code offset #159
    //   Java source line #274	-> byte code offset #166
    //   Java source line #278	-> byte code offset #167
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	169	0	in	InputStream
    //   0	169	1	length	int
    //   0	169	2	BUF_SIZE	int
    //   10	6	3	classbytes	byte[]
    //   56	81	3	classbytes	byte[]
    //   159	1	3	classbytes	byte[]
    //   167	1	3	classbytes	byte[]
    //   1	138	4	bytesread	int
    //   25	13	5	readcount	int
    //   71	13	5	readcount	int
    //   95	11	6	oldbytes	byte[]
    //   126	8	6	oldbytes	byte[]
    //   146	11	7	localObject	Object
    //   155	1	13	localIOException1	IOException
    //   166	1	14	localIOException2	IOException
    // Exception table:
    //   from	to	target	type
    //   3	146	146	finally
    //   148	152	155	java/io/IOException
    //   159	163	166	java/io/IOException
  }
}

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

import java.util.Iterator;

class ArrayMap$1
  implements Iterator<K>
{
  final ArrayMap this$0;
  
  ArrayMap$1(ArrayMap paramArrayMap, Iterator paramIterator1, Iterator paramIterator2) {}
  
  public boolean hasNext()
  {
    return val$keyIter.hasNext();
  }
  
  public K next()
  {
    val$valueIter.next();
    return (K)val$keyIter.next();
  }
  
  public void remove()
  {
    val$valueIter.remove();
    val$keyIter.remove();
  }
}

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

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

public class ArrayMap<K, V>
  implements Collection<K>
{
  final List<K> keys;
  final List<V> values;
  
  public ArrayMap(int initialCapacity)
  {
    keys = new ArrayList(initialCapacity);
    values = new ArrayList(initialCapacity);
  }
  
  public ArrayMap(List<K> keys, List<V> values)
  {
    if (keys.size() != values.size()) {
      throw new IllegalArgumentException("Keys and values size must be equal.");
    }
    this.keys = keys;
    this.values = values;
  }
  
  public V get(K key)
  {
    int index = keys.indexOf(key);
    if (index < 0) {
      return null;
    }
    return (V)values.get(index);
  }
  
  public void put(K key, V value)
  {
    int index = keys.indexOf(key);
    if (index > 0)
    {
      values.set(index, value);
    }
    else
    {
      keys.add(key);
      values.add(value);
    }
  }
  
  public boolean remove(Object key)
  {
    int index = keys.indexOf(key);
    if (index < 0) {
      return false;
    }
    keys.remove(index);
    values.remove(index);
    return true;
  }
  
  public void clear()
  {
    keys.clear();
    values.clear();
  }
  
  public List<K> getKeys()
  {
    return new ArrayList(keys);
  }
  
  public List<V> getValues()
  {
    return new ArrayList(values);
  }
  
  public int size()
  {
    return keys.size();
  }
  
  public boolean isEmpty()
  {
    return keys.isEmpty();
  }
  
  public boolean contains(Object o)
  {
    return keys.contains(o);
  }
  
  public Iterator<K> iterator()
  {
    final Iterator<K> keyIter = keys.iterator();
    final Iterator<V> valueIter = values.iterator();
    
    new Iterator()
    {
      public boolean hasNext()
      {
        return keyIter.hasNext();
      }
      
      public K next()
      {
        valueIter.next();
        return (K)keyIter.next();
      }
      
      public void remove()
      {
        valueIter.remove();
        keyIter.remove();
      }
    };
  }
  
  public Object[] toArray()
  {
    return keys.toArray();
  }
  
  public <T> T[] toArray(T[] a)
  {
    return keys.toArray(a);
  }
  
  public boolean add(K o)
  {
    throw new UnsupportedOperationException();
  }
  
  public boolean containsAll(Collection<?> c)
  {
    throw new UnsupportedOperationException();
  }
  
  public boolean addAll(Collection<? extends K> c)
  {
    throw new UnsupportedOperationException();
  }
  
  public boolean removeAll(Collection<?> c)
  {
    boolean result = false;
    for (Iterator localIterator = c.iterator(); localIterator.hasNext();)
    {
      Object key = localIterator.next();
      result |= remove(key);
    }
    return result;
  }
  
  public boolean retainAll(Collection<?> c)
  {
    boolean result = false;
    Object[] keyArray = keys.toArray();
    Object[] arrayOfObject1;
    int j = (arrayOfObject1 = keyArray).length;
    for (int i = 0; i < j; i++)
    {
      Object key = arrayOfObject1[i];
      if (!c.contains(key)) {
        result |= remove(key);
      }
    }
    return result;
  }
  
  public K getKey(int index)
  {
    return (K)keys.get(index);
  }
  
  public V getValue(int index)
  {
    return (V)values.get(index);
  }
}

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

import java.io.File;
import java.security.ProtectionDomain;
import java.util.ArrayList;
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.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.debug.Debug;
import org.eclipse.osgi.framework.internal.core.FrameworkProperties;
import org.eclipse.osgi.util.ManifestElement;

public class BaseClassLoadingHook
  implements ClassLoadingHook
{
  private static final String[] LIB_EXTENSIONS;
  private static final String[] EMPTY_STRINGS = new String[0];
  
  static
  {
    String[] libExtensions = ManifestElement.getArrayFromList(FrameworkProperties.getProperty("osgi.framework.library.extensions", FrameworkProperties.getProperty("org.osgi.framework.library.extensions")), ",");
    for (int i = 0; i < libExtensions.length; i++) {
      if ((libExtensions[i].length() > 0) && (libExtensions[i].charAt(0) != '.')) {
        libExtensions[i] = ('.' + libExtensions[i]);
      }
    }
    LIB_EXTENSIONS = libExtensions;
  }
  
  public static String[] mapLibraryNames(String mappedLibName)
  {
    int extIndex = mappedLibName.lastIndexOf('.');
    if ((LIB_EXTENSIONS.length == 0) || (extIndex < 0)) {
      return EMPTY_STRINGS;
    }
    String libNameBase = mappedLibName.substring(0, extIndex);
    String[] results = new String[LIB_EXTENSIONS.length];
    for (int i = 0; i < results.length; i++) {
      results[i] = (libNameBase + LIB_EXTENSIONS[i]);
    }
    return results;
  }
  
  public String findLibrary(BaseData data, String libName)
  {
    String mappedName = System.mapLibraryName(libName);
    String path = null;
    if (Debug.DEBUG_LOADER) {
      Debug.println("  mapped library name: " + mappedName);
    }
    path = findNativePath(data, mappedName);
    if (path == null)
    {
      String[] mappedNames = mapLibraryNames(mappedName);
      for (int i = 0; (i < mappedNames.length) && (path == null); i++) {
        path = findNativePath(data, mappedNames[i]);
      }
    }
    if (path == null)
    {
      if (Debug.DEBUG_LOADER) {
        Debug.println("  library does not exist: " + mappedName);
      }
      path = findNativePath(data, libName);
    }
    if (Debug.DEBUG_LOADER) {
      Debug.println("  returning library: " + path);
    }
    return path;
  }
  
  private String findNativePath(BaseData bundledata, String libname)
  {
    int slash = libname.lastIndexOf('/');
    if (slash >= 0) {
      libname = libname.substring(slash + 1);
    }
    String[] nativepaths = getNativePaths(bundledata);
    if (nativepaths == null) {
      return null;
    }
    for (int i = 0; i < nativepaths.length; i++)
    {
      slash = nativepaths[i].lastIndexOf('/');
      String path = slash < 0 ? nativepaths[i] : nativepaths[i].substring(slash + 1);
      if (path.equals(libname))
      {
        if (nativepaths[i].startsWith("external:"))
        {
          String externalPath = BaseStorageHook.substituteVars(nativepaths[i].substring("external:".length()));
          File nativeFile = new File(externalPath);
          return nativeFile.getAbsolutePath();
        }
        File nativeFile = bundledata.getBundleFile().getFile(nativepaths[i], true);
        if (nativeFile != null) {
          return nativeFile.getAbsolutePath();
        }
      }
    }
    return null;
  }
  
  private String[] getNativePaths(BaseData bundledata)
  {
    BaseStorageHook storageHook = (BaseStorageHook)bundledata.getStorageHook(BaseStorageHook.KEY);
    return storageHook != null ? storageHook.getNativePaths() : null;
  }
  
  public boolean addClassPathEntry(ArrayList<ClasspathEntry> cpEntries, String cp, ClasspathManager hostmanager, BaseData sourcedata, ProtectionDomain sourcedomain)
  {
    return false;
  }
  
  public ClassLoader getBundleClassLoaderParent()
  {
    return null;
  }
  
  public byte[] processClass(String name, byte[] classbytes, ClasspathEntry classpathEntry, BundleEntry entry, ClasspathManager manager)
  {
    return null;
  }
  
  public BaseClassLoader createClassLoader(ClassLoader parent, ClassLoaderDelegate delegate, BundleProtectionDomain domain, BaseData data, String[] bundleclasspath)
  {
    return null;
  }
  
  public void initializedClassLoader(BaseClassLoader baseClassLoader, BaseData data) {}
}

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

import org.eclipse.osgi.baseadaptor.HookConfigurator;
import org.eclipse.osgi.baseadaptor.HookRegistry;

public class BaseHookConfigurator
  implements HookConfigurator
{
  public void addHooks(HookRegistry registry)
  {
    BaseStorageHook hook = new BaseStorageHook(new BaseStorage());
    registry.addStorageHook(hook);
    registry.addAdaptorHook(hook);
    registry.addClassLoadingHook(new BaseClassLoadingHook());
  }
}

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

import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.eclipse.osgi.framework.adaptor.PermissionStorage;

public class BasePermissionStorage
  implements PermissionStorage
{
  private Map<String, String[]> locations = new HashMap();
  private String[] defaultInfos;
  private String[] condPermInfos;
  private BaseStorage storage;
  private boolean dirty;
  
  BasePermissionStorage(BaseStorage storage)
  {
    this.storage = storage;
  }
  
  public String[] getLocations()
    throws IOException
  {
    synchronized (locations)
    {
      String[] result = new String[locations.size()];
      int i = 0;
      for (Iterator<String> iLocs = locations.keySet().iterator(); iLocs.hasNext(); i++) {
        result[i] = ((String)iLocs.next());
      }
      return result;
    }
  }
  
  public String[] getPermissionData(String location)
    throws IOException
  {
    if (location == null) {
      return defaultInfos;
    }
    synchronized (locations)
    {
      if (locations.size() == 0) {
        return null;
      }
      return (String[])locations.get(location);
    }
  }
  
  public void setPermissionData(String location, String[] data)
    throws IOException
  {
    if (location == null)
    {
      defaultInfos = data;
      return;
    }
    synchronized (locations)
    {
      if (data == null) {
        locations.remove(location);
      } else {
        locations.put(location, data);
      }
    }
    setDirty(true);
    storage.requestSave();
  }
  
  public void saveConditionalPermissionInfos(String[] infos)
    throws IOException
  {
    condPermInfos = infos;
    setDirty(true);
    storage.requestSave();
  }
  
  public String[] getConditionalPermissionInfos()
    throws IOException
  {
    return condPermInfos;
  }
  
  public boolean isDirty()
  {
    return dirty;
  }
  
  public void setDirty(boolean dirty)
  {
    this.dirty = dirty;
  }
}

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

class BaseStorage$StateSaver$1
  implements Runnable
{
  final BaseStorage.StateSaver this$1;
  
  BaseStorage$StateSaver$1(BaseStorage.StateSaver paramStateSaver) {}
  
  public void run()
  {
    this$1.shutdown();
  }
}

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

import org.eclipse.osgi.baseadaptor.BaseAdaptor;
import org.eclipse.osgi.framework.debug.Debug;
import org.eclipse.osgi.framework.internal.core.FrameworkProperties;
import org.eclipse.osgi.service.resolver.State;

class BaseStorage$StateSaver
  implements Runnable
{
  private final long delay_interval;
  private final long max_total_delay_interval;
  private boolean shutdown = false;
  private long lastSaveTime = 0L;
  private Thread runningThread = null;
  private Thread shutdownHook = null;
  final BaseStorage this$0;
  
  BaseStorage$StateSaver(BaseStorage arg1)
  {
    String prop = FrameworkProperties.getProperty("eclipse.stateSaveDelayInterval");
    long delayValue = 30000L;
    long maxDelayValue = 1800000L;
    if (prop != null) {
      try
      {
        long val = Long.parseLong(prop);
        if ((val >= 1000L) && (val <= 1800000L))
        {
          delayValue = val;
          maxDelayValue = val * 60L;
        }
        else if (val == 0L)
        {
          delayValue = 0L;
          maxDelayValue = 0L;
        }
      }
      catch (NumberFormatException localNumberFormatException) {}
    }
    delay_interval = delayValue;
    max_total_delay_interval = maxDelayValue;
  }
  
  public void run()
  {
    State systemState = this$0.adaptor.getState();
    synchronized (systemState)
    {
      long firstSaveTime = lastSaveTime;
      long curSaveTime = 0L;
      do
      {
        do
        {
          if (System.currentTimeMillis() - firstSaveTime > max_total_delay_interval)
          {
            curSaveTime = lastSaveTime;
            
            break;
          }
          long delayTime = Math.min(delay_interval, lastSaveTime - curSaveTime);
          curSaveTime = lastSaveTime;
          try
          {
            if (!shutdown) {
              systemState.wait(delayTime);
            }
          }
          catch (InterruptedException localInterruptedException)
          {
            curSaveTime = lastSaveTime;
            break;
          }
        } while ((!shutdown) && (curSaveTime < lastSaveTime));
        this$0.saveAllData(false);
      } while ((!shutdown) && (curSaveTime < lastSaveTime));
      runningThread = null;
      try
      {
        Runtime.getRuntime().removeShutdownHook(shutdownHook);
      }
      catch (IllegalStateException localIllegalStateException) {}
      shutdownHook = null;
    }
  }
  
  void shutdown()
  {
    State systemState = this$0.adaptor.getState();
    Thread joinWith = null;
    synchronized (systemState)
    {
      shutdown = true;
      joinWith = runningThread;
      systemState.notifyAll();
    }
    try
    {
      if (joinWith != null)
      {
        if (Debug.DEBUG_GENERAL) {
          Debug.println("About to join saving thread");
        }
        joinWith.join();
        if (Debug.DEBUG_GENERAL) {
          Debug.println("Joined with saving thread");
        }
      }
    }
    catch (InterruptedException ie)
    {
      if (Debug.DEBUG_GENERAL)
      {
        Debug.println("Error shutdowning StateSaver: " + ie.getMessage());
        Debug.printStackTrace(ie);
      }
    }
  }
  
  void requestSave()
  {
    State systemState = this$0.adaptor.getState();
    synchronized (systemState)
    {
      if (shutdown) {
        return;
      }
      if (delay_interval == 0L)
      {
        this$0.saveAllData(false);
        return;
      }
      lastSaveTime = System.currentTimeMillis();
      if (runningThread == null)
      {
        shutdownHook = new Thread(new Runnable()
        {
          public void run()
          {
            shutdown();
          }
        });
        runningThread = new Thread(this, "State Saver");
        runningThread.start();
        Runtime.getRuntime().addShutdownHook(shutdownHook);
      }
    }
  }
}

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

import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Dictionary;
import java.util.List;
import java.util.Properties;
import org.eclipse.core.runtime.adaptor.LocationManager;
import org.eclipse.core.runtime.internal.adaptor.EclipseAdaptorMsg;
import org.eclipse.osgi.baseadaptor.BaseAdaptor;
import org.eclipse.osgi.baseadaptor.BaseData;
import org.eclipse.osgi.baseadaptor.HookRegistry;
import org.eclipse.osgi.baseadaptor.bundlefile.BundleFile;
import org.eclipse.osgi.baseadaptor.bundlefile.BundleFileWrapperChain;
import org.eclipse.osgi.baseadaptor.bundlefile.DirBundleFile;
import org.eclipse.osgi.baseadaptor.bundlefile.MRUBundleFileList;
import org.eclipse.osgi.baseadaptor.bundlefile.NestedDirBundleFile;
import org.eclipse.osgi.baseadaptor.bundlefile.ZipBundleFile;
import org.eclipse.osgi.baseadaptor.hooks.BundleFileFactoryHook;
import org.eclipse.osgi.baseadaptor.hooks.BundleFileWrapperFactoryHook;
import org.eclipse.osgi.baseadaptor.hooks.StorageHook;
import org.eclipse.osgi.framework.adaptor.BundleData;
import org.eclipse.osgi.framework.adaptor.BundleOperation;
import org.eclipse.osgi.framework.adaptor.EventPublisher;
import org.eclipse.osgi.framework.adaptor.PermissionStorage;
import org.eclipse.osgi.framework.debug.Debug;
import org.eclipse.osgi.framework.debug.FrameworkDebugOptions;
import org.eclipse.osgi.framework.internal.core.AbstractBundle;
import org.eclipse.osgi.framework.internal.core.FrameworkProperties;
import org.eclipse.osgi.framework.log.FrameworkLog;
import org.eclipse.osgi.framework.log.FrameworkLogEntry;
import org.eclipse.osgi.framework.util.KeyedHashSet;
import org.eclipse.osgi.internal.loader.BundleLoader;
import org.eclipse.osgi.internal.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd