org.eclipse.osgi_3.8.2.v20130124-134944

    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.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;
  private final State lock;
  final BaseStorage this$0;
  
  BaseStorage$StateSaver(BaseStorage arg1, State lock)
  {
    this.lock = lock;
    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()
  {
    synchronized (lock)
    {
      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) {
              lock.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()
  {
    synchronized (lock)
    {
      if (shutdown) {
        return;
      }
      shutdown = true;
      Thread joinWith = runningThread;
      lock.notifyAll();
    }
    try
    {
      Thread joinWith;
      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()
  {
    synchronized (lock)
    {
      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();
        try
        {
          Runtime.getRuntime().addShutdownHook(shutdownHook);
        }
        catch (IllegalStateException localIllegalStateException) {}
      }
    }
  }
}

/* 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.loader.BundleLoaderProxy;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.NativeCodeDescription;
import org.eclipse.osgi.service.resolver.NativeCodeSpecification;
import org.eclipse.osgi.service.resolver.ResolverError;
import org.eclipse.osgi.service.resolver.State;
import org.eclipse.osgi.service.resolver.StateObjectFactory;
import org.eclipse.osgi.storagemanager.StorageManager;
import org.eclipse.osgi.util.ManifestElement;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleException;
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.SynchronousBundleListener;

public class BaseStorage
  implements SynchronousBundleListener
{
  private static final String RUNTIME_ADAPTOR = "org.eclipse.osgi/eclipseadaptor";
  private static final String OPTION_PLATFORM_ADMIN = "org.eclipse.osgi/eclipseadaptor/debug/platformadmin";
  private static final String OPTION_PLATFORM_ADMIN_RESOLVER = "org.eclipse.osgi/eclipseadaptor/debug/platformadmin/resolver";
  private static final String OPTION_MONITOR_PLATFORM_ADMIN = "org.eclipse.osgi/eclipseadaptor/resolver/timing";
  private static final String OPTION_RESOLVER_READER = "org.eclipse.osgi/eclipseadaptor/resolver/reader/timing";
  private static final String PROP_FRAMEWORK_EXTENSIONS = "osgi.framework.extensions";
  private static final String PROP_BUNDLE_STORE = "osgi.bundlestore";
  static final String DATA_DIR_NAME = "data";
  static final String LIB_TEMP = "libtemp";
  private static final String PROP_ENABLE_STATE_SAVER = "eclipse.enableStateSaver";
  static final String BUNDLEFILE_NAME = "bundlefile";
  private static final String PROP_CLEAN = "osgi.clean";
  public static final byte BUNDLEDATA_VERSION = 18;
  public static final byte EXTENSION_INITIALIZE = 1;
  public static final byte EXTENSION_INSTALLED = 2;
  public static final byte EXTENSION_UNINSTALLED = 4;
  public static final byte EXTENSION_UPDATED = 8;
  public static final int TYPE_DIRECTORYBUNDLE = 268435456;
  public static final int TYPE_FILEBUNDLE = 536870912;
  public static final String DELETE_FLAG = ".delete";
  private static final String PERM_DATA_FILE = ".permdata";
  private static final byte PERMDATA_VERSION = 1;
  private final MRUBundleFileList mruList = new MRUBundleFileList();
  BaseAdaptor adaptor;
  private String installPath;
  private StorageManager storageManager;
  private StateManager stateManager;
  private KeyedHashSet storageHooks = new KeyedHashSet(5, false);
  private BundleContext context;
  private SynchronousBundleListener extensionListener;
  private final Method addFwkURLMethod;
  private final Method addExtURLMethod;
  private String[] configuredExtensions;
  private long timeStamp = 0L;
  private int initialBundleStartLevel = 1;
  private final Object nextIdMonitor = new Object();
  private volatile long nextId = 1L;
  private File bundleStoreRoot;
  private BasePermissionStorage permissionStorage;
  private StateSaver stateSaver;
  private boolean invalidState;
  private boolean storageManagerClosed;
  
  BaseStorage()
  {
    addFwkURLMethod = findAddURLMethod(getFwkClassLoader(), "addURL");
    addExtURLMethod = findAddURLMethod(getExtClassLoader(), "addURL");
  }
  
  public void initialize(BaseAdaptor initAdaptor)
    throws IOException
  {
    adaptor = initAdaptor;
    setDebugOptions();
    if (Boolean.valueOf(FrameworkProperties.getProperty("osgi.clean")).booleanValue()) {
      cleanOSGiCache();
    }
    Location installLoc = LocationManager.getInstallLocation();
    if (installLoc != null)
    {
      URL installURL = installLoc.getURL();
      
      installPath = installURL.getPath();
    }
    boolean readOnlyConfiguration = LocationManager.getConfigurationLocation().isReadOnly();
    storageManager = initFileManager(LocationManager.getOSGiConfigurationDir(), readOnlyConfiguration ? "none" : null, readOnlyConfiguration);
    storageManagerClosed = false;
    
    StorageHook[] hooks = initAdaptor.getHookRegistry().getStorageHooks();
    for (int i = 0; i < hooks.length; i++) {
      storageHooks.add(hooks[i]);
    }
  }
  
  private static Method findAddURLMethod(ClassLoader cl, String name)
  {
    if (cl == null) {
      return null;
    }
    return findMethod(cl.getClass(), name, new Class[] { URL.class });
  }
  
  private static Method findMethod(Class<?> clazz, String name, Class<?>[] args)
  {
    if (clazz == null) {
      return null;
    }
    try
    {
      Method result = clazz.getDeclaredMethod(name, args);
      result.setAccessible(true);
      return result;
    }
    catch (NoSuchMethodException localNoSuchMethodException) {}catch (SecurityException localSecurityException) {}
    return findMethod(clazz.getSuperclass(), name, args);
  }
  
  private static void callAddURLMethod(ClassLoader cl, Method meth, URL arg)
    throws InvocationTargetException
  {
    try
    {
      meth.invoke(cl, new Object[] { arg });
    }
    catch (Throwable t)
    {
      throw new InvocationTargetException(t);
    }
  }
  
  private ClassLoader getFwkClassLoader()
  {
    return getClass().getClassLoader();
  }
  
  private ClassLoader getExtClassLoader()
  {
    ClassLoader cl = ClassLoader.getSystemClassLoader();
    ClassLoader extcl = cl.getParent();
    while ((extcl != null) && (extcl.getParent() != null)) {
      extcl = extcl.getParent();
    }
    return extcl;
  }
  
  private static void setDebugOptions()
  {
    FrameworkDebugOptions options = FrameworkDebugOptions.getDefault();
    if (options == null) {
      return;
    }
    StateManager.DEBUG = options != null;
    StateManager.DEBUG_READER = options.getBooleanOption("org.eclipse.osgi/eclipseadaptor/resolver/reader/timing", false);
    StateManager.MONITOR_PLATFORM_ADMIN = options.getBooleanOption("org.eclipse.osgi/eclipseadaptor/resolver/timing", false);
    StateManager.DEBUG_PLATFORM_ADMIN = options.getBooleanOption("org.eclipse.osgi/eclipseadaptor/debug/platformadmin", false);
    StateManager.DEBUG_PLATFORM_ADMIN_RESOLVER = options.getBooleanOption("org.eclipse.osgi/eclipseadaptor/debug/platformadmin/resolver", false);
  }
  
  protected StorageManager initFileManager(File baseDir, String lockMode, boolean readOnly)
    throws IOException
  {
    StorageManager sManager = new StorageManager(baseDir, lockMode, readOnly);
    try
    {
      sManager.open(!readOnly);
    }
    catch (IOException ex)
    {
      if (Debug.DEBUG_GENERAL)
      {
        Debug.println("Error reading framework metadata: " + ex.getMessage());
        Debug.printStackTrace(ex);
      }
      String message = NLS.bind(EclipseAdaptorMsg.ECLIPSE_STARTUP_FILEMANAGER_OPEN_ERROR, ex.getMessage());
      FrameworkLogEntry logEntry = new FrameworkLogEntry("org.eclipse.osgi", 4, 0, message, 0, ex, null);
      adaptor.getFrameworkLog().log(logEntry);
      FrameworkProperties.setProperty("eclipse.exitcode", "15");
      String errorDialog = "<title>" + AdaptorMsg.ADAPTOR_STORAGE_INIT_FAILED_TITLE + "</title>" + NLS.bind(AdaptorMsg.ADAPTOR_STORAGE_INIT_FAILED_MSG, baseDir) + "\n" + ex.getMessage();
      FrameworkProperties.setProperty("eclipse.exitdata", errorDialog);
      throw ex;
    }
    return sManager;
  }
  
  public boolean isReadOnly()
  {
    return storageManager.isReadOnly();
  }
  
  public void compact()
  {
    if (!isReadOnly()) {
      compact(getBundleStoreRoot());
    }
  }
  
  private void compact(File directory)
  {
    if (Debug.DEBUG_GENERAL) {
      Debug.println("compact(" + directory.getPath() + ")");
    }
    String[] list = directory.list();
    if (list == null) {
      return;
    }
    int len = list.length;
    for (int i = 0; i < len; i++) {
      if (!"data".equals(list[i]))
      {
        File target = new File(directory, list[i]);
        if (target.isDirectory())
        {
          File delete = new File(target, ".delete");
          if (delete.exists())
          {
            if ((!AdaptorUtil.rm(target)) && (!delete.exists()))
            {
              try
              {
                FileOutputStream out = new FileOutputStream(delete);
                out.close();
              }
              catch (IOException e)
              {
                if (!Debug.DEBUG_GENERAL) {
                  continue;
                }
              }
              Debug.println("Unable to write " + delete.getPath() + ": " + e.getMessage());
            }
          }
          else {
            compact(target);
          }
        }
      }
    }
  }
  
  public long getFreeSpace()
    throws IOException
  {
    return -1L;
  }
  
  public File getDataFile(BaseData data, String path)
  {
    BaseStorageHook storageHook = (BaseStorageHook)data.getStorageHook(BaseStorageHook.KEY);
    if (storageHook == null) {
      return null;
    }
    return storageHook.getDataFile(path);
  }
  
  BaseAdaptor getAdaptor()
  {
    return adaptor;
  }
  
  public void installNativeCode(BaseData data, String[] nativepaths)
    throws BundleException
  {
    if (nativepaths.length > 0)
    {
      BaseStorageHook storageHook = (BaseStorageHook)data.getStorageHook(BaseStorageHook.KEY);
      if (storageHook != null) {
        storageHook.installNativePaths(nativepaths);
      }
    }
  }
  
  public Dictionary<String, String> loadManifest(BaseData data)
    throws BundleException
  {
    return loadManifest(data, false);
  }
  
  public Dictionary<String, String> loadManifest(BaseData bundleData, boolean firstTime)
    throws BundleException
  {
    Dictionary<String, String> result = null;
    StorageHook[] dataStorageHooks = bundleData.getStorageHooks();
    for (int i = 0; (i < dataStorageHooks.length) && (result == null); i++) {
      result = dataStorageHooks[i].getManifest(firstTime);
    }
    if (result == null) {
      result = AdaptorUtil.loadManifestFrom(bundleData);
    }
    if (result == null) {
      throw new BundleException(NLS.bind(AdaptorMsg.MANIFEST_NOT_FOUND_EXCEPTION, "META-INF/MANIFEST.MF", bundleData.getLocation()), 3);
    }
    return result;
  }
  
  public File getExtractFile(BaseData data, String path)
  {
    BaseStorageHook storageHook = (BaseStorageHook)data.getStorageHook(BaseStorageHook.KEY);
    if (storageHook == null) {
      return null;
    }
    File childGenDir = storageHook.getGenerationDir();
    if (childGenDir != null)
    {
      File childPath = new File(childGenDir, path);
      if (childPath.exists()) {
        return childPath;
      }
    }
    File parentGenDir = storageHook.getParentGenerationDir();
    if (parentGenDir != null)
    {
      File parentPath = new File(parentGenDir, path);
      if (parentPath.exists()) {
        return parentPath;
      }
    }
    File bundleGenerationDir = storageHook.createGenerationDir();
    if ((bundleGenerationDir != null) && (bundleGenerationDir.exists())) {
      return new File(bundleGenerationDir, path);
    }
    return null;
  }
  
  public BaseData[] getInstalledBundles()
  {
    try
    {
      return readBundleDatas();
    }
    catch (Throwable t)
    {
      FrameworkLogEntry logEntry = new FrameworkLogEntry("org.eclipse.osgi", 4, 0, "Error loading bundle datas.  Recalculating cache.", 0, t, null);
      adaptor.getFrameworkLog().log(logEntry);
    }
    return null;
  }
  
  private BaseData[] readBundleDatas()
  {
    InputStream bundleDataStream = findStorageStream(".bundledata");
    if (bundleDataStream == null) {
      return null;
    }
    try
    {
      DataInputStream in = new DataInputStream(new BufferedInputStream(bundleDataStream));
      try
      {
        byte version = in.readByte();
        if (version != 18) {
          return null;
        }
        timeStamp = in.readLong();
        initialBundleStartLevel = in.readInt();
        nextId = in.readLong();
        
        int numStorageHooks = in.readInt();
        StorageHook[] hooks = adaptor.getHookRegistry().getStorageHooks();
        if (numStorageHooks != hooks.length) {
          return null;
        }
        for (int i = 0; i < numStorageHooks; i++)
        {
          Object storageKey = hooks[i].getKey();
          int storageVersion = hooks[i].getStorageVersion();
          if ((!storageKey.equals(in.readUTF())) || (storageVersion != in.readInt())) {
            return null;
          }
        }
        int bundleCount = in.readInt();
        List<BaseData> result = new ArrayList(bundleCount);
        long id = -1L;
        boolean bundleDiscarded = false;
        for (int i = 0; i < bundleCount; i++)
        {
          boolean error = false;
          BaseData data = null;
          try
          {
            id = in.readLong();
            if (id != 0L)
            {
              data = loadBaseData(id, in);
              data.getBundleFile();
              StorageHook[] dataStorageHooks = data.getStorageHooks();
              for (int j = 0; j < dataStorageHooks.length; j++) {
                dataStorageHooks[j].validate();
              }
              if (Debug.DEBUG_GENERAL) {
                Debug.println("BundleData created: " + data);
              }
              processExtension(data, (byte)1);
              result.add(data);
            }
          }
          catch (IllegalArgumentException localIllegalArgumentException)
          {
            bundleDiscarded = true;
            error = true;
          }
          catch (BundleException localBundleException)
          {
            bundleDiscarded = true;
            error = true;
          }
          catch (IOException e)
          {
            bundleDiscarded = true;
            error = true;
            if (Debug.DEBUG_GENERAL)
            {
              Debug.println("Error reading framework metadata: " + e.getMessage());
              Debug.printStackTrace(e);
            }
          }
          if ((error) && (data != null))
          {
            BaseStorageHook storageHook = (BaseStorageHook)data.getStorageHook(BaseStorageHook.KEY);
            storageHook.delete(true, 1);
          }
        }
        if (bundleDiscarded) {
          FrameworkProperties.setProperty("eclipse.refreshBundles", "true");
        }
        return (BaseData[])result.toArray(new BaseData[result.size()]);
      }
      finally
      {
        in.close();
      }
      return null;
    }
    catch (IOException e)
    {
      if (Debug.DEBUG_GENERAL)
      {
        Debug.println("Error reading framework metadata: " + e.getMessage());
        Debug.printStackTrace(e);
      }
    }
  }
  
  private StorageManager getStorageManager()
  {
    if (storageManagerClosed) {
      try
      {
        storageManager.open(!LocationManager.getConfigurationLocation().isReadOnly());
        storageManagerClosed = false;
      }
      catch (IOException e)
      {
        String message = NLS.bind(EclipseAdaptorMsg.ECLIPSE_STARTUP_FILEMANAGER_OPEN_ERROR, e.getMessage());
        FrameworkLogEntry logEntry = new FrameworkLogEntry("org.eclipse.osgi", 4, 0, message, 0, e, null);
        adaptor.getFrameworkLog().log(logEntry);
      }
    }
    return storageManager;
  }
  
  void saveAllData(boolean shutdown)
  {
    if (Debug.DEBUG_GENERAL) {
      Debug.println("Saving framework data ...");
    }
    saveBundleDatas();
    saveStateData(shutdown);
    savePermissionStorage();
    if (shutdown) {
      stateManager.stopDataManager();
    }
  }
  
  private BasePermissionStorage readPermissionData()
  {
    BasePermissionStorage result = new BasePermissionStorage(this);
    InputStream permDataStream = findStorageStream(".permdata");
    if (permDataStream == null) {
      return result;
    }
    try
    {
      DataInputStream in = new DataInputStream(new BufferedInputStream(permDataStream));
      try
      {
        if (1 != in.readByte()) {
          return result;
        }
        int numPerms = in.readInt();
        if (numPerms > 0)
        {
          String[] perms = new String[numPerms];
          for (int i = 0; i < numPerms; i++) {
            perms[i] = in.readUTF();
          }
          result.setPermissionData(null, perms);
        }
        int numLocs = in.readInt();
        if (numLocs > 0) {
          for (int i = 0; i < numLocs; i++)
          {
            String loc = in.readUTF();
            numPerms = in.readInt();
            String[] perms = new String[numPerms];
            for (int j = 0; j < numPerms; j++) {
              perms[j] = in.readUTF();
            }
            result.setPermissionData(loc, perms);
          }
        }
        int numCondPerms = in.readInt();
        if (numCondPerms > 0)
        {
          String[] condPerms = new String[numCondPerms];
          for (int i = 0; i < numCondPerms; i++) {
            condPerms[i] = in.readUTF();
          }
          result.saveConditionalPermissionInfos(condPerms);
        }
        result.setDirty(false);
      }
      finally
      {
        in.close();
      }
      in.close();
    }
    catch (IOException e)
    {
      adaptor.getFrameworkLog().log(new FrameworkEvent(2, context.getBundle(), e));
    }
    return result;
  }
  
  /* Error */
  private void savePermissionStorage()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 1211	org/eclipse/osgi/internal/baseadaptor/BaseStorage:permissionStorage	Lorg/eclipse/osgi/internal/baseadaptor/BasePermissionStorage;
    //   4: ifnull +20 -> 24
    //   7: aload_0
    //   8: invokevirtual 1369	org/eclipse/osgi/internal/baseadaptor/BaseStorage:isReadOnly	()Z
    //   11: ifne +13 -> 24
    //   14: aload_0
    //   15: getfield 1211	org/eclipse/osgi/internal/baseadaptor/BaseStorage:permissionStorage	Lorg/eclipse/osgi/internal/baseadaptor/BasePermissionStorage;
    //   18: invokevirtual 1354	org/eclipse/osgi/internal/baseadaptor/BasePermissionStorage:isDirty	()Z
    //   21: ifne +4 -> 25
    //   24: return
    //   25: getstatic 1188	org/eclipse/osgi/framework/debug/Debug:DEBUG_GENERAL	Z
    //   28: ifeq +9 -> 37
    //   31: ldc_w 602
    //   34: invokestatic 1336	org/eclipse/osgi/framework/debug/Debug:println	(Ljava/lang/String;)V
    //   37: aload_0
    //   38: invokespecial 1386	org/eclipse/osgi/internal/baseadaptor/BaseStorage:getStorageManager	()Lorg/eclipse/osgi/storagemanager/StorageManager;
    //   41: ldc 4
    //   43: invokevirtual 1439	org/eclipse/osgi/storagemanager/StorageManager:getOutputStream	(Ljava/lang/String;)Lorg/eclipse/osgi/storagemanager/ManagedOutputStream;
    //   46: astore_1
    //   47: new 638	java/io/DataOutputStream
    //   50: dup
    //   51: new 636	java/io/BufferedOutputStream
    //   54: dup
    //   55: aload_1
    //   56: invokespecial 1224	java/io/BufferedOutputStream:<init>	(Ljava/io/OutputStream;)V
    //   59: invokespecial 1235	java/io/DataOutputStream:<init>	(Ljava/io/OutputStream;)V
    //   62: astore_2
    //   63: iconst_1
    //   64: istore_3
    //   65: aload_2
    //   66: iconst_1
    //   67: invokevirtual 1232	java/io/DataOutputStream:writeByte	(I)V
    //   70: aload_0
    //   71: getfield 1211	org/eclipse/osgi/internal/baseadaptor/BaseStorage:permissionStorage	Lorg/eclipse/osgi/internal/baseadaptor/BasePermissionStorage;
    //   74: aconst_null
    //   75: invokevirtual 1360	org/eclipse/osgi/internal/baseadaptor/BasePermissionStorage:getPermissionData	(Ljava/lang/String;)[Ljava/lang/String;
    //   78: astore 4
    //   80: aload_2
    //   81: aload 4
    //   83: ifnonnull +7 -> 90
    //   86: iconst_0
    //   87: goto +6 -> 93
    //   90: aload 4
    //   92: arraylength
    //   93: invokevirtual 1233	java/io/DataOutputStream:writeInt	(I)V
    //   96: aload 4
    //   98: ifnull +29 -> 127
    //   101: iconst_0
    //   102: istore 5
    //   104: goto +15 -> 119
    //   107: aload_2
    //   108: aload 4
    //   110: iload 5
    //   112: aaload
    //   113: invokevirtual 1236	java/io/DataOutputStream:writeUTF	(Ljava/lang/String;)V
    //   116: iinc 5 1
    //   119: iload 5
    //   121: aload 4
    //   123: arraylength
    //   124: if_icmplt -17 -> 107
    //   127: aload_0
    //   128: getfield 1211	org/eclipse/osgi/internal/baseadaptor/BaseStorage:permissionStorage	Lorg/eclipse/osgi/internal/baseadaptor/BasePermissionStorage;
    //   131: invokevirtual 1357	org/eclipse/osgi/internal/baseadaptor/BasePermissionStorage:getLocations	()[Ljava/lang/String;
    //   134: astore 5
    //   136: aload_2
    //   137: aload 5
    //   139: ifnonnull +7 -> 146
    //   142: iconst_0
    //   143: goto +6 -> 149
    //   146: aload 5
    //   148: arraylength
    //   149: invokevirtual 1233	java/io/DataOutputStream:writeInt	(I)V
    //   152: aload 5
    //   154: ifnull +90 -> 244
    //   157: iconst_0
    //   158: istore 6
    //   160: goto +76 -> 236
    //   163: aload_2
    //   164: aload 5
    //   166: iload 6
    //   168: aaload
    //   169: invokevirtual 1236	java/io/DataOutputStream:writeUTF	(Ljava/lang/String;)V
    //   172: aload_0
    //   173: getfield 1211	org/eclipse/osgi/internal/baseadaptor/BaseStorage:permissionStorage	Lorg/eclipse/osgi/internal/baseadaptor/BasePermissionStorage;
    //   176: aload 5
    //   178: iload 6
    //   180: aaload
    //   181: invokevirtual 1360	org/eclipse/osgi/internal/baseadaptor/BasePermissionStorage:getPermissionData	(Ljava/lang/String;)[Ljava/lang/String;
    //   184: astore 7
    //   186: aload_2
    //   187: aload 7
    //   189: ifnonnull +7 -> 196
    //   192: iconst_0
    //   193: goto +6 -> 199
    //   196: aload 7
    //   198: arraylength
    //   199: invokevirtual 1233	java/io/DataOutputStream:writeInt	(I)V
    //   202: aload 7
    //   204: ifnull +29 -> 233
    //   207: iconst_0
    //   208: istore 8
    //   210: goto +15 -> 225
    //   213: aload_2
    //   214: aload 7
    //   216: iload 8
    //   218: aaload
    //   219: invokevirtual 1236	java/io/DataOutputStream:writeUTF	(Ljava/lang/String;)V
    //   222: iinc 8 1
    //   225: iload 8
    //   227: aload 7
    //   229: arraylength
    //   230: if_icmplt -17 -> 213
    //   233: iinc 6 1
    //   236: iload 6
    //   238: aload 5
    //   240: arraylength
    //   241: if_icmplt -78 -> 163
    //   244: aload_0
    //   245: getfield 1211	org/eclipse/osgi/internal/baseadaptor/BaseStorage:permissionStorage	Lorg/eclipse/osgi/internal/baseadaptor/BasePermissionStorage;
    //   248: invokevirtual 1356	org/eclipse/osgi/internal/baseadaptor/BasePermissionStorage:getConditionalPermissionInfos	()[Ljava/lang/String;
    //   251: astore 6
    //   253: aload_2
    //   254: aload 6
    //   256: ifnonnull +7 -> 263
    //   259: iconst_0
    //   260: goto +6 -> 266
    //   263: aload 6
    //   265: arraylength
    //   266: invokevirtual 1233	java/io/DataOutputStream:writeInt	(I)V
    //   269: aload 6
    //   271: ifnull +29 -> 300
    //   274: iconst_0
    //   275: istore 7
    //   277: goto +15 -> 292
    //   280: aload_2
    //   281: aload 6
    //   283: iload 7
    //   285: aaload
    //   286: invokevirtual 1236	java/io/DataOutputStream:writeUTF	(Ljava/lang/String;)V
    //   289: iinc 7 1
    //   292: iload 7
    //   294: aload 6
    //   296: arraylength
    //   297: if_icmplt -17 -> 280
    //   300: aload_2
    //   301: invokevirtual 1231	java/io/DataOutputStream:close	()V
    //   304: aload_0
    //   305: getfield 1211	org/eclipse/osgi/internal/baseadaptor/BaseStorage:permissionStorage	Lorg/eclipse/osgi/internal/baseadaptor/BasePermissionStorage;
    //   308: iconst_0
    //   309: invokevirtual 1355	org/eclipse/osgi/internal/baseadaptor/BasePermissionStorage:setDirty	(Z)V
    //   312: iconst_0
    //   313: istore_3
    //   314: goto +24 -> 338
    //   317: astore 9
    //   319: iload_3
    //   320: ifeq +15 -> 335
    //   323: aload_1
    //   324: invokevirtual 1431	org/eclipse/osgi/storagemanager/ManagedOutputStream:abort	()V
    //   327: aload_2
    //   328: invokevirtual 1231	java/io/DataOutputStream:close	()V
    //   331: goto +4 -> 335
    //   334: pop
    //   335: aload 9
    //   337: athrow
    //   338: iload_3
    //   339: ifeq +50 -> 389
    //   342: aload_1
    //   343: invokevirtual 1431	org/eclipse/osgi/storagemanager/ManagedOutputStream:abort	()V
    //   346: aload_2
    //   347: invokevirtual 1231	java/io/DataOutputStream:close	()V
    //   350: goto +39 -> 389
    //   353: pop
    //   354: goto +35 -> 389
    //   357: astore_1
    //   358: aload_0
    //   359: getfield 1208	org/eclipse/osgi/internal/baseadaptor/BaseStorage:adaptor	Lorg/eclipse/osgi/baseadaptor/BaseAdaptor;
    //   362: invokevirtual 1303	org/eclipse/osgi/baseadaptor/BaseAdaptor:getFrameworkLog	()Lorg/eclipse/osgi/framework/log/FrameworkLog;
    //   365: new 719	org/osgi/framework/FrameworkEvent
    //   368: dup
    //   369: iconst_2
    //   370: aload_0
    //   371: getfield 1215	org/eclipse/osgi/internal/baseadaptor/BaseStorage:context	Lorg/osgi/framework/BundleContext;
    //   374: invokeinterface 1491 1 0
    //   379: aload_1
    //   380: invokespecial 1447	org/osgi/framework/FrameworkEvent:<init>	(ILorg/osgi/framework/Bundle;Ljava/lang/Throwable;)V
    //   383: invokeinterface 1464 2 0
    //   388: return
    //   389: return
    // Line number table:
    //   Java source line #514	-> byte code offset #0
    //   Java source line #515	-> byte code offset #24
    //   Java source line #516	-> byte code offset #25
    //   Java source line #517	-> byte code offset #31
    //   Java source line #519	-> byte code offset #37
    //   Java source line #520	-> byte code offset #47
    //   Java source line #521	-> byte code offset #63
    //   Java source line #523	-> byte code offset #65
    //   Java source line #525	-> byte code offset #70
    //   Java source line #526	-> byte code offset #80
    //   Java source line #527	-> byte code offset #96
    //   Java source line #528	-> byte code offset #101
    //   Java source line #529	-> byte code offset #107
    //   Java source line #528	-> byte code offset #116
    //   Java source line #530	-> byte code offset #127
    //   Java source line #531	-> byte code offset #136
    //   Java source line #532	-> byte code offset #152
    //   Java source line #533	-> byte code offset #157
    //   Java source line #534	-> byte code offset #163
    //   Java source line #535	-> byte code offset #172
    //   Java source line #536	-> byte code offset #186
    //   Java source line #537	-> byte code offset #202
    //   Java source line #538	-> byte code offset #207
    //   Java source line #539	-> byte code offset #213
    //   Java source line #538	-> byte code offset #222
    //   Java source line #533	-> byte code offset #233
    //   Java source line #541	-> byte code offset #244
    //   Java source line #542	-> byte code offset #253
    //   Java source line #543	-> byte code offset #269
    //   Java source line #544	-> byte code offset #274
    //   Java source line #545	-> byte code offset #280
    //   Java source line #544	-> byte code offset #289
    //   Java source line #546	-> byte code offset #300
    //   Java source line #547	-> byte code offset #304
    //   Java source line #548	-> byte code offset #312
    //   Java source line #549	-> byte code offset #314
    //   Java source line #551	-> byte code offset #319
    //   Java source line #552	-> byte code offset #323
    //   Java source line #554	-> byte code offset #327
    //   Java source line #555	-> byte code offset #331
    //   Java source line #558	-> byte code offset #335
    //   Java source line #551	-> byte code offset #338
    //   Java source line #552	-> byte code offset #342
    //   Java source line #554	-> byte code offset #346
    //   Java source line #555	-> byte code offset #350
    //   Java source line #559	-> byte code offset #354
    //   Java source line #560	-> byte code offset #358
    //   Java source line #561	-> byte code offset #388
    //   Java source line #563	-> byte code offset #389
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	390	0	this	BaseStorage
    //   46	297	1	fmos	org.eclipse.osgi.storagemanager.ManagedOutputStream
    //   357	23	1	e	IOException
    //   62	285	2	out	DataOutputStream
    //   64	275	3	error	boolean
    //   78	44	4	defaultPerms	String[]
    //   102	18	5	i	int
    //   134	105	5	locations	String[]
    //   158	79	6	i	int
    //   251	44	6	condPerms	String[]
    //   184	44	7	perms	String[]
    //   275	18	7	i	int
    //   208	18	8	j	int
    //   317	19	9	localObject	Object
    //   334	1	14	localIOException1	IOException
    //   353	1	15	localIOException2	IOException
    // Exception table:
    //   from	to	target	type
    //   65	317	317	finally
    //   327	331	334	java/io/IOException
    //   346	350	353	java/io/IOException
    //   37	354	357	java/io/IOException
  }
  
  /* Error */
  private void saveBundleDatas()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 1213	org/eclipse/osgi/internal/baseadaptor/BaseStorage:stateManager	Lorg/eclipse/osgi/internal/baseadaptor/StateManager;
    //   4: ifnull +40 -> 44
    //   7: aload_0
    //   8: invokevirtual 1369	org/eclipse/osgi/internal/baseadaptor/BaseStorage:isReadOnly	()Z
    //   11: ifne +33 -> 44
    //   14: aload_0
    //   15: getfield 1198	org/eclipse/osgi/internal/baseadaptor/BaseStorage:timeStamp	J
    //   18: aload_0
    //   19: getfield 1213	org/eclipse/osgi/internal/baseadaptor/BaseStorage:stateManager	Lorg/eclipse/osgi/internal/baseadaptor/StateManager;
    //   22: invokevirtual 1423	org/eclipse/osgi/internal/baseadaptor/StateManager:getSystemState	()Lorg/eclipse/osgi/service/resolver/State;
    //   25: invokeinterface 1475 1 0
    //   30: lcmp
    //   31: ifne +14 -> 45
    //   34: aload_0
    //   35: getfield 1213	org/eclipse/osgi/internal/baseadaptor/BaseStorage:stateManager	Lorg/eclipse/osgi/internal/baseadaptor/StateManager;
    //   38: invokevirtual 1421	org/eclipse/osgi/internal/baseadaptor/StateManager:saveNeeded	()Z
    //   41: ifne +4 -> 45
    //   44: return
    //   45: getstatic 1188	org/eclipse/osgi/framework/debug/Debug:DEBUG_GENERAL	Z
    //   48: ifeq +9 -> 57
    //   51: ldc_w 615
    //   54: invokestatic 1336	org/eclipse/osgi/framework/debug/Debug:println	(Ljava/lang/String;)V
    //   57: aload_0
    //   58: invokespecial 1386	org/eclipse/osgi/internal/baseadaptor/BaseStorage:getStorageManager	()Lorg/eclipse/osgi/storagemanager/StorageManager;
    //   61: ldc_w 594
    //   64: invokevirtual 1439	org/eclipse/osgi/storagemanager/StorageManager:getOutputStream	(Ljava/lang/String;)Lorg/eclipse/osgi/storagemanager/ManagedOutputStream;
    //   67: astore_1
    //   68: new 638	java/io/DataOutputStream
    //   71: dup
    //   72: new 636	java/io/BufferedOutputStream
    //   75: dup
    //   76: aload_1
    //   77: invokespecial 1224	java/io/BufferedOutputStream:<init>	(Ljava/io/OutputStream;)V
    
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