org.eclipse.osgi_3.7.2.v20120110-1415

etStackTrace(Throwable t)
  {
    if (t == null) {
      return null;
    }
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    
    t.printStackTrace(pw);
    
    Throwable root = getRoot(t);
    if (root != null)
    {
      pw.println("Root exception:");
      root.printStackTrace(pw);
    }
    return sw.toString();
  }
  
  private Writer logForStream(OutputStream output)
  {
    try
    {
      return new BufferedWriter(new OutputStreamWriter(output, "UTF-8"));
    }
    catch (UnsupportedEncodingException localUnsupportedEncodingException) {}
    return new BufferedWriter(new OutputStreamWriter(output));
  }
  
  private void writeLog(int depth, FrameworkLogEntry entry)
    throws IOException
  {
    writeEntry(depth, entry);
    writeMessage(entry);
    writeStack(entry);
    
    FrameworkLogEntry[] children = entry.getChildren();
    if (children != null) {
      for (int i = 0; i < children.length; i++) {
        writeLog(depth + 1, children[i]);
      }
    }
  }
  
  private void writeEntry(int depth, FrameworkLogEntry entry)
    throws IOException
  {
    if (depth == 0)
    {
      writeln();
      write("!ENTRY");
    }
    else
    {
      write("!SUBENTRY");
      writeSpace();
      write(Integer.toString(depth));
    }
    writeSpace();
    write(entry.getEntry());
    writeSpace();
    write(Integer.toString(entry.getSeverity()));
    writeSpace();
    write(Integer.toString(entry.getBundleCode()));
    writeSpace();
    write(getDate(new Date()));
    writeln();
  }
  
  private void writeMessage(FrameworkLogEntry entry)
    throws IOException
  {
    write("!MESSAGE");
    writeSpace();
    writeln(entry.getMessage());
  }
  
  private void writeStack(FrameworkLogEntry entry)
    throws IOException
  {
    Throwable t = entry.getThrowable();
    if (t != null)
    {
      String stack = getStackTrace(t);
      write("!STACK");
      writeSpace();
      write(Integer.toString(entry.getStackCode()));
      writeln();
      write(stack);
    }
  }
  
  private void write(String message)
    throws IOException
  {
    if (message != null)
    {
      writer.write(message);
      if (consoleLog) {
        System.out.print(message);
      }
    }
  }
  
  private void writeln(String s)
    throws IOException
  {
    write(s);
    writeln();
  }
  
  private void writeln()
    throws IOException
  {
    write(LINE_SEPARATOR);
  }
  
  private void writeSpace()
    throws IOException
  {
    write(" ");
  }
  
  private boolean checkLogFileSize()
  {
    if (maxLogSize == 0) {
      return true;
    }
    boolean isBackupOK = true;
    if ((outFile != null) && 
      (secureAction.length(outFile) >> 10 > maxLogSize))
    {
      String logFilename = outFile.getAbsolutePath();
      
      String backupFilename = "";
      if (logFilename.toLowerCase().endsWith(".log")) {
        backupFilename = logFilename.substring(0, logFilename.length() - ".log".length()) + ".bak_" + backupIdx + ".log";
      } else {
        backupFilename = logFilename + ".bak_" + backupIdx;
      }
      File backupFile = new File(backupFilename);
      if ((backupFile.exists()) && 
        (!backupFile.delete()))
      {
        System.err.println("Error when trying to delete old log file: " + backupFile.getName());
        if (backupFile.renameTo(new File(backupFile.getAbsolutePath() + System.currentTimeMillis())))
        {
          System.err.println("So we rename it to filename: " + backupFile.getName());
        }
        else
        {
          System.err.println("And we also cannot rename it!");
          isBackupOK = false;
        }
      }
      boolean isRenameOK = outFile.renameTo(backupFile);
      if (!isRenameOK)
      {
        System.err.println("Error when trying to rename log file to backup one.");
        isBackupOK = false;
      }
      File newFile = new File(logFilename);
      setOutput(newFile, null, false);
      
      openFile();
      try
      {
        writeSession();
        writeln();
        writeln("This is a continuation of log file " + backupFile.getAbsolutePath());
        writeln("Created Time: " + getDate(new Date(System.currentTimeMillis())));
        writer.flush();
      }
      catch (IOException ioe)
      {
        ioe.printStackTrace(System.err);
      }
      closeFile();
      backupIdx = (++backupIdx % maxLogFiles);
    }
    return isBackupOK;
  }
  
  private void readLogProperties()
  {
    String newMaxLogSize = secureAction.getProperty("eclipse.log.size.max");
    if (newMaxLogSize != null)
    {
      maxLogSize = Integer.parseInt(newMaxLogSize);
      if ((maxLogSize != 0) && (maxLogSize < 10)) {
        maxLogSize = 10;
      }
    }
    String newMaxLogFiles = secureAction.getProperty("eclipse.log.backup.max");
    if (newMaxLogFiles != null)
    {
      maxLogFiles = Integer.parseInt(newMaxLogFiles);
      if (maxLogFiles < 1) {
        maxLogFiles = 10;
      }
    }
    String newLogLevel = secureAction.getProperty("eclipse.log.level");
    if (newLogLevel != null) {
      if (newLogLevel.equals("ERROR")) {
        logLevel = 4;
      } else if (newLogLevel.equals("WARNING")) {
        logLevel = 6;
      } else if (newLogLevel.equals("INFO")) {
        logLevel = 15;
      } else {
        logLevel = 0;
      }
    }
  }
  
  private boolean isLoggable(int fwkEntrySeverity)
  {
    if (logLevel == 0) {
      return true;
    }
    return (fwkEntrySeverity & logLevel) != 0;
  }
  
  public boolean isLoggable(Bundle bundle, String loggableName, int loggableLevel)
  {
    if (!enabled) {
      return false;
    }
    if (loggerName.equals(loggableName)) {
      return isLoggable(convertSeverity(loggableLevel));
    }
    if ("org.eclipse.performance.logger".equals(loggableName)) {
      return false;
    }
    if (!"org.eclipse.equinox.logger".equals(loggerName)) {
      return false;
    }
    return loggableLevel == 1;
  }
  
  public void logged(LogEntry entry)
  {
    if (!(entry instanceof ExtendedLogEntry)) {
      return;
    }
    ExtendedLogEntry extended = (ExtendedLogEntry)entry;
    Object context = extended.getContext();
    if ((context instanceof FrameworkLogEntry))
    {
      log((FrameworkLogEntry)context);
      return;
    }
    log(new FrameworkLogEntry(getFwkEntryTag(entry), convertSeverity(entry.getLevel()), 0, entry.getMessage(), 0, entry.getException(), null));
  }
  
  private static String getFwkEntryTag(LogEntry entry)
  {
    Bundle b = entry.getBundle();
    if ((b != null) && (b.getSymbolicName() != null)) {
      return b.getSymbolicName();
    }
    return "unknown";
  }
  
  private static int convertSeverity(int entryLevel)
  {
    switch (entryLevel)
    {
    case 1: 
      return 4;
    case 2: 
      return 2;
    case 3: 
      return 1;
    case 4: 
      return 0;
    }
    return 32;
  }
  
  public String getLoggerName()
  {
    return loggerName;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.core.runtime.internal.adaptor.EclipseLogWriter
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.core.runtime.internal.adaptor;

import java.security.PrivilegedExceptionAction;
import java.util.Dictionary;
import org.osgi.framework.BundleException;

class EclipseStorageHook$1
  implements PrivilegedExceptionAction<Dictionary<String, String>>
{
  final EclipseStorageHook this$0;
  
  EclipseStorageHook$1(EclipseStorageHook paramEclipseStorageHook) {}
  
  public Dictionary<String, String> run()
    throws BundleException
  {
    return this$0.getGeneratedManifest0();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.core.runtime.internal.adaptor.EclipseStorageHook.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.core.runtime.internal.adaptor;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.Dictionary;
import java.util.Enumeration;
import org.eclipse.core.runtime.adaptor.LocationManager;
import org.eclipse.osgi.baseadaptor.BaseAdaptor;
import org.eclipse.osgi.baseadaptor.BaseData;
import org.eclipse.osgi.baseadaptor.HookConfigurator;
import org.eclipse.osgi.baseadaptor.HookRegistry;
import org.eclipse.osgi.baseadaptor.bundlefile.BundleEntry;
import org.eclipse.osgi.baseadaptor.bundlefile.BundleFile;
import org.eclipse.osgi.baseadaptor.hooks.StorageHook;
import org.eclipse.osgi.framework.adaptor.FrameworkAdaptor;
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.Headers;
import org.eclipse.osgi.framework.util.KeyedElement;
import org.eclipse.osgi.internal.baseadaptor.AdaptorUtil;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.osgi.service.pluginconversion.PluginConversionException;
import org.eclipse.osgi.util.ManifestElement;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.BundleException;
import org.osgi.framework.Version;

public final class EclipseStorageHook
  implements StorageHook, HookConfigurator
{
  private static final String PROP_CHECK_CONFIG = "osgi.checkConfiguration";
  private static final String PROP_COMPATIBILITY_LAZYSTART = "osgi.compatibility.eagerStart.LazyActivation";
  private static final boolean COMPATIBILITY_LAZYSTART = Boolean.valueOf(FrameworkProperties.getProperty("osgi.compatibility.eagerStart.LazyActivation", "true")).booleanValue();
  private static final int STORAGE_VERION = 4;
  public static final String KEY = EclipseStorageHook.class.getName();
  public static final int HASHCODE = KEY.hashCode();
  private static final byte FLAG_LAZY_START = 1;
  private static final byte FLAG_HAS_PACKAGE_INFO = 2;
  private static final byte FLAG_HAS_LAZY_INCLUDE = 8;
  private long manifestTimeStamp = 0L;
  private byte manifestType = 0;
  private BaseData bundledata;
  private String pluginClass = null;
  private String[] lazyStartExcludes;
  private String[] lazyStartIncludes;
  private int bundleManfestVersion;
  private String buddyList;
  private String registeredBuddyList;
  private String serviceComponent;
  private byte flags = 0;
  
  public int getStorageVersion()
  {
    return 4;
  }
  
  public StorageHook create(BaseData data)
    throws BundleException
  {
    EclipseStorageHook storageHook = new EclipseStorageHook();
    bundledata = data;
    return storageHook;
  }
  
  public void initialize(Dictionary<String, String> manifest)
    throws BundleException
  {
    String activationPolicy = (String)manifest.get("Bundle-ActivationPolicy");
    if (activationPolicy != null)
    {
      parseActivationPolicy(this, activationPolicy);
    }
    else
    {
      String lazyStart = (String)manifest.get("Eclipse-LazyStart");
      if (lazyStart == null) {
        lazyStart = (String)manifest.get("Eclipse-AutoStart");
      }
      parseLazyStart(this, lazyStart);
    }
    try
    {
      String versionString = (String)manifest.get("Bundle-ManifestVersion");
      bundleManfestVersion = (versionString == null ? 0 : Integer.parseInt(versionString));
    }
    catch (NumberFormatException localNumberFormatException)
    {
      bundleManfestVersion = 0;
    }
    pluginClass = ((String)manifest.get("Plugin-Class"));
    buddyList = ((String)manifest.get("Eclipse-BuddyPolicy"));
    registeredBuddyList = ((String)manifest.get("Eclipse-RegisterBuddy"));
    if (hasPackageInfo(bundledata.getEntry("META-INF/MANIFEST.MF"))) {
      flags = ((byte)(flags | 0x2));
    }
    String genFrom = (String)manifest.get("Generated-from");
    if (genFrom != null)
    {
      ManifestElement generatedFrom = ManifestElement.parseHeader("Generated-from", genFrom)[0];
      if (generatedFrom != null)
      {
        manifestTimeStamp = Long.parseLong(generatedFrom.getValue());
        manifestType = Byte.parseByte(generatedFrom.getAttribute("type"));
      }
    }
    if (isAutoStartable())
    {
      bundledata.setStatus(bundledata.getStatus() | 0x2);
      if (COMPATIBILITY_LAZYSTART) {
        bundledata.setStatus(bundledata.getStatus() | 0x1 | 0x4);
      }
    }
    serviceComponent = ((String)manifest.get("Service-Component"));
  }
  
  public StorageHook load(BaseData target, DataInputStream in)
    throws IOException
  {
    EclipseStorageHook storageHook = new EclipseStorageHook();
    bundledata = target;
    flags = in.readByte();
    int pkgCount = in.readInt();
    String[] packageList = pkgCount > 0 ? new String[pkgCount] : null;
    for (int i = 0; i < pkgCount; i++) {
      packageList[i] = in.readUTF();
    }
    lazyStartExcludes = packageList;
    if ((flags & 0x8) != 0)
    {
      pkgCount = in.readInt();
      packageList = pkgCount > 0 ? new String[pkgCount] : null;
      for (int i = 0; i < pkgCount; i++) {
        packageList[i] = in.readUTF();
      }
      lazyStartIncludes = packageList;
    }
    buddyList = AdaptorUtil.readString(in, false);
    registeredBuddyList = AdaptorUtil.readString(in, false);
    pluginClass = AdaptorUtil.readString(in, false);
    manifestTimeStamp = in.readLong();
    manifestType = in.readByte();
    bundleManfestVersion = in.readInt();
    if (storageHook.isAutoStartable())
    {
      if ((target.getStatus() & 0x2) == 0) {
        target.setStatus(target.getStatus() | 0x2);
      }
      if ((COMPATIBILITY_LAZYSTART) && ((target.getStatus() & 0x1) == 0)) {
        target.setStatus(target.getStatus() | 0x1 | 0x4);
      }
    }
    serviceComponent = AdaptorUtil.readString(in, false);
    return storageHook;
  }
  
  public void save(DataOutputStream out)
    throws IOException
  {
    if (bundledata == null) {
      throw new IllegalStateException();
    }
    out.writeByte(flags);
    String[] excludes = getLazyStartExcludes();
    if (excludes == null)
    {
      out.writeInt(0);
    }
    else
    {
      out.writeInt(excludes.length);
      for (int i = 0; i < excludes.length; i++) {
        out.writeUTF(excludes[i]);
      }
    }
    if ((flags & 0x8) != 0)
    {
      String[] includes = getLazyStartIncludes();
      if (includes == null)
      {
        out.writeInt(0);
      }
      else
      {
        out.writeInt(includes.length);
        for (int i = 0; i < includes.length; i++) {
          out.writeUTF(includes[i]);
        }
      }
    }
    AdaptorUtil.writeStringOrNull(out, getBuddyList());
    AdaptorUtil.writeStringOrNull(out, getRegisteredBuddyList());
    AdaptorUtil.writeStringOrNull(out, getPluginClass());
    out.writeLong(getManifestTimeStamp());
    out.writeByte(getManifestType());
    out.writeInt(getBundleManifestVersion());
    AdaptorUtil.writeStringOrNull(out, serviceComponent);
  }
  
  public int getKeyHashCode()
  {
    return HASHCODE;
  }
  
  public boolean compare(KeyedElement other)
  {
    return other.getKey() == KEY;
  }
  
  public Object getKey()
  {
    return KEY;
  }
  
  public boolean isLazyStart()
  {
    return (flags & 0x1) == 1;
  }
  
  public String[] getLazyStartExcludes()
  {
    return lazyStartExcludes;
  }
  
  public String[] getLazyStartIncludes()
  {
    return lazyStartIncludes;
  }
  
  public String getBuddyList()
  {
    return buddyList;
  }
  
  public boolean hasPackageInfo()
  {
    return (flags & 0x2) == 2;
  }
  
  public String getPluginClass()
  {
    return pluginClass;
  }
  
  public String getRegisteredBuddyList()
  {
    return registeredBuddyList;
  }
  
  public long getManifestTimeStamp()
  {
    return manifestTimeStamp;
  }
  
  public byte getManifestType()
  {
    return manifestType;
  }
  
  public int getBundleManifestVersion()
  {
    return bundleManfestVersion;
  }
  
  public String getServiceComponent()
  {
    return serviceComponent;
  }
  
  public boolean isAutoStartable()
  {
    return (isLazyStart()) || ((lazyStartExcludes != null) && (lazyStartExcludes.length > 0));
  }
  
  private void parseLazyStart(EclipseStorageHook storageHook, String headerValue)
  {
    lazyStartExcludes = null;
    ManifestElement[] allElements = (ManifestElement[])null;
    try
    {
      allElements = ManifestElement.parseHeader("Eclipse-LazyStart", headerValue);
    }
    catch (BundleException e)
    {
      String message = NLS.bind(EclipseAdaptorMsg.ECLIPSE_CLASSLOADER_CANNOT_GET_HEADERS, bundledata.getLocation());
      bundledata.getAdaptor().getFrameworkLog().log(new FrameworkLogEntry("org.eclipse.osgi", 4, 0, message, 0, e, null));
    }
    if (allElements == null) {
      return;
    }
    if ("true".equalsIgnoreCase(allElements[0].getValue()))
    {
      EclipseStorageHook tmp90_89 = storageHook;9089flags = ((byte)(9089flags | 0x1));
    }
    String[] exceptions = ManifestElement.getArrayFromList(allElements[0].getAttribute("exceptions"));
    lazyStartExcludes = exceptions;
  }
  
  private void parseActivationPolicy(EclipseStorageHook storageHook, String headerValue)
  {
    lazyStartExcludes = null;
    ManifestElement[] allElements = (ManifestElement[])null;
    try
    {
      allElements = ManifestElement.parseHeader("Bundle-ActivationPolicy", headerValue);
    }
    catch (BundleException e)
    {
      String message = NLS.bind(EclipseAdaptorMsg.ECLIPSE_CLASSLOADER_CANNOT_GET_HEADERS, bundledata.getLocation());
      bundledata.getAdaptor().getFrameworkLog().log(new FrameworkLogEntry("org.eclipse.osgi", 4, 0, message, 0, e, null));
    }
    if (allElements == null) {
      return;
    }
    if (!"lazy".equalsIgnoreCase(allElements[0].getValue())) {
      return;
    }
    EclipseStorageHook tmp92_91 = storageHook;9291flags = ((byte)(9291flags | 0x1));
    
    lazyStartExcludes = ManifestElement.getArrayFromList(allElements[0].getDirective("exclude"));
    lazyStartIncludes = ManifestElement.getArrayFromList(allElements[0].getDirective("include"));
    if (lazyStartIncludes != null)
    {
      EclipseStorageHook tmp142_141 = storageHook;142141flags = ((byte)(142141flags | 0x8));
    }
  }
  
  /* Error */
  private static boolean hasPackageInfo(URL url)
  {
    // Byte code:
    //   0: aload_0
    //   1: ifnonnull +5 -> 6
    //   4: iconst_0
    //   5: ireturn
    //   6: aconst_null
    //   7: astore_1
    //   8: new 325	java/io/BufferedReader
    //   11: dup
    //   12: new 332	java/io/InputStreamReader
    //   15: dup
    //   16: aload_0
    //   17: invokevirtual 668	java/net/URL:openStream	()Ljava/io/InputStream;
    //   20: invokespecial 643	java/io/InputStreamReader:<init>	(Ljava/io/InputStream;)V
    //   23: invokespecial 628	java/io/BufferedReader:<init>	(Ljava/io/Reader;)V
    //   26: astore_1
    //   27: goto +132 -> 159
    //   30: aload_2
    //   31: invokevirtual 656	java/lang/String:length	()I
    //   34: bipush 20
    //   36: if_icmpge +6 -> 42
    //   39: goto +120 -> 159
    //   42: aload_2
    //   43: iconst_0
    //   44: invokevirtual 657	java/lang/String:charAt	(I)C
    //   47: lookupswitch	default:+112->159, 73:+79->126, 83:+25->72
    //   72: aload_2
    //   73: iconst_1
    //   74: invokevirtual 657	java/lang/String:charAt	(I)C
    //   77: bipush 112
    //   79: if_icmpne +80 -> 159
    //   82: aload_2
    //   83: ldc_w 312
    //   86: invokevirtual 659	java/lang/String:startsWith	(Ljava/lang/String;)Z
    //   89: ifne +23 -> 112
    //   92: aload_2
    //   93: ldc_w 314
    //   96: invokevirtual 659	java/lang/String:startsWith	(Ljava/lang/String;)Z
    //   99: ifne +13 -> 112
    //   102: aload_2
    //   103: ldc_w 313
    //   106: invokevirtual 659	java/lang/String:startsWith	(Ljava/lang/String;)Z
    //   109: ifeq +50 -> 159
    //   112: aload_1
    //   113: ifnull +11 -> 124
    //   116: aload_1
    //   117: invokevirtual 627	java/io/BufferedReader:close	()V
    //   120: goto +4 -> 124
    //   123: pop
    //   124: iconst_1
    //   125: ireturn
    //   126: aload_2
    //   127: ldc_w 309
    //   130: invokevirtual 659	java/lang/String:startsWith	(Ljava/lang/String;)Z
    //   133: ifne -21 -> 112
    //   136: aload_2
    //   137: ldc_w 311
    //   140: invokevirtual 659	java/lang/String:startsWith	(Ljava/lang/String;)Z
    //   143: ifne -31 -> 112
    //   146: aload_2
    //   147: ldc_w 310
    //   150: invokevirtual 659	java/lang/String:startsWith	(Ljava/lang/String;)Z
    //   153: ifeq +6 -> 159
    //   156: goto -44 -> 112
    //   159: aload_1
    //   160: invokevirtual 629	java/io/BufferedReader:readLine	()Ljava/lang/String;
    //   163: dup
    //   164: astore_2
    //   165: ifnonnull -135 -> 30
    //   168: goto +34 -> 202
    //   171: pop
    //   172: aload_1
    //   173: ifnull +41 -> 214
    //   176: aload_1
    //   177: invokevirtual 627	java/io/BufferedReader:close	()V
    //   180: goto +34 -> 214
    //   183: pop
    //   184: goto +30 -> 214
    //   187: astore_3
    //   188: aload_1
    //   189: ifnull +11 -> 200
    //   192: aload_1
    //   193: invokevirtual 627	java/io/BufferedReader:close	()V
    //   196: goto +4 -> 200
    //   199: pop
    //   200: aload_3
    //   201: athrow
    //   202: aload_1
    //   203: ifnull +11 -> 214
    //   206: aload_1
    //   207: invokevirtual 627	java/io/BufferedReader:close	()V
    //   210: goto +4 -> 214
    //   213: pop
    //   214: iconst_0
    //   215: ireturn
    // Line number table:
    //   Java source line #304	-> byte code offset #0
    //   Java source line #305	-> byte code offset #4
    //   Java source line #306	-> byte code offset #6
    //   Java source line #308	-> byte code offset #8
    //   Java source line #310	-> byte code offset #27
    //   Java source line #311	-> byte code offset #30
    //   Java source line #312	-> byte code offset #39
    //   Java source line #313	-> byte code offset #42
    //   Java source line #315	-> byte code offset #72
    //   Java source line #316	-> byte code offset #82
    //   Java source line #328	-> byte code offset #112
    //   Java source line #330	-> byte code offset #116
    //   Java source line #331	-> byte code offset #123
    //   Java source line #317	-> byte code offset #124
    //   Java source line #320	-> byte code offset #126
    //   Java source line #321	-> byte code offset #156
    //   Java source line #310	-> byte code offset #159
    //   Java source line #325	-> byte code offset #171
    //   Java source line #328	-> byte code offset #172
    //   Java source line #330	-> byte code offset #176
    //   Java source line #331	-> byte code offset #183
    //   Java source line #327	-> byte code offset #187
    //   Java source line #328	-> byte code offset #188
    //   Java source line #330	-> byte code offset #192
    //   Java source line #331	-> byte code offset #199
    //   Java source line #334	-> byte code offset #200
    //   Java source line #328	-> byte code offset #202
    //   Java source line #330	-> byte code offset #206
    //   Java source line #331	-> byte code offset #213
    //   Java source line #335	-> byte code offset #214
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	216	0	url	URL
    //   7	200	1	br	java.io.BufferedReader
    //   30	73	2	line	String
    //   126	21	2	line	String
    //   164	2	2	line	String
    //   187	14	3	localObject	Object
    //   123	1	6	localIOException1	IOException
    //   171	1	7	localIOException2	IOException
    //   183	1	8	localIOException3	IOException
    //   199	1	9	localIOException4	IOException
    //   213	1	10	localIOException5	IOException
    // Exception table:
    //   from	to	target	type
    //   116	120	123	java/io/IOException
    //   8	112	171	java/io/IOException
    //   126	168	171	java/io/IOException
    //   176	180	183	java/io/IOException
    //   8	112	187	finally
    //   126	172	187	finally
    //   192	196	199	java/io/IOException
    //   206	210	213	java/io/IOException
  }
  
  public void addHooks(HookRegistry hookRegistry)
  {
    hookRegistry.addStorageHook(this);
  }
  
  private void checkTimeStamp()
    throws IllegalArgumentException
  {
    if (!checkManifestTimeStamp()) {
      throw new IllegalArgumentException();
    }
  }
  
  private boolean checkManifestTimeStamp()
  {
    if (!"true".equalsIgnoreCase(FrameworkProperties.getProperty("osgi.checkConfiguration"))) {
      return true;
    }
    if (PluginConverterImpl.getTimeStamp(bundledata.getBundleFile().getBaseFile(), getManifestType()) == getManifestTimeStamp())
    {
      if ((getManifestType() & 0x9) != 0) {
        return true;
      }
      String cacheLocation = FrameworkProperties.getProperty("osgi.manifest.cache");
      Location parentConfiguration = LocationManager.getConfigurationLocation().getParentLocation();
      if (parentConfiguration != null) {
        try
        {
          return checkManifestAndParent(cacheLocation, bundledata.getSymbolicName(), bundledata.getVersion().toString(), getManifestType()) != null;
        }
        catch (BundleException localBundleException)
        {
          return false;
        }
      }
      File cacheFile = new File(cacheLocation, bundledata.getSymbolicName() + '_' + bundledata.getVersion() + ".MF");
      if (cacheFile.isFile()) {
        return true;
      }
    }
    return false;
  }
  
  private Headers<String, String> checkManifestAndParent(String cacheLocation, String symbolicName, String version, byte inputType)
    throws BundleException
  {
    Headers<String, String> result = basicCheckManifest(cacheLocation, symbolicName, version, inputType);
    if (result != null) {
      return result;
    }
    Location parentConfiguration = null;
    if ((parentConfiguration = LocationManager.getConfigurationLocation().getParentLocation()) != null) {
      result = basicCheckManifest(new File(parentConfiguration.getURL().getFile(), "org.eclipse.osgi/manifests").toString(), symbolicName, version, inputType);
    }
    return result;
  }
  
  private Headers<String, String> basicCheckManifest(String cacheLocation, String symbolicName, String version, byte inputType)
    throws BundleException
  {
    File currentFile = new File(cacheLocation, symbolicName + '_' + version + ".MF");
    if (PluginConverterImpl.upToDate(currentFile, bundledata.getBundleFile().getBaseFile(), inputType)) {
      try
      {
        return Headers.parseManifest(new FileInputStream(currentFile));
      }
      catch (FileNotFoundException localFileNotFoundException) {}
    }
    return null;
  }
  
  Dictionary<String, String> createCachedManifest(boolean firstTime)
    throws BundleException
  {
    return firstTime ? getGeneratedManifest() : new CachedManifest(this);
  }
  
  public Dictionary<String, String> getGeneratedManifest()
    throws BundleException
  {
    if (System.getSecurityManager() == null) {
      return getGeneratedManifest0();
    }
    try
    {
      (Dictionary)AccessController.doPrivileged(new PrivilegedExceptionAction()
      {
        public Dictionary<String, String> run()
          throws BundleException
        {
          return getGeneratedManifest0();
        }
      });
    }
    catch (PrivilegedActionException e)
    {
      throw ((BundleException)e.getException());
    }
  }
  
  final Dictionary<String, String> getGeneratedManifest0()
    throws BundleException
  {
    Dictionary<String, String> builtIn = AdaptorUtil.loadManifestFrom(bundledata);
    if (builtIn != null)
    {
      if (!isComplete(builtIn))
      {
        Dictionary<String, String> generatedManifest = generateManifest(builtIn);
        if (generatedManifest != null) {
          return generatedManifest;
        }
      }
      manifestType = 1;
      File baseFile = bundledata.getBundleFile().getBaseFile();
      if ((baseFile != null) && (bundledata.getBundleFile().getBaseFile().isFile()))
      {
        manifestTimeStamp = bundledata.getBundleFile().getBaseFile().lastModified();
        manifestType = ((byte)(manifestType | 0x8));
      }
      else
      {
        manifestTimeStamp = bundledata.getBundleFile().getEntry("META-INF/MANIFEST.MF").getTime();
      }
      return builtIn;
    }
    Dictionary<String, String> result = generateManifest(null);
    if (result == null) {
      throw new BundleException(NLS.bind(EclipseAdaptorMsg.ECLIPSE_DATA_MANIFEST_NOT_FOUND, bundledata.getLocation()));
    }
    return result;
  }
  
  private Dictionary<String, String> generateManifest(Dictionary<String, String> builtIn)
    throws BundleException
  {
    String cacheLocation = FrameworkProperties.getProperty("osgi.manifest.cache");
    if (bundledata.getSymbolicName() != null)
    {
      Headers<String, String> existingHeaders = checkManifestAndParent(cacheLocation, bundledata.getSymbolicName(), bundledata.getVersion().toString(), manifestType);
      if (existingHeaders != null) {
        return existingHeaders;
      }
    }
    PluginConverterImpl converter = PluginConverterImpl.getDefault();
    if (converter == null) {
      converter = new PluginConverterImpl(bundledata.getAdaptor(), bundledata.getAdaptor().getContext());
    }
    try
    {
      generatedManifest = converter.convertManifest(bundledata.getBundleFile().getBaseFile(), true, null, true, null);
    }
    catch (PluginConversionException pce)
    {
      Dictionary<String, String> generatedManifest;
      String message = NLS.bind(EclipseAdaptorMsg.ECLIPSE_CONVERTER_ERROR_CONVERTING, bundledata.getBundleFile().getBaseFile());
      throw new BundleException(message, 3, pce);
    }
    Dictionary<String, String> generatedManifest;
    Version version = Version.parseVersion((String)generatedManifest.get("Bundle-Version"));
    String symbolicName = ManifestElement.parseHeader("Bundle-SymbolicName", (String)generatedManifest.get("Bundle-SymbolicName"))[0].getValue();
    ManifestElement generatedFrom = ManifestElement.parseHeader("Generated-from", (String)generatedManifest.get("Generated-from"))[0];
    Headers<String, String> existingHeaders = checkManifestAndParent(cacheLocation, symbolicName, version.toString(), Byte.parseByte(generatedFrom.getAttribute("type")));
    
    manifestTimeStamp = Long.parseLong(generatedFrom.getValue());
    manifestType = Byte.parseByte(generatedFrom.getAttribute("type"));
    if ((bundledata.getAdaptor().isReadOnly()) || (existingHeaders != null)) {
      return existingHeaders;
    }
    if (builtIn != null)
    {
      Enumeration<String> keysEnum = builtIn.keys();
      while (keysEnum.hasMoreElements())
      {
        String key = (String)keysEnum.nextElement();
        generatedManifest.put(key, (String)builtIn.get(key));
      }
    }
    File bundleManifestLocation = new File(cacheLocation, symbolicName + '_' + version.toString() + ".MF");
    try
    {
      converter.writeManifest(bundleManifestLocation, generatedManifest, true);
    }
    catch (Exception localException) {}
    return generatedManifest;
  }
  
  private boolean isComplete(Dictionary<String, String> manifest)
  {
    if (manifest.get("Bundle-SymbolicName") != null) {
      return true;
    }
    return (bundledata.getEntry("plugin.xml") == null) && (bundledata.getEntry("fragment.xml") == null);
  }
  
  public BaseData getBaseData()
  {
    return bundledata;
  }
  
  public void copy(StorageHook storageHook) {}
  
  public void validate()
    throws IllegalArgumentException
  {
    checkTimeStamp();
  }
  
  public FrameworkAdaptor getAdaptor()
  {
    if (bundledata != null) {
      return bundledata.getAdaptor();
    }
    return null;
  }
  
  public Dictionary<String, String> getManifest(boolean firstLoad)
    throws BundleException
  {
    return createCachedManifest(firstLoad);
  }
  
  public boolean forgetStatusChange(int status)
  {
    return false;
  }
  
  public boolean forgetStartLevelChange(int startlevel)
  {
    return false;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.core.runtime.internal.adaptor.EclipseStorageHook
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.core.runtime.internal.adaptor;

public abstract interface IModel
{
  public static final int INDENT = 2;
  public static final int RADIX = 36;
  public static final String TRUE = "true";
  public static final String FALSE = "false";
  public static final String REGISTRY = "plugin-registry";
  public static final String REGISTRY_PATH = "path";
  public static final String FRAGMENT = "fragment";
  public static final String FRAGMENT_ID = "id";
  public static final String FRAGMENT_NAME = "name";
  public static final String FRAGMENT_PROVIDER = "provider-name";
  public static final String FRAGMENT_VERSION = "version";
  public static final String FRAGMENT_PLUGIN_ID = "plugin-id";
  public static final String FRAGMENT_PLUGIN_VERSION = "plugin-version";
  public static final String FRAGMENT_PLUGIN_MATCH = "match";
  public static final String FRAGMENT_PLUGIN_MATCH_PERFECT = "perfect";
  public static final String FRAGMENT_PLUGIN_MATCH_EQUIVALENT = "equivalent";
  public static final String FRAGMENT_PLUGIN_MATCH_COMPATIBLE = "compatible";
  public static final String FRAGMENT_PLUGIN_MATCH_GREATER_OR_EQUAL = "greaterOrEqual";
  public static final String PLUGIN = "plugin";
  public static final String PLUGIN_ID = "id";
  public static final String PLUGIN_NAME = "name";
  public static final String PLUGIN_VENDOR = "vendor-name";
  public static final String PLUGIN_PROVIDER = "provider-name";
  public static final String PLUGIN_VERSION = "version";
  public static final String PLUGIN_CLASS = "class";
  public static final String PLUGIN_REQUIRES = "requires";
  public static final String PLUGIN_REQUIRES_PLATFORM = "platform-version";
  public static final String PLUGIN_REQUIRES_PLUGIN = "plugin";
  public static final String PLUGIN_REQUIRES_PLUGIN_VERSION = "version";
  public static final String PLUGIN_REQUIRES_OPTIONAL = "optional";
  public static final String PLUGIN_REQUIRES_IMPORT = "import";
  public static final String PLUGIN_REQUIRES_EXPORT = "export";
  public static final String PLUGIN_REQUIRES_MATCH = "match";
  public static final String PLUGIN_REQUIRES_MATCH_EXACT = "exact";
  public static final String PLUGIN_REQUIRES_MATCH_PERFECT = "perfect";
  public static final String PLUGIN_REQUIRES_MATCH_EQUIVALENT = "equivalent";
  public static final String PLUGIN_REQUIRES_MATCH_COMPATIBLE = "compatible";
  public static final String PLUGIN_REQUIRES_MATCH_GREATER_OR_EQUAL = "greaterOrEqual";
  public static final String PLUGIN_KEY_VERSION_SEPARATOR = "_";
  public static final String RUNTIME = "runtime";
  public static final String LIBRARY = "library";
  public static final String LIBRARY_NAME = "name";
  public static final String LIBRARY_SOURCE = "source";
  public static final String LIBRARY_TYPE = "type";
  public static final String LIBRARY_EXPORT = "export";
  public static final String LIBRARY_EXPORT_MASK = "name";
  public static final String LIBRARY_PACKAGES = "packages";
  public static final String LIBRARY_PACKAGES_PREFIXES = "prefixes";
  public static final String EXTENSION_POINT = "extension-point";
  public static final String EXTENSION_POINT_NAME = "name";
  public static final String EXTENSION_POINT_ID = "id";
  public static final String EXTENSION_POINT_SCHEMA = "schema";
  public static final String EXTENSION = "extension";
  public static final String EXTENSION_NAME = "name";
  public static final String EXTENSION_ID = "id";
  public static final String EXTENSION_TARGET = "point";
  public static final String ELEMENT = "element";
  public static final String ELEMENT_NAME = "name";
  public static final String ELEMENT_VALUE = "value";
  public static final String PROPERTY = "property";
  public static final String PROPERTY_NAME = "name";
  public static final String PROPERTY_VALUE = "value";
}

/* Location:
 * Qualified Name:     org.eclipse.core.runtime.internal.adaptor.IModel
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.core.runtime.internal.adaptor;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

public abstract interface IPluginInfo
{
  public abstract Map<String, List<String>> getLibraries();
  
  public abstract String[] getLibrariesName();
  
  public abstract ArrayList<PluginParser.Prerequisite> getRequires();
  
  public abstract String getMasterId();
  
  public abstract String getMasterVersion();
  
  public abstract String getMasterMatch();
  
  public abstract String getPluginClass();
  
  public abstract String getUniqueId();
  
  public abstract String getVersion();
  
  public abstract boolean isFragment();
  
  public abstract Set<String> getPackageFilters();
  
  public abstract String getPluginName();
  
  public abstract String getProviderName();
  
  public abstract boolean isSingleton();
  
  public abstract boolean hasExtensionExtensionPoints();
  
  public abstract String validateForm();
}

/* Location:
 * Qualified Name:     org.eclipse.core.runtime.internal.adaptor.IPluginInfo
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.core.runtime.internal.adaptor;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;

public class LocationHelper
{
  public static URL buildURL(String spec, boolean trailingSlash)
  {
    if (spec == null) {
      return null;
    }
    boolean isFile = spec.startsWith("file:");
    try
    {
      if (isFile) {
        return adjustTrailingSlash(new File(spec.substring(5)).toURL(), trailingSlash);
      }
      return new URL(spec);
    }
    catch (MalformedURLException localMalformedURLException1)
    {
      if (isFile) {
        return null;
      }
      try
      {
        return adjustTrailingSlash(new File(spec).toURL(), trailingSlash);
      }
      catch (MalformedURLException localMalformedURLException2) {}
    }
    return null;
  }
  
  private static URL adjustTrailingSlash(URL url, boolean trailingSlash)
    throws MalformedURLException
  {
    String file = url.getFile();
    if (trailingSlash == file.endsWith("/")) {
      return url;
    }
    file = trailingSlash ? file + "/" : file.substring(0, file.length() - 1);
    return new URL(url.getProtocol(), url.getHost(), file);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.core.runtime.internal.adaptor.LocationHelper
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.core.runtime.internal.adaptor;

import java.io.IOException;

public abstract interface Locker
{
  public abstract boolean lock()
    throws IOException;
  
  public abstract boolean isLocked()
    throws IOException;
  
  public abstract void release();
}

/* Location:
 * Qualified Name:     org.eclipse.core.runtime.internal.adaptor.Locker
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.core.runtime.internal.adaptor;

import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;

public class Locker_JavaIo
  implements Locker
{
  private File lockFile;
  private RandomAccessFile lockRAF;
  
  public Locker_JavaIo(File lockFile)
  {
    this.lockFile = lockFile;
  }
  
  public synchronized boolean lock()
    throws IOException
  {
    if (lockFile.exists()) {
      lockFile.delete();
    }
    if (lockFile.exists()) {
      return false;
    }
    lockRAF = new RandomAccessFile(lockFile, "rw");
    try
    {
      lockRAF.writeByte(0);
    }
    catch (IOException e)
    {
      lockRAF.close();
      lockRAF = null;
      throw e;
    }
    return true;
  }
  
  public synchronized void release()
  {
    try
    {
      if (lockRAF != null)
      {
        lockRAF.close();
        lockRAF = null;
      }
    }
    catch (IOException localIOException) {}
    if (lockFile != null) {
      lockFile.delete();
    }
  }
 
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