org.eclipse.osgi_3.7.2.v20120110-1415

9
    //   312: aload_0
    //   313: aload 9
    //   315: new 267	java/lang/StringBuffer
    //   318: dup
    //   319: ldc_w 248
    //   322: invokespecial 484	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   325: aload 7
    //   327: invokevirtual 455	java/io/File:getAbsolutePath	()Ljava/lang/String;
    //   330: invokevirtual 489	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   333: invokevirtual 482	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   336: invokespecial 508	org/eclipse/osgi/framework/debug/EclipseDebugTrace:writeComment	(Ljava/io/Writer;Ljava/lang/String;)V
    //   339: aload_0
    //   340: aload 9
    //   342: ldc_w 252
    //   345: invokespecial 508	org/eclipse/osgi/framework/debug/EclipseDebugTrace:writeComment	(Ljava/io/Writer;Ljava/lang/String;)V
    //   348: aload_0
    //   349: aload 9
    //   351: new 267	java/lang/StringBuffer
    //   354: dup
    //   355: ldc 19
    //   357: invokespecial 484	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   360: aload_0
    //   361: getfield 446	org/eclipse/osgi/framework/debug/EclipseDebugTrace:debugOptions	Lorg/eclipse/osgi/framework/debug/FrameworkDebugOptions;
    //   364: invokevirtual 516	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:isVerbose	()Z
    //   367: invokevirtual 487	java/lang/StringBuffer:append	(Z)Ljava/lang/StringBuffer;
    //   370: invokevirtual 482	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   373: invokespecial 508	org/eclipse/osgi/framework/debug/EclipseDebugTrace:writeComment	(Ljava/io/Writer;Ljava/lang/String;)V
    //   376: aload_0
    //   377: aload 9
    //   379: new 267	java/lang/StringBuffer
    //   382: dup
    //   383: ldc 15
    //   385: invokespecial 484	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   388: aload_0
    //   389: lload_2
    //   390: invokespecial 502	org/eclipse/osgi/framework/debug/EclipseDebugTrace:getFormattedDate	(J)Ljava/lang/String;
    //   393: invokevirtual 489	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   396: invokevirtual 482	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   399: invokespecial 508	org/eclipse/osgi/framework/debug/EclipseDebugTrace:writeComment	(Ljava/io/Writer;Ljava/lang/String;)V
    //   402: aload 9
    //   404: invokevirtual 465	java/io/Writer:flush	()V
    //   407: goto +38 -> 445
    //   410: astore 10
    //   412: aload 10
    //   414: invokevirtual 458	java/io/IOException:printStackTrace	()V
    //   417: aload_1
    //   418: ifnull +37 -> 455
    //   421: aload_0
    //   422: aload 9
    //   424: invokespecial 500	org/eclipse/osgi/framework/debug/EclipseDebugTrace:closeWriter	(Ljava/io/Writer;)V
    //   427: goto +28 -> 455
    //   430: astore 11
    //   432: aload_1
    //   433: ifnull +9 -> 442
    //   436: aload_0
    //   437: aload 9
    //   439: invokespecial 500	org/eclipse/osgi/framework/debug/EclipseDebugTrace:closeWriter	(Ljava/io/Writer;)V
    //   442: aload 11
    //   444: athrow
    //   445: aload_1
    //   446: ifnull +9 -> 455
    //   449: aload_0
    //   450: aload 9
    //   452: invokespecial 500	org/eclipse/osgi/framework/debug/EclipseDebugTrace:closeWriter	(Ljava/io/Writer;)V
    //   455: aload_0
    //   456: aload_0
    //   457: dup
    //   458: getfield 437	org/eclipse/osgi/framework/debug/EclipseDebugTrace:backupTraceFileIndex	I
    //   461: iconst_1
    //   462: iadd
    //   463: dup_x1
    //   464: putfield 437	org/eclipse/osgi/framework/debug/EclipseDebugTrace:backupTraceFileIndex	I
    //   467: aload_0
    //   468: getfield 439	org/eclipse/osgi/framework/debug/EclipseDebugTrace:maxTraceFiles	I
    //   471: irem
    //   472: putfield 437	org/eclipse/osgi/framework/debug/EclipseDebugTrace:backupTraceFileIndex	I
    //   475: iload 4
    //   477: ireturn
    // Line number table:
    //   Java source line #402	-> byte code offset #0
    //   Java source line #403	-> byte code offset #3
    //   Java source line #404	-> byte code offset #10
    //   Java source line #405	-> byte code offset #21
    //   Java source line #406	-> byte code offset #37
    //   Java source line #409	-> byte code offset #43
    //   Java source line #410	-> byte code offset #48
    //   Java source line #411	-> byte code offset #61
    //   Java source line #413	-> byte code offset #113
    //   Java source line #415	-> byte code offset #142
    //   Java source line #416	-> byte code offset #153
    //   Java source line #417	-> byte code offset #161
    //   Java source line #418	-> byte code offset #169
    //   Java source line #419	-> byte code offset #196
    //   Java source line #420	-> byte code offset #235
    //   Java source line #422	-> byte code offset #265
    //   Java source line #423	-> byte code offset #274
    //   Java source line #429	-> byte code offset #277
    //   Java source line #430	-> byte code offset #285
    //   Java source line #431	-> byte code offset #290
    //   Java source line #432	-> byte code offset #299
    //   Java source line #439	-> byte code offset #302
    //   Java source line #441	-> byte code offset #305
    //   Java source line #442	-> byte code offset #312
    //   Java source line #443	-> byte code offset #339
    //   Java source line #444	-> byte code offset #348
    //   Java source line #445	-> byte code offset #376
    //   Java source line #446	-> byte code offset #402
    //   Java source line #447	-> byte code offset #410
    //   Java source line #448	-> byte code offset #412
    //   Java source line #450	-> byte code offset #417
    //   Java source line #451	-> byte code offset #421
    //   Java source line #449	-> byte code offset #430
    //   Java source line #450	-> byte code offset #432
    //   Java source line #451	-> byte code offset #436
    //   Java source line #453	-> byte code offset #442
    //   Java source line #450	-> byte code offset #445
    //   Java source line #451	-> byte code offset #449
    //   Java source line #454	-> byte code offset #455
    //   Java source line #458	-> byte code offset #475
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	478	0	this	EclipseDebugTrace
    //   0	478	1	traceFile	File
    //   0	478	2	timestamp	long
    //   1	475	4	isBackupOK	boolean
    //   41	77	5	traceFileName	String
    //   46	101	6	backupFilename	String
    //   151	175	7	backupFile	File
    //   283	3	8	isRenameOK	boolean
    //   303	148	9	traceWriter	Writer
    //   410	3	10	ioEx	IOException
    //   430	13	11	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   305	407	410	java/io/IOException
    //   305	417	430	finally
  }
  
  private void writeComment(Writer traceWriter, String comment)
    throws IOException
  {
    StringBuffer commentText = new StringBuffer("#");
    commentText.append(" ");
    commentText.append(comment);
    commentText.append(LINE_SEPARATOR);
    traceWriter.write(commentText.toString());
  }
  
  private final String getFormattedDate(long timestamp)
  {
    return TRACE_FILE_DATE_FORMATTER.format(new Date(timestamp));
  }
  
  /* Error */
  private final String getFormattedThrowable(Throwable error)
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_2
    //   2: aload_1
    //   3: ifnull +63 -> 66
    //   6: aconst_null
    //   7: astore_3
    //   8: new 254	java/io/ByteArrayOutputStream
    //   11: dup
    //   12: invokespecial 449	java/io/ByteArrayOutputStream:<init>	()V
    //   15: astore 4
    //   17: new 258	java/io/PrintStream
    //   20: dup
    //   21: aload 4
    //   23: iconst_0
    //   24: invokespecial 462	java/io/PrintStream:<init>	(Ljava/io/OutputStream;Z)V
    //   27: astore_3
    //   28: aload_1
    //   29: aload_3
    //   30: invokevirtual 492	java/lang/Throwable:printStackTrace	(Ljava/io/PrintStream;)V
    //   33: aload 4
    //   35: invokevirtual 450	java/io/ByteArrayOutputStream:toString	()Ljava/lang/String;
    //   38: invokestatic 510	org/eclipse/osgi/framework/debug/EclipseDebugTrace:encodeText	(Ljava/lang/String;)Ljava/lang/String;
    //   41: astore_2
    //   42: goto +16 -> 58
    //   45: astore 5
    //   47: aload_3
    //   48: ifnull +7 -> 55
    //   51: aload_3
    //   52: invokevirtual 461	java/io/PrintStream:close	()V
    //   55: aload 5
    //   57: athrow
    //   58: aload_3
    //   59: ifnull +7 -> 66
    //   62: aload_3
    //   63: invokevirtual 461	java/io/PrintStream:close	()V
    //   66: aload_2
    //   67: areturn
    // Line number table:
    //   Java source line #496	-> byte code offset #0
    //   Java source line #497	-> byte code offset #2
    //   Java source line #498	-> byte code offset #6
    //   Java source line #500	-> byte code offset #8
    //   Java source line #501	-> byte code offset #17
    //   Java source line #502	-> byte code offset #28
    //   Java source line #503	-> byte code offset #33
    //   Java source line #504	-> byte code offset #45
    //   Java source line #505	-> byte code offset #47
    //   Java source line #506	-> byte code offset #51
    //   Java source line #508	-> byte code offset #55
    //   Java source line #505	-> byte code offset #58
    //   Java source line #506	-> byte code offset #62
    //   Java source line #510	-> byte code offset #66
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	68	0	this	EclipseDebugTrace
    //   0	68	1	error	Throwable
    //   1	66	2	result	String
    //   7	56	3	throwableStream	java.io.PrintStream
    //   15	19	4	throwableByteOutputStream	java.io.ByteArrayOutputStream
    //   45	11	5	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   8	45	45	finally
  }
  
  private void writeSession(Writer traceWriter, long timestamp)
    throws IOException
  {
    writeComment(traceWriter, "!SESSION " + getFormattedDate(timestamp));
    writeComment(traceWriter, "version: 1.1");
    writeComment(traceWriter, "verbose: " + debugOptions.isVerbose());
    writeComment(traceWriter, "The following option strings are specified for this debug session:");
    String[] allOptions = FrameworkDebugOptions.getDefault().getAllOptions();
    for (int i = 0; i < allOptions.length; i++) {
      writeComment(traceWriter, "\t" + allOptions[i]);
    }
  }
  
  private void writeMessage(Writer traceWriter, FrameworkDebugTraceEntry entry)
    throws IOException
  {
    StringBuffer message = new StringBuffer("|");
    message.append(" ");
    message.append(encodeText(entry.getThreadName()));
    message.append(" ");
    message.append("|");
    message.append(" ");
    message.append(getFormattedDate(entry.getTimestamp()));
    message.append(" ");
    message.append("|");
    message.append(" ");
    if (!debugOptions.isVerbose())
    {
      message.append(encodeText(entry.getMessage()));
    }
    else
    {
      message.append(entry.getBundleSymbolicName());
      message.append(" ");
      message.append("|");
      message.append(" ");
      message.append(encodeText(entry.getOptionPath()));
      message.append(" ");
      message.append("|");
      message.append(" ");
      message.append(entry.getClassName());
      message.append(" ");
      message.append("|");
      message.append(" ");
      message.append(entry.getMethodName());
      message.append(" ");
      message.append("|");
      message.append(" ");
      message.append(entry.getLineNumber());
      message.append(" ");
      message.append("|");
      message.append(" ");
      message.append(encodeText(entry.getMessage()));
    }
    if (entry.getThrowable() != null)
    {
      message.append(" ");
      message.append("|");
      message.append(" ");
      message.append(getFormattedThrowable(entry.getThrowable()));
    }
    message.append(" ");
    message.append("|");
    message.append(LINE_SEPARATOR);
    if ((traceWriter != null) && (message != null)) {
      traceWriter.write(message.toString());
    }
  }
  
  private static String encodeText(String inputString)
  {
    if ((inputString == null) || (inputString.indexOf("|") < 0)) {
      return inputString;
    }
    StringBuffer tempBuffer = new StringBuffer(inputString);
    int currentIndex = tempBuffer.indexOf("|");
    while (currentIndex >= 0)
    {
      tempBuffer.replace(currentIndex, currentIndex + "|".length(), "&#124;");
      currentIndex = tempBuffer.indexOf("|");
    }
    return tempBuffer.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 Writer openWriter(File traceFile)
  {
    Writer traceWriter = null;
    if (traceFile != null) {
      try
      {
        traceWriter = logForStream(secureAction.getFileOutputStream(traceFile, true));
      }
      catch (IOException localIOException)
      {
        traceWriter = logForStream(System.out);
      }
    } else {
      traceWriter = logForStream(System.out);
    }
    return traceWriter;
  }
  
  private void closeWriter(Writer traceWriter)
  {
    if (traceWriter != null)
    {
      try
      {
        traceWriter.close();
      }
      catch (IOException ioEx)
      {
        ioEx.printStackTrace();
      }
      traceWriter = null;
    }
  }
}

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

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
import org.eclipse.osgi.framework.internal.core.FrameworkProperties;
import org.eclipse.osgi.service.debug.DebugOptions;
import org.eclipse.osgi.service.debug.DebugOptionsListener;
import org.eclipse.osgi.service.debug.DebugTrace;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.ServiceTracker;
import org.osgi.util.tracker.ServiceTrackerCustomizer;

public class FrameworkDebugOptions
  implements DebugOptions, ServiceTrackerCustomizer<DebugOptionsListener, DebugOptionsListener>
{
  private static final String OSGI_DEBUG = "osgi.debug";
  private static final String OSGI_DEBUG_VERBOSE = "osgi.debug.verbose";
  public static final String PROP_TRACEFILE = "osgi.tracefile";
  private final Object lock;
  private Properties options;
  private Properties disabledOptions;
  private static FrameworkDebugOptions singleton = null;
  private static final String OPTIONS = ".options";
  protected static final Map<String, DebugTrace> debugTraceCache = new HashMap();
  protected File outFile;
  protected boolean verboseDebug;
  private volatile BundleContext context;
  private volatile ServiceTracker<DebugOptionsListener, DebugOptionsListener> listenerTracker;
  
  /* Error */
  private FrameworkDebugOptions()
  {
    // Byte code:
    //   0: aload_0
    //   1: invokespecial 469	java/lang/Object:<init>	()V
    //   4: aload_0
    //   5: new 244	java/lang/Object
    //   8: dup
    //   9: invokespecial 469	java/lang/Object:<init>	()V
    //   12: putfield 445	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:lock	Ljava/lang/Object;
    //   15: aload_0
    //   16: aconst_null
    //   17: putfield 448	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:options	Ljava/util/Properties;
    //   20: aload_0
    //   21: aconst_null
    //   22: putfield 447	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:disabledOptions	Ljava/util/Properties;
    //   25: aload_0
    //   26: aconst_null
    //   27: putfield 443	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:outFile	Ljava/io/File;
    //   30: aload_0
    //   31: iconst_1
    //   32: putfield 442	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:verboseDebug	Z
    //   35: aload_0
    //   36: ldc 10
    //   38: getstatic 439	java/lang/Boolean:TRUE	Ljava/lang/Boolean;
    //   41: invokevirtual 462	java/lang/Boolean:toString	()Ljava/lang/String;
    //   44: invokestatic 520	org/eclipse/osgi/framework/internal/core/FrameworkProperties:getProperty	(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    //   47: invokestatic 463	java/lang/Boolean:valueOf	(Ljava/lang/String;)Ljava/lang/Boolean;
    //   50: invokevirtual 461	java/lang/Boolean:booleanValue	()Z
    //   53: putfield 442	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:verboseDebug	Z
    //   56: ldc 9
    //   58: invokestatic 519	org/eclipse/osgi/framework/internal/core/FrameworkProperties:getProperty	(Ljava/lang/String;)Ljava/lang/String;
    //   61: astore_1
    //   62: aload_1
    //   63: ifnonnull +4 -> 67
    //   66: return
    //   67: aload_0
    //   68: new 256	java/util/Properties
    //   71: dup
    //   72: invokespecial 496	java/util/Properties:<init>	()V
    //   75: putfield 448	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:options	Ljava/util/Properties;
    //   78: aload_1
    //   79: invokevirtual 471	java/lang/String:length	()I
    //   82: ifne +60 -> 142
    //   85: ldc 12
    //   87: invokestatic 519	org/eclipse/osgi/framework/internal/core/FrameworkProperties:getProperty	(Ljava/lang/String;)Ljava/lang/String;
    //   90: getstatic 438	java/io/File:separatorChar	C
    //   93: bipush 47
    //   95: invokevirtual 474	java/lang/String:replace	(CC)Ljava/lang/String;
    //   98: astore_3
    //   99: aload_3
    //   100: ldc 5
    //   102: invokevirtual 478	java/lang/String:endsWith	(Ljava/lang/String;)Z
    //   105: ifne +23 -> 128
    //   108: new 246	java/lang/StringBuffer
    //   111: dup
    //   112: aload_3
    //   113: invokestatic 481	java/lang/String:valueOf	(Ljava/lang/Object;)Ljava/lang/String;
    //   116: invokespecial 483	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   119: ldc 5
    //   121: invokevirtual 484	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   124: invokevirtual 482	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   127: astore_3
    //   128: new 232	java/io/File
    //   131: dup
    //   132: aload_3
    //   133: ldc 4
    //   135: invokespecial 456	java/io/File:<init>	(Ljava/lang/String;Ljava/lang/String;)V
    //   138: invokevirtual 453	java/io/File:toString	()Ljava/lang/String;
    //   141: astore_1
    //   142: aload_1
    //   143: iconst_0
    //   144: invokestatic 511	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:buildURL	(Ljava/lang/String;Z)Ljava/net/URL;
    //   147: astore_2
    //   148: aload_2
    //   149: ifnonnull +26 -> 175
    //   152: getstatic 440	java/lang/System:out	Ljava/io/PrintStream;
    //   155: new 246	java/lang/StringBuffer
    //   158: dup
    //   159: ldc 7
    //   161: invokespecial 483	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   164: aload_1
    //   165: invokevirtual 484	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   168: invokevirtual 482	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   171: invokevirtual 460	java/io/PrintStream:println	(Ljava/lang/String;)V
    //   174: return
    //   175: getstatic 440	java/lang/System:out	Ljava/io/PrintStream;
    //   178: new 246	java/lang/StringBuffer
    //   181: dup
    //   182: ldc 6
    //   184: invokespecial 483	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   187: aload_2
    //   188: invokevirtual 490	java/net/URL:toExternalForm	()Ljava/lang/String;
    //   191: invokevirtual 484	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   194: invokevirtual 482	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   197: invokevirtual 459	java/io/PrintStream:print	(Ljava/lang/String;)V
    //   200: aload_2
    //   201: invokevirtual 486	java/net/URL:openStream	()Ljava/io/InputStream;
    //   204: astore_3
    //   205: aload_0
    //   206: getfield 448	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:options	Ljava/util/Properties;
    //   209: aload_3
    //   210: invokevirtual 497	java/util/Properties:load	(Ljava/io/InputStream;)V
    //   213: getstatic 440	java/lang/System:out	Ljava/io/PrintStream;
    //   216: ldc 2
    //   218: invokevirtual 460	java/io/PrintStream:println	(Ljava/lang/String;)V
    //   221: goto +12 -> 233
    //   224: astore 4
    //   226: aload_3
    //   227: invokevirtual 458	java/io/InputStream:close	()V
    //   230: aload 4
    //   232: athrow
    //   233: aload_3
    //   234: invokevirtual 458	java/io/InputStream:close	()V
    //   237: goto +31 -> 268
    //   240: pop
    //   241: getstatic 440	java/lang/System:out	Ljava/io/PrintStream;
    //   244: ldc 3
    //   246: invokevirtual 460	java/io/PrintStream:println	(Ljava/lang/String;)V
    //   249: goto +19 -> 268
    //   252: astore_3
    //   253: getstatic 440	java/lang/System:out	Ljava/io/PrintStream;
    //   256: ldc 1
    //   258: invokevirtual 460	java/io/PrintStream:println	(Ljava/lang/String;)V
    //   261: aload_3
    //   262: getstatic 440	java/lang/System:out	Ljava/io/PrintStream;
    //   265: invokevirtual 457	java/io/IOException:printStackTrace	(Ljava/io/PrintStream;)V
    //   268: aload_0
    //   269: getfield 448	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:options	Ljava/util/Properties;
    //   272: invokevirtual 500	java/util/Properties:keySet	()Ljava/util/Set;
    //   275: invokeinterface 534 1 0
    //   280: astore 4
    //   282: goto +34 -> 316
    //   285: aload 4
    //   287: invokeinterface 526 1 0
    //   292: astore_3
    //   293: aload_0
    //   294: getfield 448	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:options	Ljava/util/Properties;
    //   297: aload_3
    //   298: aload_0
    //   299: getfield 448	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:options	Ljava/util/Properties;
    //   302: aload_3
    //   303: invokevirtual 501	java/util/Properties:get	(Ljava/lang/Object;)Ljava/lang/Object;
    //   306: checkcast 245	java/lang/String
    //   309: invokevirtual 473	java/lang/String:trim	()Ljava/lang/String;
    //   312: invokevirtual 504	java/util/Properties:put	(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    //   315: pop
    //   316: aload 4
    //   318: invokeinterface 525 1 0
    //   323: ifne -38 -> 285
    //   326: return
    // Line number table:
    //   Java source line #57	-> byte code offset #0
    //   Java source line #36	-> byte code offset #4
    //   Java source line #38	-> byte code offset #15
    //   Java source line #40	-> byte code offset #20
    //   Java source line #48	-> byte code offset #25
    //   Java source line #50	-> byte code offset #30
    //   Java source line #59	-> byte code offset #35
    //   Java source line #63	-> byte code offset #56
    //   Java source line #64	-> byte code offset #62
    //   Java source line #65	-> byte code offset #66
    //   Java source line #66	-> byte code offset #67
    //   Java source line #68	-> byte code offset #78
    //   Java source line #72	-> byte code offset #85
    //   Java source line #73	-> byte code offset #99
    //   Java source line #74	-> byte code offset #108
    //   Java source line #75	-> byte code offset #128
    //   Java source line #77	-> byte code offset #142
    //   Java source line #78	-> byte code offset #148
    //   Java source line #79	-> byte code offset #152
    //   Java source line #80	-> byte code offset #174
    //   Java source line #82	-> byte code offset #175
    //   Java source line #84	-> byte code offset #200
    //   Java source line #86	-> byte code offset #205
    //   Java source line #87	-> byte code offset #213
    //   Java source line #88	-> byte code offset #224
    //   Java source line #89	-> byte code offset #226
    //   Java source line #90	-> byte code offset #230
    //   Java source line #89	-> byte code offset #233
    //   Java source line #91	-> byte code offset #240
    //   Java source line #92	-> byte code offset #241
    //   Java source line #93	-> byte code offset #252
    //   Java source line #94	-> byte code offset #253
    //   Java source line #95	-> byte code offset #261
    //   Java source line #98	-> byte code offset #268
    //   Java source line #99	-> byte code offset #293
    //   Java source line #98	-> byte code offset #316
    //   Java source line #101	-> byte code offset #326
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	327	0	this	FrameworkDebugOptions
    //   61	104	1	debugOptionsFilename	String
    //   147	54	2	optionsFile	URL
    //   98	35	3	userDir	String
    //   204	30	3	input	java.io.InputStream
    //   252	10	3	e	java.io.IOException
    //   292	11	3	key	Object
    //   224	7	4	localObject1	Object
    //   280	37	4	localIterator	Iterator
    //   240	1	9	localFileNotFoundException	java.io.FileNotFoundException
    // Exception table:
    //   from	to	target	type
    //   205	224	224	finally
    //   200	237	240	java/io/FileNotFoundException
    //   200	237	252	java/io/IOException
  }
  
  public void start(BundleContext bc)
  {
    context = bc;
    listenerTracker = new ServiceTracker(bc, DebugOptionsListener.class.getName(), this);
    listenerTracker.open();
  }
  
  public void stop(BundleContext bc)
  {
    listenerTracker.close();
    listenerTracker = null;
    context = null;
  }
  
  public static FrameworkDebugOptions getDefault()
  {
    if (singleton == null) {
      singleton = new FrameworkDebugOptions();
    }
    return singleton;
  }
  
  private 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);
  }
  
  public boolean getBooleanOption(String option, boolean defaultValue)
  {
    String optionValue = getOption(option);
    return optionValue != null ? optionValue.equalsIgnoreCase("true") : defaultValue;
  }
  
  public String getOption(String option)
  {
    return getOption(option, null);
  }
  
  public String getOption(String option, String defaultValue)
  {
    synchronized (lock)
    {
      if (options != null) {
        return options.getProperty(option, defaultValue);
      }
    }
    return defaultValue;
  }
  
  public int getIntegerOption(String option, int defaultValue)
  {
    String value = getOption(option);
    try
    {
      return value == null ? defaultValue : Integer.parseInt(value);
    }
    catch (NumberFormatException localNumberFormatException) {}
    return defaultValue;
  }
  
  public Map<String, String> getOptions()
  {
    Map<String, String> snapShot = new HashMap();
    synchronized (lock)
    {
      if (options != null) {
        snapShot.putAll(options);
      } else if (disabledOptions != null) {
        snapShot.putAll(disabledOptions);
      }
    }
    return snapShot;
  }
  
  String[] getAllOptions()
  {
    String[] optionsArray = (String[])null;
    synchronized (lock)
    {
      if (options != null)
      {
        optionsArray = new String[options.size()];
        Iterator<Map.Entry<Object, Object>> entrySetIterator = options.entrySet().iterator();
        int i = 0;
        while (entrySetIterator.hasNext())
        {
          Map.Entry<Object, Object> entry = (Map.Entry)entrySetIterator.next();
          optionsArray[i] = ((String)entry.getKey() + "=" + (String)entry.getValue());
          i++;
        }
      }
    }
    if (optionsArray == null) {
      optionsArray = new String[1];
    }
    return optionsArray;
  }
  
  public void removeOption(String option)
  {
    if (option == null) {
      return;
    }
    String fireChangedEvent = null;
    synchronized (lock)
    {
      if ((options != null) && (options.remove(option) != null)) {
        fireChangedEvent = getSymbolicName(option);
      }
    }
    if (fireChangedEvent != null) {
      optionsChanged(fireChangedEvent);
    }
  }
  
  public void setOption(String option, String value)
  {
    if ((option == null) || (value == null)) {
      throw new IllegalArgumentException("The option and value must not be null.");
    }
    String fireChangedEvent = null;
    value = value != null ? value.trim() : null;
    synchronized (lock)
    {
      if (options != null)
      {
        String currentValue = options.getProperty(option);
        if (currentValue != null)
        {
          if (!currentValue.equals(value)) {
            fireChangedEvent = getSymbolicName(option);
          }
        }
        else if (value != null) {
          fireChangedEvent = getSymbolicName(option);
        }
        if (fireChangedEvent != null) {
          options.put(option, value);
        }
      }
    }
    if (fireChangedEvent != null) {
      optionsChanged(fireChangedEvent);
    }
  }
  
  private String getSymbolicName(String option)
  {
    int firstSlashIndex = option.indexOf("/");
    if (firstSlashIndex > 0) {
      return option.substring(0, firstSlashIndex);
    }
    return null;
  }
  
  public void setOptions(Map<String, String> ops)
  {
    if (ops == null) {
      throw new IllegalArgumentException("The options must not be null.");
    }
    Properties newOptions = new Properties();
    for (Iterator<Map.Entry<String, String>> entries = ops.entrySet().iterator(); entries.hasNext();)
    {
      Map.Entry<String, String> entry = (Map.Entry)entries.next();
      if ((!(entry.getKey() instanceof String)) || (!(entry.getValue() instanceof String))) {
        throw new IllegalArgumentException("Option keys and values must be of type String: " + (String)entry.getKey() + "=" + (String)entry.getValue());
      }
      newOptions.put(entry.getKey(), ((String)entry.getValue()).trim());
    }
    Set<String> fireChangesTo = null;
    synchronized (lock)
    {
      if (options == null)
      {
        disabledOptions = newOptions;
        
        return;
      }
      fireChangesTo = new HashSet();
      for (Iterator<Object> keys = options.keySet().iterator(); keys.hasNext();)
      {
        String key = (String)keys.next();
        if (!newOptions.containsKey(key))
        {
          String symbolicName = getSymbolicName(key);
          if (symbolicName != null) {
            fireChangesTo.add(symbolicName);
          }
        }
      }
      for (Iterator<Map.Entry<Object, Object>> newEntries = newOptions.entrySet().iterator(); newEntries.hasNext();)
      {
        Map.Entry<Object, Object> entry = (Map.Entry)newEntries.next();
        String existingValue = (String)options.get(entry.getKey());
        if (!entry.getValue().equals(existingValue))
        {
          String symbolicName = getSymbolicName((String)entry.getKey());
          if (symbolicName != null) {
            fireChangesTo.add(symbolicName);
          }
        }
      }
      options = newOptions;
    }
    if (fireChangesTo != null) {
      for (Iterator<String> iChanges = fireChangesTo.iterator(); iChanges.hasNext();) {
        optionsChanged((String)iChanges.next());
      }
    }
  }
  
  public boolean isDebugEnabled()
  {
    synchronized (lock)
    {
      return options != null;
    }
  }
  
  public void setDebugEnabled(boolean enabled)
  {
    boolean fireChangedEvent = false;
    synchronized (lock)
    {
      if (enabled)
      {
        if (options != null) {
          return;
        }
        EclipseDebugTrace.newSession = true;
        
        FrameworkProperties.setProperty("osgi.debug", "");
        if (disabledOptions != null)
        {
          options = disabledOptions;
          disabledOptions = null;
          
          fireChangedEvent = true;
        }
        else
        {
          options = new Properties();
        }
      }
      else
      {
        if (options == null) {
          return;
        }
        FrameworkProperties.clearProperty("osgi.debug");
        if (options.size() > 0)
        {
          disabledOptions = options;
          
          fireChangedEvent = true;
        }
        options = null;
      }
    }
    if (fireChangedEvent) {
      optionsChanged("*");
    }
  }
  
  public final DebugTrace newDebugTrace(String bundleSymbolicName)
  {
    return newDebugTrace(bundleSymbolicName, null);
  }
  
  public final DebugTrace newDebugTrace(String bundleSymbolicName, Class<?> traceEntryClass)
  {
    DebugTrace debugTrace = null;
    synchronized (debugTraceCache)
    {
      debugTrace = (DebugTrace)debugTraceCache.get(bundleSymbolicName);
      if (debugTrace == null)
      {
        debugTrace = new EclipseDebugTrace(bundleSymbolicName, singleton, traceEntryClass);
        debugTraceCache.put(bundleSymbolicName, debugTrace);
      }
    }
    return debugTrace;
  }
  
  public final File getFile()
  {
    return outFile;
  }
  
  public synchronized void setFile(File traceFile)
  {
    outFile = traceFile;
    FrameworkProperties.setProperty("osgi.tracefile", outFile.getAbsolutePath());
    
    EclipseDebugTrace.newSession = true;
  }
  
  boolean isVerbose()
  {
    return verboseDebug;
  }
  
  public synchronized void setVerbose(boolean verbose)
  {
    verboseDebug = verbose;
    
    EclipseDebugTrace.newSession = true;
  }
  
  /* Error */
  private void optionsChanged(String bundleSymbolicName)
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 450	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:context	Lorg/osgi/framework/BundleContext;
    //   4: astore_2
    //   5: aload_2
    //   6: ifnonnull +4 -> 10
    //   9: return
    //   10: aconst_null
    //   11: checkcast 231	[Lorg/osgi/framework/ServiceReference;
    //   14: astore_3
    //   15: aload_2
    //   16: getstatic 444	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:class$0	Ljava/lang/Class;
    //   19: dup
    //   20: ifnonnull +28 -> 48
    //   23: pop
    //   24: ldc 8
    //   26: invokestatic 465	java/lang/Class:forName	(Ljava/lang/String;)Ljava/lang/Class;
    //   29: dup
    //   30: putstatic 444	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:class$0	Ljava/lang/Class;
    //   33: goto +15 -> 48
    //   36: new 242	java/lang/NoClassDefFoundError
    //   39: dup_x1
    //   40: swap
    //   41: invokevirtual 485	java/lang/Throwable:getMessage	()Ljava/lang/String;
    //   44: invokespecial 468	java/lang/NoClassDefFoundError:<init>	(Ljava/lang/String;)V
    //   47: athrow
    //   48: invokevirtual 464	java/lang/Class:getName	()Ljava/lang/String;
    //   51: new 246	java/lang/StringBuffer
    //   54: dup
    //   55: ldc_w 221
    //   58: invokespecial 483	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   61: aload_1
    //   62: invokevirtual 484	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   65: ldc_w 222
    //   68: invokevirtual 484	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   71: invokevirtual 482	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   74: invokeinterface 538 3 0
    //   79: astore_3
    //   80: goto +4 -> 84
    //   83: pop
    //   84: aload_3
    //   85: ifnonnull +4 -> 89
    //   88: return
    //   89: iconst_0
    //   90: istore 4
    //   92: goto +82 -> 174
    //   95: aload_2
    //   96: aload_3
    //   97: iload 4
    //   99: aaload
    //   100: invokeinterface 537 2 0
    //   105: checkcast 262	org/eclipse/osgi/service/debug/DebugOptionsListener
    //   108: astore 5
    //   110: aload 5
    //   112: ifnonnull +6 -> 118
    //   115: goto +56 -> 171
    //   118: aload 5
    //   120: aload_0
    //   121: invokeinterface 535 2 0
    //   126: goto +34 -> 160
    //   129: pop
    //   130: aload_2
    //   131: aload_3
    //   132: iload 4
    //   134: aaload
    //   135: invokeinterface 536 2 0
    //   140: pop
    //   141: goto +30 -> 171
    //   144: astore 6
    //   146: aload_2
    //   147: aload_3
    //   148: iload 4
    //   150: aaload
    //   151: invokeinterface 536 2 0
    //   156: pop
    //   157: aload 6
    //   159: athrow
    //   160: aload_2
    //   161: aload_3
    //   162: iload 4
    //   164: aaload
    //   165: invokeinterface 536 2 0
    //   170: pop
    //   171: iinc 4 1
    //   174: iload 4
    //   176: aload_3
    //   177: arraylength
    //   178: if_icmplt -83 -> 95
    //   181: return
    // Line number table:
    //   Java source line #468	-> byte code offset #0
    //   Java source line #469	-> byte code offset #5
    //   Java source line #470	-> byte code offset #9
    //   Java source line #473	-> byte code offset #10
    //   Java source line #475	-> byte code offset #15
    //   Java source line #476	-> byte code offset #83
    //   Java source line #479	-> byte code offset #84
    //   Java source line #480	-> byte code offset #88
    //   Java source line #481	-> byte code offset #89
    //   Java source line #482	-> byte code offset #95
    //   Java source line #483	-> byte code offset #110
    //   Java source line #484	-> byte code offset #115
    //   Java source line #486	-> byte code offset #118
    //   Java source line #487	-> byte code offset #129
    //   Java source line #490	-> byte code offset #130
    //   Java source line #489	-> byte code offset #144
    //   Java source line #490	-> byte code offset #146
    //   Java source line #491	-> byte code offset #157
    //   Java source line #490	-> byte code offset #160
    //   Java source line #481	-> byte code offset #171
    //   Java source line #493	-> byte code offset #181
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	182	0	this	FrameworkDebugOptions
    //   0	182	1	bundleSymbolicName	String
    //   4	157	2	bc	BundleContext
    //   14	163	3	listenerRefs	ServiceReference[]
    //   90	85	4	i	int
    //   108	11	5	service	DebugOptionsListener
    //   144	14	6	localObject	Object
    //   36	1	7	localClassNotFoundException	ClassNotFoundException
    //   83	1	8	localInvalidSyntaxException	org.osgi.framework.InvalidSyntaxException
    //   129	1	9	localThrowable	Throwable
    // Exception table:
    //   from	to	target	type
    //   24	29	36	java/lang/ClassNotFoundException
    //   15	80	83	org/osgi/framework/InvalidSyntaxException
    //   118	126	129	java/lang/Throwable
    //   118	130	144	finally
  }
  
  public DebugOptionsListener addingService(ServiceReference<DebugOptionsListener> reference)
  {
    DebugOptionsListener listener = (DebugOptionsListener)context.getService(reference);
    listener.optionsChanged(this);
    return listener;
  }
  
  public void modifiedService(ServiceReference<DebugOptionsListener> reference, DebugOptionsListener service) {}
  
  public void removedService(ServiceReference<DebugOptionsListener> reference, DebugOptionsListener service)
  {
    context.ungetService(reference);
  }
}

/* Location:
 * Qualified Name:  
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84

Further reading...

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

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd