org.eclipse.osgi_3.7.2.v20120110-1415

rg.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.Version;

public class BaseStorageHook
  implements StorageHook, AdaptorHook
{
  public static final String KEY = BaseStorageHook.class.getName();
  public static final int HASHCODE = KEY.hashCode();
  public static final int DEL_BUNDLE_STORE = 1;
  public static final int DEL_GENERATION = 2;
  private static final int STORAGE_VERSION = 1;
  public static final String EXTERNAL_LIB_PREFIX = "external:";
  public static final String VARIABLE_DELIM_STRING = "$";
  public static final char VARIABLE_DELIM_CHAR = '$';
  public static String COMPOSITE_HEADER = "Equinox-CompositeBundle";
  public static String COMPOSITE_BUNDLE = "composite";
  public static String SURROGATE_BUNDLE = "surrogate";
  private String fileName;
  private String[] nativePaths;
  private int generation = 1;
  private boolean reference;
  private BaseData bundleData;
  private BaseStorage storage;
  private File bundleStore;
  private File dataStore;
  
  public BaseStorageHook(BaseStorage storage)
  {
    this.storage = storage;
  }
  
  public int getStorageVersion()
  {
    return 1;
  }
  
  public StorageHook create(BaseData bundledata)
    throws BundleException
  {
    BaseStorageHook storageHook = new BaseStorageHook(storage);
    bundleData = bundledata;
    return storageHook;
  }
  
  public void initialize(Dictionary<String, String> manifest)
    throws BundleException
  {
    loadManifest(bundleData, manifest);
  }
  
  static void loadManifest(BaseData target, Dictionary<String, String> manifest)
    throws BundleException
  {
    try
    {
      target.setVersion(Version.parseVersion((String)manifest.get("Bundle-Version")));
    }
    catch (IllegalArgumentException localIllegalArgumentException)
    {
      target.setVersion(new InvalidVersion((String)manifest.get("Bundle-Version")));
    }
    ManifestElement[] bsnHeader = ManifestElement.parseHeader("Bundle-SymbolicName", (String)manifest.get("Bundle-SymbolicName"));
    int bundleType = 0;
    if (bsnHeader != null)
    {
      target.setSymbolicName(bsnHeader[0].getValue());
      String singleton = bsnHeader[0].getDirective("singleton");
      if (singleton == null) {
        singleton = bsnHeader[0].getAttribute("singleton");
      }
      if ("true".equals(singleton)) {
        bundleType |= 0x8;
      }
    }
    String classpath = (String)manifest.get("Bundle-ClassPath");
    ManifestElement.parseHeader("Bundle-ClassPath", classpath);
    target.setClassPathString(classpath);
    target.setActivator((String)manifest.get("Bundle-Activator"));
    String host = (String)manifest.get("Fragment-Host");
    if (host != null)
    {
      bundleType |= 0x1;
      ManifestElement[] hostElement = ManifestElement.parseHeader("Fragment-Host", host);
      if ((Constants.getInternalSymbolicName().equals(hostElement[0].getValue())) || ("system.bundle".equals(hostElement[0].getValue())))
      {
        String extensionType = hostElement[0].getDirective("extension");
        if ((extensionType == null) || (extensionType.equals("framework"))) {
          bundleType |= 0x2;
        } else if (extensionType.equals("bootclasspath")) {
          bundleType |= 0x4;
        } else if (extensionType.equals("extclasspath")) {
          bundleType |= 0x10;
        }
      }
    }
    else
    {
      String composite = (String)manifest.get(COMPOSITE_HEADER);
      if (composite != null) {
        if (COMPOSITE_BUNDLE.equals(composite)) {
          bundleType |= 0x20;
        } else {
          bundleType |= 0x40;
        }
      }
    }
    target.setType(bundleType);
    target.setExecutionEnvironment((String)manifest.get("Bundle-RequiredExecutionEnvironment"));
    target.setDynamicImports((String)manifest.get("DynamicImport-Package"));
  }
  
  public StorageHook load(BaseData target, DataInputStream in)
    throws IOException
  {
    target.setLocation(AdaptorUtil.readString(in, false));
    target.setSymbolicName(AdaptorUtil.readString(in, false));
    target.setVersion(AdaptorUtil.loadVersion(in));
    target.setActivator(AdaptorUtil.readString(in, false));
    target.setClassPathString(AdaptorUtil.readString(in, false));
    target.setExecutionEnvironment(AdaptorUtil.readString(in, false));
    target.setDynamicImports(AdaptorUtil.readString(in, false));
    target.setStartLevel(in.readInt());
    target.setStatus(in.readInt());
    target.setType(in.readInt());
    target.setLastModified(in.readLong());
    target.setDirty(false);
    
    BaseStorageHook storageHook = new BaseStorageHook(storage);
    bundleData = target;
    generation = in.readInt();
    reference = in.readBoolean();
    storageHook.setFileName(getAbsolute(reference, AdaptorUtil.readString(in, false)));
    int nativePathCount = in.readInt();
    nativePaths = (nativePathCount > 0 ? new String[nativePathCount] : null);
    for (int i = 0; i < nativePathCount; i++) {
      nativePaths[i] = in.readUTF();
    }
    return storageHook;
  }
  
  private String getAbsolute(boolean isReference, String path)
  {
    if (!isReference) {
      return path;
    }
    File storedPath = new File(path);
    if (!storedPath.isAbsolute()) {
      return new FilePath(storage.getInstallPath() + path).toString();
    }
    return path;
  }
  
  public void save(DataOutputStream out)
    throws IOException
  {
    if (bundleData == null) {
      throw new IllegalStateException();
    }
    AdaptorUtil.writeStringOrNull(out, bundleData.getLocation());
    AdaptorUtil.writeStringOrNull(out, bundleData.getSymbolicName());
    AdaptorUtil.writeStringOrNull(out, bundleData.getVersion().toString());
    AdaptorUtil.writeStringOrNull(out, bundleData.getActivator());
    AdaptorUtil.writeStringOrNull(out, bundleData.getClassPathString());
    AdaptorUtil.writeStringOrNull(out, bundleData.getExecutionEnvironment());
    AdaptorUtil.writeStringOrNull(out, bundleData.getDynamicImports());
    StorageHook[] hooks = bundleData.getStorageHooks();
    boolean forgetStartLevel = false;
    for (int i = 0; (i < hooks.length) && (!forgetStartLevel); i++) {
      forgetStartLevel = hooks[i].forgetStartLevelChange(bundleData.getStartLevel());
    }
    out.writeInt(!forgetStartLevel ? bundleData.getStartLevel() : 1);
    boolean forgetStatus = false;
    for (int i = 0; (i < hooks.length) && (!forgetStatus); i++) {
      forgetStatus = hooks[i].forgetStatusChange(bundleData.getStatus());
    }
    out.writeInt(!forgetStatus ? bundleData.getStatus() : 0xFFFFFFFE & bundleData.getStatus());
    out.writeInt(bundleData.getType());
    out.writeLong(bundleData.getLastModified());
    
    out.writeInt(getGeneration());
    out.writeBoolean(isReference());
    String storedFileName = isReference() ? new FilePath(storage.getInstallPath()).makeRelative(new FilePath(getFileName())) : getFileName();
    AdaptorUtil.writeStringOrNull(out, storedFileName);
    if (nativePaths == null)
    {
      out.writeInt(0);
    }
    else
    {
      out.writeInt(nativePaths.length);
      for (int i = 0; i < nativePaths.length; i++) {
        out.writeUTF(nativePaths[i]);
      }
    }
  }
  
  public int getKeyHashCode()
  {
    return HASHCODE;
  }
  
  public boolean compare(KeyedElement other)
  {
    return other.getKey() == KEY;
  }
  
  public Object getKey()
  {
    return KEY;
  }
  
  public String getFileName()
  {
    return fileName;
  }
  
  public int getGeneration()
  {
    return generation;
  }
  
  public String[] getNativePaths()
  {
    return nativePaths;
  }
  
  public void installNativePaths(String[] installPaths)
    throws BundleException
  {
    validateNativePaths(installPaths);
    nativePaths = installPaths;
  }
  
  public void validateNativePaths(String[] paths)
    throws BundleException
  {
    for (int i = 0; i < paths.length; i++) {
      if (paths[i].startsWith("external:"))
      {
        String path = substituteVars(paths[i].substring("external:".length()));
        File nativeFile = new File(path);
        if (!nativeFile.exists()) {
          throw new BundleException(NLS.bind(AdaptorMsg.BUNDLE_NATIVECODE_EXCEPTION, nativeFile.getAbsolutePath()), 8);
        }
      }
      else
      {
        BundleEntry nativeEntry = bundleData.getBundleFile().getEntry(paths[i]);
        if (nativeEntry == null) {
          throw new BundleException(NLS.bind(AdaptorMsg.BUNDLE_NATIVECODE_EXCEPTION, paths[i]), 8);
        }
      }
    }
  }
  
  public boolean isReference()
  {
    return reference;
  }
  
  public File getBundleStore()
  {
    if (bundleStore == null) {
      bundleStore = new File(storage.getBundleStoreRoot(), String.valueOf(bundleData.getBundleID()));
    }
    return bundleStore;
  }
  
  public File getDataFile(String path)
  {
    if (dataStore == null) {
      dataStore = new File(getBundleStore(), "data");
    }
    if ((path != null) && (!dataStore.exists()) && ((storage.isReadOnly()) || (!dataStore.mkdirs())) && 
      (Debug.DEBUG_GENERAL)) {
      Debug.println("Unable to create bundle data directory: " + dataStore.getPath());
    }
    return path == null ? dataStore : new File(dataStore, path);
  }
  
  void delete(boolean postpone, int type)
    throws IOException
  {
    File delete = null;
    switch (type)
    {
    case 2: 
      delete = getGenerationDir();
      break;
    case 1: 
      delete = getBundleStore();
    }
    if ((delete != null) && (delete.exists()) && ((postpone) || (!AdaptorUtil.rm(delete))))
    {
      FileOutputStream out = new FileOutputStream(new File(delete, ".delete"));
      out.close();
    }
  }
  
  File getGenerationDir()
  {
    return new File(getBundleStore(), String.valueOf(getGeneration()));
  }
  
  File getParentGenerationDir()
  {
    Location parentConfiguration = null;
    Location currentConfiguration = LocationManager.getConfigurationLocation();
    if ((currentConfiguration != null) && ((parentConfiguration = currentConfiguration.getParentLocation()) != null)) {
      return new File(parentConfiguration.getURL().getFile(), "org.eclipse.osgi/bundles/" + bundleData.getBundleID() + '/' + getGeneration());
    }
    return null;
  }
  
  File createGenerationDir()
  {
    File generationDir = getGenerationDir();
    if ((!generationDir.exists()) && ((storage.isReadOnly()) || (!generationDir.mkdirs())) && 
      (Debug.DEBUG_GENERAL)) {
      Debug.println("Unable to create bundle generation directory: " + generationDir.getPath());
    }
    return generationDir;
  }
  
  public void setReference(boolean reference)
  {
    this.reference = reference;
  }
  
  public void setFileName(String fileName)
  {
    this.fileName = fileName;
    
    bundleData.setFileName(fileName);
  }
  
  public void copy(StorageHook storageHook)
  {
    if (!(storageHook instanceof BaseStorageHook)) {
      throw new IllegalArgumentException();
    }
    BaseStorageHook hook = (BaseStorageHook)storageHook;
    bundleStore = bundleStore;
    dataStore = dataStore;
    generation += 1;
  }
  
  public void validate()
    throws IllegalArgumentException
  {}
  
  public Dictionary<String, String> getManifest(boolean firstLoad)
    throws BundleException
  {
    return null;
  }
  
  public boolean forgetStatusChange(int status)
  {
    return false;
  }
  
  public boolean forgetStartLevelChange(int startlevel)
  {
    return false;
  }
  
  public void initialize(BaseAdaptor adaptor) {}
  
  public void frameworkStart(BundleContext context)
    throws BundleException
  {}
  
  public void frameworkStop(BundleContext context)
    throws BundleException
  {}
  
  public void frameworkStopping(BundleContext context) {}
  
  public void addProperties(Properties properties) {}
  
  public URLConnection mapLocationToURLConnection(String location)
    throws IOException
  {
    if (location.startsWith("initial@"))
    {
      location = location.substring(8);
      return new URL(location).openConnection();
    }
    Bundle[] bundles = storage.getAdaptor().getContext().getBundles();
    AbstractBundle bundle = null;
    for (int i = 0; (i < bundles.length) && (bundle == null); i++) {
      if (location.equals(bundles[i].getLocation())) {
        bundle = (AbstractBundle)bundles[i];
      }
    }
    if (bundle == null) {
      return null;
    }
    BaseData data = (BaseData)bundle.getBundleData();
    BaseStorageHook hook = (BaseStorageHook)data.getStorageHook(KEY);
    return hook.isReference() ? new URL("reference:file:" + hook.getFileName()).openConnection() : null;
  }
  
  public void handleRuntimeError(Throwable error) {}
  
  public FrameworkLog createFrameworkLog()
  {
    return null;
  }
  
  public BaseStorage getStorage()
  {
    return storage;
  }
  
  public static String substituteVars(String path)
  {
    StringBuffer buf = new StringBuffer(path.length());
    StringTokenizer st = new StringTokenizer(path, "$", true);
    boolean varStarted = false;
    String var = null;
    while (st.hasMoreElements())
    {
      String tok = st.nextToken();
      if ("$".equals(tok))
      {
        if (!varStarted)
        {
          varStarted = true;
          var = "";
        }
        else
        {
          String prop = null;
          if ((var != null) && (var.length() > 0)) {
            prop = FrameworkProperties.getProperty(var);
          }
          if (prop == null) {
            try
            {
              Method getenv = tmp93_90.getMethod("getenv", new Class[] { String.class });
              prop = (String)getenv.invoke(null, new Object[] { var });
            }
            catch (Throwable localThrowable) {}
          }
          if (prop != null) {
            buf.append(prop);
          } else {
            buf.append(var == null ? "" : var);
          }
          varStarted = false;
          var = null;
        }
      }
      else if (!varStarted) {
        buf.append(tok);
      } else {
        var = tok;
      }
    }
    if (var != null) {
      buf.append('$').append(var);
    }
    return buf.toString();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.baseadaptor.BaseStorageHook
 * 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.net.URLConnection;
import org.eclipse.osgi.baseadaptor.BaseAdaptor;
import org.eclipse.osgi.baseadaptor.BaseData;
import org.eclipse.osgi.framework.adaptor.BundleOperation;
import org.eclipse.osgi.framework.adaptor.EventPublisher;
import org.eclipse.osgi.framework.debug.Debug;
import org.osgi.framework.BundleException;

public class BundleInstall
  implements BundleOperation
{
  private BaseData data;
  private URLConnection source;
  private BaseStorage storage;
  
  public BundleInstall(BaseData data, URLConnection source, BaseStorage storage)
  {
    this.data = data;
    this.source = source;
    this.storage = storage;
  }
  
  /* Error */
  public org.eclipse.osgi.framework.adaptor.BundleData begin()
    throws BundleException
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_1
    //   2: aload_0
    //   3: getfield 238	org/eclipse/osgi/internal/baseadaptor/BundleInstall:data	Lorg/eclipse/osgi/baseadaptor/BaseData;
    //   6: invokestatic 254	java/lang/System:currentTimeMillis	()J
    //   9: invokevirtual 264	org/eclipse/osgi/baseadaptor/BaseData:setLastModified	(J)V
    //   12: aload_0
    //   13: getfield 238	org/eclipse/osgi/internal/baseadaptor/BundleInstall:data	Lorg/eclipse/osgi/baseadaptor/BaseData;
    //   16: aload_0
    //   17: getfield 239	org/eclipse/osgi/internal/baseadaptor/BundleInstall:storage	Lorg/eclipse/osgi/internal/baseadaptor/BaseStorage;
    //   20: invokevirtual 274	org/eclipse/osgi/internal/baseadaptor/BaseStorage:getInitialBundleStartLevel	()I
    //   23: invokevirtual 263	org/eclipse/osgi/baseadaptor/BaseData:setStartLevel	(I)V
    //   26: aload_0
    //   27: getfield 238	org/eclipse/osgi/internal/baseadaptor/BundleInstall:data	Lorg/eclipse/osgi/baseadaptor/BaseData;
    //   30: invokevirtual 265	org/eclipse/osgi/baseadaptor/BaseData:getAdaptor	()Lorg/eclipse/osgi/baseadaptor/BaseAdaptor;
    //   33: invokevirtual 259	org/eclipse/osgi/baseadaptor/BaseAdaptor:getHookRegistry	()Lorg/eclipse/osgi/baseadaptor/HookRegistry;
    //   36: invokevirtual 269	org/eclipse/osgi/baseadaptor/HookRegistry:getStorageHooks	()[Lorg/eclipse/osgi/baseadaptor/hooks/StorageHook;
    //   39: astore_2
    //   40: aload_2
    //   41: arraylength
    //   42: anewarray 123	org/eclipse/osgi/baseadaptor/hooks/StorageHook
    //   45: astore_3
    //   46: iconst_0
    //   47: istore 4
    //   49: goto +23 -> 72
    //   52: aload_3
    //   53: iload 4
    //   55: aload_2
    //   56: iload 4
    //   58: aaload
    //   59: aload_0
    //   60: getfield 238	org/eclipse/osgi/internal/baseadaptor/BundleInstall:data	Lorg/eclipse/osgi/baseadaptor/BaseData;
    //   63: invokeinterface 288 2 0
    //   68: aastore
    //   69: iinc 4 1
    //   72: iload 4
    //   74: aload_2
    //   75: arraylength
    //   76: if_icmplt -24 -> 52
    //   79: aload_0
    //   80: getfield 238	org/eclipse/osgi/internal/baseadaptor/BundleInstall:data	Lorg/eclipse/osgi/baseadaptor/BaseData;
    //   83: aload_3
    //   84: invokevirtual 266	org/eclipse/osgi/baseadaptor/BaseData:setStorageHooks	([Lorg/eclipse/osgi/baseadaptor/hooks/StorageHook;)V
    //   87: aload_0
    //   88: getfield 238	org/eclipse/osgi/internal/baseadaptor/BundleInstall:data	Lorg/eclipse/osgi/baseadaptor/BaseData;
    //   91: getstatic 236	org/eclipse/osgi/internal/baseadaptor/BaseStorageHook:KEY	Ljava/lang/String;
    //   94: invokevirtual 268	org/eclipse/osgi/baseadaptor/BaseData:getStorageHook	(Ljava/lang/String;)Lorg/eclipse/osgi/baseadaptor/hooks/StorageHook;
    //   97: checkcast 131	org/eclipse/osgi/internal/baseadaptor/BaseStorageHook
    //   100: astore 4
    //   102: aload_0
    //   103: getfield 237	org/eclipse/osgi/internal/baseadaptor/BundleInstall:source	Ljava/net/URLConnection;
    //   106: invokevirtual 257	java/net/URLConnection:getInputStream	()Ljava/io/InputStream;
    //   109: astore_1
    //   110: aload_0
    //   111: getfield 237	org/eclipse/osgi/internal/baseadaptor/BundleInstall:source	Ljava/net/URLConnection;
    //   114: invokevirtual 258	java/net/URLConnection:getURL	()Ljava/net/URL;
    //   117: astore 5
    //   119: aload 5
    //   121: ifnonnull +7 -> 128
    //   124: aconst_null
    //   125: goto +8 -> 133
    //   128: aload 5
    //   130: invokevirtual 256	java/net/URL:getProtocol	()Ljava/lang/String;
    //   133: astore 6
    //   135: aload_1
    //   136: instanceof 127
    //   139: ifeq +60 -> 199
    //   142: aload_1
    //   143: checkcast 127	org/eclipse/osgi/framework/internal/core/ReferenceInputStream
    //   146: invokevirtual 271	org/eclipse/osgi/framework/internal/core/ReferenceInputStream:getReference	()Ljava/net/URL;
    //   149: astore 7
    //   151: ldc 4
    //   153: aload 7
    //   155: invokevirtual 256	java/net/URL:getProtocol	()Ljava/lang/String;
    //   158: invokevirtual 249	java/lang/String:equals	(Ljava/lang/Object;)Z
    //   161: ifne +19 -> 180
    //   164: new 134	org/osgi/framework/BundleException
    //   167: dup
    //   168: getstatic 234	org/eclipse/osgi/internal/baseadaptor/AdaptorMsg:ADAPTOR_URL_CREATE_EXCEPTION	Ljava/lang/String;
    //   171: aload 7
    //   173: invokestatic 283	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;
    //   176: invokespecial 284	org/osgi/framework/BundleException:<init>	(Ljava/lang/String;)V
    //   179: athrow
    //   180: aload 4
    //   182: iconst_1
    //   183: invokevirtual 278	org/eclipse/osgi/internal/baseadaptor/BaseStorageHook:setReference	(Z)V
    //   186: aload 4
    //   188: aload 7
    //   190: invokevirtual 255	java/net/URL:getPath	()Ljava/lang/String;
    //   193: invokevirtual 282	org/eclipse/osgi/internal/baseadaptor/BaseStorageHook:setFileName	(Ljava/lang/String;)V
    //   196: goto +128 -> 324
    //   199: aload 4
    //   201: invokevirtual 280	org/eclipse/osgi/internal/baseadaptor/BaseStorageHook:createGenerationDir	()Ljava/io/File;
    //   204: astore 7
    //   206: aload 7
    //   208: invokevirtual 240	java/io/File:exists	()Z
    //   211: ifne +22 -> 233
    //   214: new 112	java/io/IOException
    //   217: dup
    //   218: getstatic 232	org/eclipse/osgi/internal/baseadaptor/AdaptorMsg:ADAPTOR_DIRECTORY_CREATE_EXCEPTION	Ljava/lang/String;
    //   221: aload 7
    //   223: invokevirtual 242	java/io/File:getPath	()Ljava/lang/String;
    //   226: invokestatic 283	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;
    //   229: invokespecial 246	java/io/IOException:<init>	(Ljava/lang/String;)V
    //   232: athrow
    //   233: aload 4
    //   235: iconst_0
    //   236: invokevirtual 278	org/eclipse/osgi/internal/baseadaptor/BaseStorageHook:setReference	(Z)V
    //   239: aload 4
    //   241: ldc 3
    //   243: invokevirtual 282	org/eclipse/osgi/internal/baseadaptor/BaseStorageHook:setFileName	(Ljava/lang/String;)V
    //   246: new 111	java/io/File
    //   249: dup
    //   250: aload 7
    //   252: aload 4
    //   254: invokevirtual 281	org/eclipse/osgi/internal/baseadaptor/BaseStorageHook:getFileName	()Ljava/lang/String;
    //   257: invokespecial 244	java/io/File:<init>	(Ljava/io/File;Ljava/lang/String;)V
    //   260: astore 8
    //   262: ldc 4
    //   264: aload 6
    //   266: invokevirtual 249	java/lang/String:equals	(Ljava/lang/Object;)Z
    //   269: ifeq +49 -> 318
    //   272: new 111	java/io/File
    //   275: dup
    //   276: aload_0
    //   277: getfield 237	org/eclipse/osgi/internal/baseadaptor/BundleInstall:source	Ljava/net/URLConnection;
    //   280: invokevirtual 258	java/net/URLConnection:getURL	()Ljava/net/URL;
    //   283: invokevirtual 255	java/net/URL:getPath	()Ljava/lang/String;
    //   286: invokespecial 243	java/io/File:<init>	(Ljava/lang/String;)V
    //   289: astore 9
    //   291: aload 9
    //   293: invokevirtual 241	java/io/File:isDirectory	()Z
    //   296: ifeq +13 -> 309
    //   299: aload 9
    //   301: aload 8
    //   303: invokestatic 272	org/eclipse/osgi/internal/baseadaptor/AdaptorUtil:copyDir	(Ljava/io/File;Ljava/io/File;)V
    //   306: goto +18 -> 324
    //   309: aload_1
    //   310: aload 8
    //   312: invokestatic 273	org/eclipse/osgi/internal/baseadaptor/AdaptorUtil:readFile	(Ljava/io/InputStream;Ljava/io/File;)V
    //   315: goto +9 -> 324
    //   318: aload_1
    //   319: aload 8
    //   321: invokestatic 273	org/eclipse/osgi/internal/baseadaptor/AdaptorUtil:readFile	(Ljava/io/InputStream;Ljava/io/File;)V
    //   324: aload_0
    //   325: getfield 239	org/eclipse/osgi/internal/baseadaptor/BundleInstall:storage	Lorg/eclipse/osgi/internal/baseadaptor/BaseStorage;
    //   328: aload_0
    //   329: getfield 238	org/eclipse/osgi/internal/baseadaptor/BundleInstall:data	Lorg/eclipse/osgi/baseadaptor/BaseData;
    //   332: iconst_1
    //   333: invokevirtual 277	org/eclipse/osgi/internal/baseadaptor/BaseStorage:loadManifest	(Lorg/eclipse/osgi/baseadaptor/BaseData;Z)Ljava/util/Dictionary;
    //   336: astore 7
    //   338: iconst_0
    //   339: istore 8
    //   341: goto +17 -> 358
    //   344: aload_3
    //   345: iload 8
    //   347: aaload
    //   348: aload 7
    //   350: invokeinterface 287 2 0
    //   355: iinc 8 1
    //   358: iload 8
    //   360: aload_3
    //   361: arraylength
    //   362: if_icmplt -18 -> 344
    //   365: goto +20 -> 385
    //   368: astore 10
    //   370: aload_1
    //   371: ifnull +11 -> 382
    //   374: aload_1
    //   375: invokevirtual 247	java/io/InputStream:close	()V
    //   378: goto +4 -> 382
    //   381: pop
    //   382: aload 10
    //   384: athrow
    //   385: aload_1
    //   386: ifnull +29 -> 415
    //   389: aload_1
    //   390: invokevirtual 247	java/io/InputStream:close	()V
    //   393: goto +22 -> 415
    //   396: pop
    //   397: goto +18 -> 415
    //   400: astore_1
    //   401: new 134	org/osgi/framework/BundleException
    //   404: dup
    //   405: getstatic 235	org/eclipse/osgi/internal/baseadaptor/AdaptorMsg:BUNDLE_READ_EXCEPTION	Ljava/lang/String;
    //   408: bipush 11
    //   410: aload_1
    //   411: invokespecial 285	org/osgi/framework/BundleException:<init>	(Ljava/lang/String;ILjava/lang/Throwable;)V
    //   414: athrow
    //   415: aload_0
    //   416: getfield 238	org/eclipse/osgi/internal/baseadaptor/BundleInstall:data	Lorg/eclipse/osgi/baseadaptor/BaseData;
    //   419: areturn
    // Line number table:
    //   Java source line #46	-> byte code offset #0
    //   Java source line #48	-> byte code offset #2
    //   Java source line #49	-> byte code offset #12
    //   Java source line #50	-> byte code offset #26
    //   Java source line #51	-> byte code offset #40
    //   Java source line #52	-> byte code offset #46
    //   Java source line #53	-> byte code offset #52
    //   Java source line #52	-> byte code offset #69
    //   Java source line #54	-> byte code offset #79
    //   Java source line #55	-> byte code offset #87
    //   Java source line #56	-> byte code offset #102
    //   Java source line #57	-> byte code offset #110
    //   Java source line #58	-> byte code offset #119
    //   Java source line #59	-> byte code offset #135
    //   Java source line #60	-> byte code offset #142
    //   Java source line #61	-> byte code offset #151
    //   Java source line #62	-> byte code offset #164
    //   Java source line #63	-> byte code offset #180
    //   Java source line #64	-> byte code offset #186
    //   Java source line #66	-> byte code offset #199
    //   Java source line #67	-> byte code offset #206
    //   Java source line #68	-> byte code offset #214
    //   Java source line #69	-> byte code offset #233
    //   Java source line #70	-> byte code offset #239
    //   Java source line #71	-> byte code offset #246
    //   Java source line #72	-> byte code offset #262
    //   Java source line #73	-> byte code offset #272
    //   Java source line #74	-> byte code offset #291
    //   Java source line #75	-> byte code offset #299
    //   Java source line #77	-> byte code offset #309
    //   Java source line #79	-> byte code offset #318
    //   Java source line #82	-> byte code offset #324
    //   Java source line #83	-> byte code offset #338
    //   Java source line #84	-> byte code offset #344
    //   Java source line #83	-> byte code offset #355
    //   Java source line #85	-> byte code offset #368
    //   Java source line #87	-> byte code offset #370
    //   Java source line #88	-> byte code offset #374
    //   Java source line #89	-> byte code offset #381
    //   Java source line #92	-> byte code offset #382
    //   Java source line #87	-> byte code offset #385
    //   Java source line #88	-> byte code offset #389
    //   Java source line #89	-> byte code offset #396
    //   Java source line #93	-> byte code offset #400
    //   Java source line #94	-> byte code offset #401
    //   Java source line #97	-> byte code offset #415
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	420	0	this	BundleInstall
    //   1	389	1	in	java.io.InputStream
    //   400	11	1	ioe	IOException
    //   39	36	2	storageHooks	org.eclipse.osgi.baseadaptor.hooks.StorageHook[]
    //   45	316	3	instanceHooks	org.eclipse.osgi.baseadaptor.hooks.StorageHook[]
    //   47	26	4	i	int
    //   100	153	4	storageHook	BaseStorageHook
    //   117	12	5	sourceURL	java.net.URL
    //   133	132	6	protocol	String
    //   149	40	7	reference	java.net.URL
    //   204	47	7	genDir	java.io.File
    //   336	13	7	manifest	java.util.Dictionary<String, String>
    //   260	60	8	outFile	java.io.File
    //   339	20	8	i	int
    //   289	11	9	inFile	java.io.File
    //   368	15	10	localObject	Object
    //   381	1	16	localIOException1	IOException
    //   396	1	17	localIOException2	IOException
    // Exception table:
    //   from	to	target	type
    //   2	368	368	finally
    //   370	378	381	java/io/IOException
    //   385	393	396	java/io/IOException
    //   0	397	400	java/io/IOException
  }
  
  public void undo()
  {
    if (data != null) {
      try
      {
        data.close();
      }
      catch (IOException e)
      {
        if (Debug.DEBUG_GENERAL) {
          Debug.println("Unable to close " + data + ": " + e.getMessage());
        }
      }
    }
    if (data != null)
    {
      BaseStorageHook storageHook = (BaseStorageHook)data.getStorageHook(BaseStorageHook.KEY);
      try
      {
        if (storageHook != null) {
          storageHook.delete(false, 1);
        }
      }
      catch (IOException e)
      {
        data.getAdaptor().getEventPublisher().publishFrameworkEvent(2, data.getBundle(), e);
      }
    }
  }
  
  public void commit(boolean postpone)
    throws BundleException
  {
    storage.processExtension(data, (byte)2);
    storage.updateState(data, 1);
    try
    {
      data.save();
    }
    catch (IOException e)
    {
      throw new BundleException(AdaptorMsg.ADAPTOR_STORAGE_EXCEPTION, e);
    }
  }
}

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

import java.io.IOException;
import org.eclipse.osgi.baseadaptor.BaseData;
import org.eclipse.osgi.framework.adaptor.BundleData;
import org.eclipse.osgi.framework.adaptor.BundleOperation;
import org.osgi.framework.BundleException;

public class BundleUninstall
  implements BundleOperation
{
  private BaseData data;
  private BaseStorage storage;
  
  public BundleUninstall(BaseData data, BaseStorage storage)
  {
    this.data = data;
    this.storage = storage;
  }
  
  public BundleData begin()
    throws BundleException
  {
    return data;
  }
  
  public void commit(boolean postpone)
    throws BundleException
  {
    BaseStorageHook storageHook = (BaseStorageHook)data.getStorageHook(BaseStorageHook.KEY);
    try
    {
      storageHook.delete(postpone, 1);
    }
    catch (IOException localIOException1) {}
    storage.processExtension(data, (byte)4);
    data.setLastModified(System.currentTimeMillis());
    storage.updateState(data, 16);
    data.setDirty(true);
    try
    {
      data.save();
    }
    catch (IOException e)
    {
      throw new BundleException(AdaptorMsg.ADAPTOR_STORAGE_EXCEPTION, e);
    }
  }
  
  public void undo()
    throws BundleException
  {}
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.baseadaptor.BundleUninstall
 * 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.net.URLConnection;
import org.eclipse.osgi.baseadaptor.BaseAdaptor;
import org.eclipse.osgi.baseadaptor.BaseData;
import org.eclipse.osgi.framework.adaptor.BundleOperation;
import org.eclipse.osgi.framework.adaptor.EventPublisher;
import org.osgi.framework.BundleException;

public class BundleUpdate
  implements BundleOperation
{
  private BaseData data;
  private BaseData newData;
  private URLConnection source;
  private BaseStorage storage;
  
  public BundleUpdate(BaseData data, URLConnection source, BaseStorage storage)
  {
    this.data = data;
    this.source = source;
    this.storage = storage;
  }
  
  /* Error */
  public org.eclipse.osgi.framework.adaptor.BundleData begin()
    throws BundleException
  {
    // Byte code:
    //   0: aload_0
    //   1: aload_0
    //   2: getfield 238	org/eclipse/osgi/internal/baseadaptor/BundleUpdate:storage	Lorg/eclipse/osgi/internal/baseadaptor/BaseStorage;
    //   5: aload_0
    //   6: getfield 236	org/eclipse/osgi/internal/baseadaptor/BundleUpdate:data	Lorg/eclipse/osgi/baseadaptor/BaseData;
    //   9: invokevirtual 256	org/eclipse/osgi/baseadaptor/BaseData:getBundleID	()J
    //   12: aload_0
    //   13: getfield 236	org/eclipse/osgi/internal/baseadaptor/BundleUpdate:data	Lorg/eclipse/osgi/baseadaptor/BaseData;
    //   16: invokevirtual 261	org/eclipse/osgi/baseadaptor/BaseData:getLocation	()Ljava/lang/String;
    //   19: invokevirtual 273	org/eclipse/osgi/internal/baseadaptor/BaseStorage:createBaseData	(JLjava/lang/String;)Lorg/eclipse/osgi/baseadaptor/BaseData;
    //   22: putfield 237	org/eclipse/osgi/internal/baseadaptor/BundleUpdate:newData	Lorg/eclipse/osgi/baseadaptor/BaseData;
    //   25: aload_0
    //   26: getfield 237	org/eclipse/osgi/internal/baseadaptor/BundleUpdate:newData	Lorg/eclipse/osgi/baseadaptor/BaseData;
    //   29: invokestatic 247	java/lang/System:currentTimeMillis	()J
    //   32: invokevirtual 260	org/eclipse/osgi/baseadaptor/BaseData:setLastModified	(J)V
    //   35: aload_0
    //   36: getfield 237	org/eclipse/osgi/internal/baseadaptor/BundleUpdate:newData	Lorg/eclipse/osgi/baseadaptor/BaseData;
    //   39: aload_0
    //   40: getfield 236	org/eclipse/osgi/internal/baseadaptor/BundleUpdate:data	Lorg/eclipse/osgi/baseadaptor/BaseData;
    //   43: invokevirtual 254	org/eclipse/osgi/baseadaptor/BaseData:getStartLevel	()I
    //   46: invokevirtual 258	org/eclipse/osgi/baseadaptor/BaseData:setStartLevel	(I)V
    //   49: aload_0
    //   50: getfield 237	org/eclipse/osgi/internal/baseadaptor/BundleUpdate:newData	Lorg/eclipse/osgi/baseadaptor/BaseData;
    //   53: aload_0
    //   54: getfield 236	org/eclipse/osgi/internal/baseadaptor/BundleUpdate:data	Lorg/eclipse/osgi/baseadaptor/BaseData;
    //   57: invokevirtual 255	org/eclipse/osgi/baseadaptor/BaseData:getStatus	()I
    //   60: invokevirtual 259	org/eclipse/osgi/baseadaptor/BaseData:setStatus	(I)V
    //   63: aload_0
    //   64: getfield 236	org/eclipse/osgi/internal/baseadaptor/BundleUpdate:data	Lorg/eclipse/osgi/baseadaptor/BaseData;
    //   67: invokevirtual 262	org/eclipse/osgi/baseadaptor/BaseData:getAdaptor	()Lorg/eclipse/osgi/baseadaptor/BaseAdaptor;
    //   70: invokevirtual 252	org/eclipse/osgi/baseadaptor/BaseAdaptor:getHookRegistry	()Lorg/eclipse/osgi/baseadaptor/HookRegistry;
    //   73: invokevirtual 266	org/eclipse/osgi/baseadaptor/HookRegistry:getStorageHooks	()[Lorg/eclipse/osgi/baseadaptor/hooks/StorageHook;
    //   76: astore_1
    //   77: aload_1
    //   78: arraylength
    //   79: anewarray 120	org/eclipse/osgi/baseadaptor/hooks/StorageHook
    //   82: astore_2
    //   83: iconst_0
    //   84: istore_3
    //   85: goto +47 -> 132
    //   88: aload_2
    //   89: iload_3
    //   90: aload_1
    //   91: iload_3
    //   92: aaload
    //   93: aload_0
    //   94: getfield 237	org/eclipse/osgi/internal/baseadaptor/BundleUpdate:newData	Lorg/eclipse/osgi/baseadaptor/BaseData;
    //   97: invokeinterface 286 2 0
    //   102: aastore
    //   103: aload_2
    //   104: iload_3
    //   105: aaload
    //   106: aload_0
    //   107: getfield 236	org/eclipse/osgi/internal/baseadaptor/BundleUpdate:data	Lorg/eclipse/osgi/baseadaptor/BaseData;
    //   110: aload_2
    //   111: iload_3
    //   112: aaload
    //   113: invokeinterface 283 1 0
    //   118: checkcast 113	java/lang/String
    //   121: invokevirtual 265	org/eclipse/osgi/baseadaptor/BaseData:getStorageHook	(Ljava/lang/String;)Lorg/eclipse/osgi/baseadaptor/hooks/StorageHook;
    //   124: invokeinterface 285 2 0
    //   129: iinc 3 1
    //   132: iload_3
    //   133: aload_1
    //   134: arraylength
    //   135: if_icmplt -47 -> 88
    //   138: aload_0
    //   139: getfield 237	org/eclipse/osgi/internal/baseadaptor/BundleUpdate:newData	Lorg/eclipse/osgi/baseadaptor/BaseData;
    //   142: aload_2
    //   143: invokevirtual 263	org/eclipse/osgi/baseadaptor/BaseData:setStorageHooks	([Lorg/eclipse/osgi/baseadaptor/hooks/StorageHook;)V
    //   146: aload_0
    //   147: getfield 237	org/eclipse/osgi/internal/baseadaptor/BundleUpdate:newData	Lorg/eclipse/osgi/baseadaptor/BaseData;
    //   150: getstatic 234	org/eclipse/osgi/internal/baseadaptor/BaseStorageHook:KEY	Ljava/lang/String;
    //   153: invokevirtual 265	org/eclipse/osgi/baseadaptor/BaseData:getStorageHook	(Ljava/lang/String;)Lorg/eclipse/osgi/baseadaptor/hooks/StorageHook;
    //   156: checkcast 127	org/eclipse/osgi/internal/baseadaptor/BaseStorageHook
    //   159: astore_3
    //   160: aload_0
    //   161: getfield 235	org/eclipse/osgi/internal/baseadaptor/BundleUpdate:source	Ljava/net/URLConnection;
    //   164: invokevirtual 250	java/net/URLConnection:getInputStream	()Ljava/io/InputStream;
    //   167: astore 4
    //   169: aload_0
    //   170: getfield 235	org/eclipse/osgi/internal/baseadaptor/BundleUpdate:source	Ljava/net/URLConnection;
    //   173: invokevirtual 251	java/net/URLConnection:getURL	()Ljava/net/URL;
    //   176: astore 5
    //   178: aload 5
    //   180: ifnonnull +7 -> 187
    //   183: aconst_null
    //   184: goto +8 -> 192
    //   187: aload 5
    //   189: invokevirtual 249	java/net/URL:getProtocol	()Ljava/lang/String;
    //   192: astore 6
    //   194: aload 4
    //   196: instanceof 123
    //   199: ifeq +63 -> 262
    //   202: aload 4
    //   204: checkcast 123	org/eclipse/osgi/framework/internal/core/ReferenceInputStream
    //   207: invokevirtual 267	org/eclipse/osgi/framework/internal/core/ReferenceInputStream:getReference	()Ljava/net/URL;
    //   210: astore 7
    //   212: ldc 2
    //   214: aload 7
    //   216: invokevirtual 249	java/net/URL:getProtocol	()Ljava/lang/String;
    //   219: invokevirtual 246	java/lang/String:equals	(Ljava/lang/Object;)Z
    //   222: ifne +19 -> 241
    //   225: new 130	org/osgi/framework/BundleException
    //   228: dup
    //   229: getstatic 232	org/eclipse/osgi/internal/baseadaptor/AdaptorMsg:ADAPTOR_URL_CREATE_EXCEPTION	Ljava/lang/String;
    //   232: aload 7
    //   234: invokestatic 279	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;
    //   237: invokespecial 280	org/osgi/framework/BundleException:<init>	(Ljava/lang/String;)V
    //   240: athrow
    //   241: aload 7
    //   243: invokevirtual 248	java/net/URL:getPath	()Ljava/lang/String;
    //   246: astore 8
    //   248: aload_3
    //   249: iconst_1
    //   250: invokevirtual 274	org/eclipse/osgi/internal/baseadaptor/BaseStorageHook:setReference	(Z)V
    //   253: aload_3
    //   254: aload 8
    //   256: invokevirtual 278	org/eclipse/osgi/internal/baseadaptor/BaseStorageHook:setFileName	(Ljava/lang/String;)V
    //   259: goto +126 -> 385
    //   262: aload_3
    //   263: invokevirtual 276	org/eclipse/osgi/internal/baseadaptor/BaseStorageHook:createGenerationDir	()Ljava/io/File;
    //   266: astore 7
    //   268: aload 7
    //   270: invokevirtual 239	java/io/File:exists	()Z
    //   273: ifne +22 -> 295
    //   276: new 130	org/osgi/framework/BundleException
    //   279: dup
    //   280: getstatic 230	org/eclipse/osgi/internal/baseadaptor/AdaptorMsg:ADAPTOR_DIRECTORY_CREATE_EXCEPTION	Ljava/lang/String;
    //   283: aload 7
    //   285: invokevirtual 241	java/io/File:getPath	()Ljava/lang/String;
    //   288: invokestatic 279	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;
    //   291: invokespecial 280	org/osgi/framework/BundleException:<init>	(Ljava/lang/String;)V
    //   294: athrow
    //   295: aload_3
    //   296: iconst_0
    //   297: invokevirtual 274	org/eclipse/osgi/internal/baseadaptor/BaseStorageHook:setReference	(Z)V
    //   300: aload_3
    //   301: ldc 1
    //   303: invokevirtual 278	org/eclipse/osgi/internal/baseadaptor/BaseStorageHook:setFileName	(Ljava/lang/String;)V
    //   306: new 109	java/io/File
    //   309: dup
    //   310: aload 7
    //   312: aload_3
    //   313: invokevirtual 277	org/eclipse/osgi/internal/baseadaptor/BaseStorageHook:getFileName	()Ljava/lang/String;
    //   316: invokespecial 243	java/io/File:<i
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-2017. Infinite Loop Ltd