org.eclipse.osgi_3.7.2.v20120110-1415

c void postFindLocalClass(String name, Class<?> clazz, ClasspathManager manager)
    throws ClassNotFoundException
  {
    List<Object> stack = (List)activationStack.get();
    if (stack == null) {
      return;
    }
    int size = stack.size();
    if ((size <= 1) || (stack.get(0) != name)) {
      return;
    }
    ClasspathManager[] managers = (ClasspathManager[])null;
    managers = new ClasspathManager[size - 1];
    for (int i = 1; i < size; i++) {
      managers[(i - 1)] = ((ClasspathManager)stack.get(i));
    }
    stack.clear();
    if (clazz == null) {
      return;
    }
    for (int i = managers.length - 1; i >= 0; i--) {
      if (errors.get(managers[i]) != null)
      {
        if (throwErrorOnFailedStart) {
          throw ((TerminatingClassNotFoundException)errors.get(managers[i]));
        }
      }
      else
      {
        long startTime = System.currentTimeMillis();
        try
        {
          managers[i].getBaseClassLoader().getDelegate().setLazyTrigger();
        }
        catch (BundleException e)
        {
          Bundle bundle = managers[i].getBaseData().getBundle();
          Throwable cause = e.getCause();
          if ((cause != null) && ((cause instanceof StatusException)))
          {
            StatusException status = (StatusException)cause;
            if ((status.getStatusCode() & 0x8) == 0)
            {
              if (!(status.getStatus() instanceof Thread)) {
                continue;
              }
              String message = NLS.bind(EclipseAdaptorMsg.ECLIPSE_CLASSLOADER_CONCURRENT_STARTUP, new Object[] { Thread.currentThread(), name, status.getStatus(), bundle, new Long(System.currentTimeMillis() - startTime) });
              adaptor.getFrameworkLog().log(new FrameworkLogEntry("org.eclipse.osgi", 2, 0, message, 0, e, null));
              
              continue;
            }
          }
          String message = NLS.bind(EclipseAdaptorMsg.ECLIPSE_CLASSLOADER_ACTIVATION, bundle.getSymbolicName(), Long.toString(bundle.getBundleId()));
          TerminatingClassNotFoundException error = new TerminatingClassNotFoundException(message, e);
          errors.put(managers[i], error);
          if (throwErrorOnFailedStart)
          {
            adaptor.getFrameworkLog().log(new FrameworkLogEntry("org.eclipse.osgi", 4, 0, message, 0, e, null));
            throw error;
          }
          adaptor.getEventPublisher().publishFrameworkEvent(2, bundle, new BundleException(message, e));
        }
      }
    }
  }
  
  public void preFindLocalResource(String name, ClasspathManager manager) {}
  
  public void postFindLocalResource(String name, URL resource, ClasspathManager manager) {}
  
  public void recordClassDefine(String name, Class<?> clazz, byte[] classbytes, ClasspathEntry classpathEntry, BundleEntry entry, ClasspathManager manager) {}
  
  private boolean shouldActivateFor(String className, BaseData bundledata, EclipseStorageHook storageHook, ClasspathManager manager)
    throws ClassNotFoundException
  {
    if (!isLazyStartable(className, bundledata, storageHook)) {
      return false;
    }
    if (bundledata.getBundle().getState() == 4)
    {
      if (throwErrorOnFailedStart)
      {
        TerminatingClassNotFoundException error = (TerminatingClassNotFoundException)errors.get(manager);
        if (error != null) {
          throw error;
        }
      }
      return (bundledata.getStatus() & 0x1) != 0;
    }
    return true;
  }
  
  private boolean isLazyStartable(String className, BaseData bundledata, EclipseStorageHook storageHook)
  {
    if (storageHook == null) {
      return false;
    }
    boolean lazyStart = storageHook.isLazyStart();
    String[] excludes = storageHook.getLazyStartExcludes();
    String[] includes = storageHook.getLazyStartIncludes();
    if ((excludes == null) && (includes == null)) {
      return lazyStart;
    }
    int dotPosition = className.lastIndexOf('.');
    if (dotPosition == -1) {
      return lazyStart;
    }
    String packageName = className.substring(0, dotPosition);
    if (lazyStart) {
      return ((includes == null) || (contains(includes, packageName))) && ((excludes == null) || (!contains(excludes, packageName)));
    }
    return (excludes != null) && (contains(excludes, packageName));
  }
  
  private boolean contains(String[] array, String element)
  {
    for (int i = 0; i < array.length; i++) {
      if (array[i].equals(element)) {
        return true;
      }
    }
    return false;
  }
  
  public void addHooks(HookRegistry hookRegistry)
  {
    hookRegistry.addClassLoadingStatsHook(this);
    hookRegistry.addAdaptorHook(this);
  }
  
  public void addProperties(Properties properties) {}
  
  public FrameworkLog createFrameworkLog()
  {
    return null;
  }
  
  public void frameworkStart(BundleContext context)
    throws BundleException
  {}
  
  public void frameworkStop(BundleContext context)
    throws BundleException
  {}
  
  public void frameworkStopping(BundleContext context)
  {
    if (!Debug.DEBUG_ENABLED) {
      return;
    }
    BundleDescription[] allBundles = adaptor.getState().getResolvedBundles();
    StateHelper stateHelper = adaptor.getPlatformAdmin().getStateHelper();
    Object[][] cycles = stateHelper.sortBundles(allBundles);
    logCycles(cycles);
  }
  
  public void handleRuntimeError(Throwable error) {}
  
  public void initialize(BaseAdaptor baseAdaptor)
  {
    adaptor = baseAdaptor;
  }
  
  public URLConnection mapLocationToURLConnection(String location)
    throws IOException
  {
    return null;
  }
  
  private void logCycles(Object[][] cycles)
  {
    if (cycles.length > 0)
    {
      StringBuffer cycleText = new StringBuffer("[");
      for (int i = 0; i < cycles.length; i++)
      {
        cycleText.append('[');
        for (int j = 0; j < cycles[i].length; j++)
        {
          cycleText.append(((BundleDescription)cycles[i][j]).getSymbolicName());
          cycleText.append(',');
        }
        cycleText.insert(cycleText.length() - 1, ']');
      }
      cycleText.setCharAt(cycleText.length() - 1, ']');
      String message = NLS.bind(EclipseAdaptorMsg.ECLIPSE_BUNDLESTOPPER_CYCLES_FOUND, cycleText);
      FrameworkLogEntry entry = new FrameworkLogEntry("org.eclipse.osgi", 2, 0, message, 0, null, null);
      adaptor.getFrameworkLog().log(entry);
    }
  }
  
  private static class TerminatingClassNotFoundException
    extends ClassNotFoundException
    implements StatusException
  {
    private static final long serialVersionUID = -6730732895632169173L;
    private Object cause;
    
    public TerminatingClassNotFoundException(String message, Throwable cause)
    {
      super(cause);
      this.cause = cause;
    }
    
    public Object getStatus()
    {
      return cause;
    }
    
    public int getStatusCode()
    {
      return 8;
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter
 * 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.Writer;
import org.eclipse.equinox.log.Logger;
import org.eclipse.osgi.framework.log.FrameworkLog;
import org.eclipse.osgi.framework.log.FrameworkLogEntry;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkEvent;

class EclipseLogFactory$1
  implements FrameworkLog
{
  final EclipseLogFactory this$0;
  
  EclipseLogFactory$1(EclipseLogFactory paramEclipseLogFactory, EclipseLogWriter paramEclipseLogWriter, Logger paramLogger) {}
  
  public void setWriter(Writer newWriter, boolean append)
  {
    val$logWriter.setWriter(newWriter, append);
  }
  
  public void setFile(File newFile, boolean append)
    throws IOException
  {
    val$logWriter.setFile(newFile, append);
  }
  
  public void setConsoleLog(boolean consoleLog)
  {
    val$logWriter.setConsoleLog(consoleLog);
  }
  
  public void log(FrameworkLogEntry logEntry)
  {
    val$logger.log(logEntry, EclipseLogFactory.convertLevel(logEntry), logEntry.getMessage(), logEntry.getThrowable());
  }
  
  public void log(FrameworkEvent frameworkEvent)
  {
    Bundle b = frameworkEvent.getBundle();
    Throwable t = frameworkEvent.getThrowable();
    String entry = b.getSymbolicName() == null ? b.getLocation() : b.getSymbolicName();
    int severity;
    int severity;
    int severity;
    int severity;
    switch (frameworkEvent.getType())
    {
    case 32: 
      severity = 1;
      break;
    case 2: 
      severity = 4;
      break;
    case 16: 
      severity = 2;
      break;
    default: 
      severity = 0;
    }
    FrameworkLogEntry logEntry = new FrameworkLogEntry(entry, severity, 0, "", 0, t, null);
    log(logEntry);
  }
  
  public File getFile()
  {
    return val$logWriter.getFile();
  }
  
  public void close()
  {
    val$logWriter.close();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.core.runtime.internal.adaptor.EclipseLogFactory.1
 * 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.Writer;
import org.eclipse.equinox.log.ExtendedLogService;
import org.eclipse.equinox.log.Logger;
import org.eclipse.equinox.log.internal.LogServiceManager;
import org.eclipse.osgi.framework.log.FrameworkLog;
import org.eclipse.osgi.framework.log.FrameworkLogEntry;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.ServiceFactory;
import org.osgi.framework.ServiceRegistration;

public class EclipseLogFactory
  implements ServiceFactory<FrameworkLog>
{
  final EclipseLogWriter defaultWriter;
  final LogServiceManager logManager;
  
  public EclipseLogFactory(EclipseLogWriter defaultWriter, LogServiceManager logManager)
  {
    this.defaultWriter = defaultWriter;
    this.logManager = logManager;
  }
  
  public FrameworkLog getService(Bundle bundle, ServiceRegistration<FrameworkLog> registration)
  {
    return createFrameworkLog(bundle, defaultWriter);
  }
  
  FrameworkLog createFrameworkLog(Bundle bundle, EclipseLogWriter eclipseWriter)
  {
    final EclipseLogWriter logWriter = eclipseWriter == null ? defaultWriter : eclipseWriter;
    final Logger logger = bundle == null ? logManager.getSystemBundleLog().getLogger(eclipseWriter.getLoggerName()) : logManager.getSystemBundleLog().getLogger(bundle, logWriter.getLoggerName());
    new FrameworkLog()
    {
      public void setWriter(Writer newWriter, boolean append)
      {
        logWriter.setWriter(newWriter, append);
      }
      
      public void setFile(File newFile, boolean append)
        throws IOException
      {
        logWriter.setFile(newFile, append);
      }
      
      public void setConsoleLog(boolean consoleLog)
      {
        logWriter.setConsoleLog(consoleLog);
      }
      
      public void log(FrameworkLogEntry logEntry)
      {
        logger.log(logEntry, EclipseLogFactory.convertLevel(logEntry), logEntry.getMessage(), logEntry.getThrowable());
      }
      
      public void log(FrameworkEvent frameworkEvent)
      {
        Bundle b = frameworkEvent.getBundle();
        Throwable t = frameworkEvent.getThrowable();
        String entry = b.getSymbolicName() == null ? b.getLocation() : b.getSymbolicName();
        int severity;
        int severity;
        int severity;
        int severity;
        switch (frameworkEvent.getType())
        {
        case 32: 
          severity = 1;
          break;
        case 2: 
          severity = 4;
          break;
        case 16: 
          severity = 2;
          break;
        default: 
          severity = 0;
        }
        FrameworkLogEntry logEntry = new FrameworkLogEntry(entry, severity, 0, "", 0, t, null);
        log(logEntry);
      }
      
      public File getFile()
      {
        return logWriter.getFile();
      }
      
      public void close()
      {
        logWriter.close();
      }
    };
  }
  
  public void ungetService(Bundle bundle, ServiceRegistration<FrameworkLog> registration, FrameworkLog service) {}
  
  static int convertLevel(FrameworkLogEntry logEntry)
  {
    switch (logEntry.getSeverity())
    {
    case 4: 
      return 1;
    case 2: 
      return 2;
    case 1: 
      return 3;
    case 0: 
      return 4;
    }
    return 32;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.core.runtime.internal.adaptor.EclipseLogFactory
 * 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.net.URL;
import java.net.URLConnection;
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.Properties;
import org.eclipse.core.runtime.adaptor.LocationManager;
import org.eclipse.equinox.log.internal.LogServiceManager;
import org.eclipse.osgi.baseadaptor.BaseAdaptor;
import org.eclipse.osgi.baseadaptor.HookConfigurator;
import org.eclipse.osgi.baseadaptor.HookRegistry;
import org.eclipse.osgi.baseadaptor.hooks.AdaptorHook;
import org.eclipse.osgi.framework.internal.core.FrameworkProperties;
import org.eclipse.osgi.framework.log.FrameworkLog;
import org.eclipse.osgi.internal.baseadaptor.AdaptorUtil;
import org.eclipse.osgi.service.datalocation.Location;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.log.LogListener;

public class EclipseLogHook
  implements HookConfigurator, AdaptorHook
{
  static final String EQUINOX_LOGGER_NAME = "org.eclipse.equinox.logger";
  static final String PERF_LOGGER_NAME = "org.eclipse.performance.logger";
  private static final String PROP_LOG_ENABLED = "eclipse.log.enabled";
  private static final String LOG_EXT = ".log";
  private final LogServiceManager logServiceManager;
  private final EclipseLogFactory eclipseLogFactory;
  private final EclipseLogWriter logWriter;
  private final EclipseLogWriter perfWriter;
  private ServiceRegistration<?> frameworkLogReg;
  private ServiceRegistration<?> perfLogReg;
  
  public EclipseLogHook()
  {
    String logFileProp = FrameworkProperties.getProperty("osgi.logfile");
    boolean enabled = "true".equals(FrameworkProperties.getProperty("eclipse.log.enabled", "true"));
    if (logFileProp != null)
    {
      logWriter = new EclipseLogWriter(new File(logFileProp), "org.eclipse.equinox.logger", enabled);
    }
    else
    {
      Location location = LocationManager.getConfigurationLocation();
      File configAreaDirectory = null;
      if (location != null) {
        configAreaDirectory = new File(location.getURL().getFile());
      }
      if (configAreaDirectory != null)
      {
        String logFileName = Long.toString(System.currentTimeMillis()) + ".log";
        File logFile = new File(configAreaDirectory, logFileName);
        FrameworkProperties.setProperty("osgi.logfile", logFile.getAbsolutePath());
        logWriter = new EclipseLogWriter(logFile, "org.eclipse.equinox.logger", enabled);
      }
      else
      {
        logWriter = new EclipseLogWriter(null, "org.eclipse.equinox.logger", enabled);
      }
    }
    File logFile = logWriter.getFile();
    if (logFile != null)
    {
      File perfLogFile = new File(logFile.getParentFile(), "performance.log");
      perfWriter = new EclipseLogWriter(perfLogFile, "org.eclipse.performance.logger", true);
    }
    else
    {
      perfWriter = new EclipseLogWriter(null, "org.eclipse.performance.logger", true);
    }
    if ("true".equals(FrameworkProperties.getProperty("eclipse.consoleLog"))) {
      logWriter.setConsoleLog(true);
    }
    logServiceManager = new LogServiceManager(new LogListener[] { logWriter, perfWriter });
    eclipseLogFactory = new EclipseLogFactory(logWriter, logServiceManager);
  }
  
  public void addHooks(HookRegistry hookRegistry)
  {
    hookRegistry.addAdaptorHook(this);
  }
  
  public void initialize(BaseAdaptor initAdaptor) {}
  
  public void frameworkStart(BundleContext context)
    throws BundleException
  {
    logServiceManager.start(context);
    frameworkLogReg = AdaptorUtil.register(FrameworkLog.class.getName(), eclipseLogFactory, context);
    perfLogReg = registerPerformanceLog(context);
  }
  
  public void frameworkStop(BundleContext context)
    throws BundleException
  {
    frameworkLogReg.unregister();
    perfLogReg.unregister();
    logServiceManager.stop(context);
  }
  
  public void frameworkStopping(BundleContext context) {}
  
  public void addProperties(Properties properties) {}
  
  public URLConnection mapLocationToURLConnection(String location)
    throws IOException
  {
    return null;
  }
  
  public void handleRuntimeError(Throwable error) {}
  
  public FrameworkLog createFrameworkLog()
  {
    return eclipseLogFactory.createFrameworkLog(null, logWriter);
  }
  
  private ServiceRegistration<?> registerPerformanceLog(BundleContext context)
  {
    Object service = createPerformanceLog(context.getBundle());
    String serviceName = FrameworkLog.class.getName();
    Dictionary<String, Object> serviceProperties = new Hashtable(7);
    Dictionary<String, String> headers = context.getBundle().getHeaders();
    
    serviceProperties.put("service.vendor", headers.get("Bundle-Vendor"));
    serviceProperties.put("service.ranking", new Integer(Integer.MIN_VALUE));
    serviceProperties.put("service.pid", context.getBundle().getBundleId() + 46L + service.getClass().getName());
    serviceProperties.put("performance", Boolean.TRUE.toString());
    
    return context.registerService(serviceName, service, serviceProperties);
  }
  
  private FrameworkLog createPerformanceLog(Bundle systemBundle)
  {
    return eclipseLogFactory.createFrameworkLog(systemBundle, perfWriter);
  }
}

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

import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.lang.reflect.InvocationTargetException;
import java.security.AccessController;
import java.util.Calendar;
import java.util.Date;
import org.eclipse.equinox.log.ExtendedLogEntry;
import org.eclipse.equinox.log.LogFilter;
import org.eclipse.equinox.log.SynchronousLogListener;
import org.eclipse.osgi.framework.internal.core.FrameworkProperties;
import org.eclipse.osgi.framework.log.FrameworkLogEntry;
import org.eclipse.osgi.framework.util.SecureAction;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.service.log.LogEntry;

public class EclipseLogWriter
  implements SynchronousLogListener, LogFilter
{
  private static final String PASSWORD = "-password";
  private static final String SESSION = "!SESSION";
  private static final String ENTRY = "!ENTRY";
  private static final String SUBENTRY = "!SUBENTRY";
  private static final String MESSAGE = "!MESSAGE";
  private static final String STACK = "!STACK";
  private static final String LINE_SEPARATOR;
  private static final int DEFAULT_LOG_SIZE = 1000;
  private static final int DEFAULT_LOG_FILES = 10;
  private static final int LOG_SIZE_MIN = 10;
  private static final String PROP_LOG_LEVEL = "eclipse.log.level";
  private static final String PROP_LOG_SIZE_MAX = "eclipse.log.size.max";
  private static final String PROP_LOG_FILE_MAX = "eclipse.log.backup.max";
  private static final String LOG_EXT = ".log";
  private static final String BACKUP_MARK = ".bak_";
  
  static
  {
    String s = System.getProperty("line.separator");
    LINE_SEPARATOR = s == null ? "\n" : s;
  }
  
  private static final SecureAction secureAction = (SecureAction)AccessController.doPrivileged(SecureAction.createSecureAction());
  private boolean consoleLog = false;
  private boolean newSession = true;
  private File outFile;
  private Writer writer;
  private final String loggerName;
  private final boolean enabled;
  int maxLogSize = 1000;
  int maxLogFiles = 10;
  int backupIdx = 0;
  private int logLevel = 0;
  
  public EclipseLogWriter(File outFile, String loggerName, boolean enabled)
  {
    this.outFile = outFile;
    writer = null;
    this.loggerName = loggerName;
    this.enabled = enabled;
    readLogProperties();
  }
  
  public EclipseLogWriter(Writer writer, String loggerName, boolean enabled)
  {
    if (writer == null) {
      this.writer = logForStream(System.err);
    } else {
      this.writer = writer;
    }
    this.loggerName = loggerName;
    this.enabled = enabled;
  }
  
  private Throwable getRoot(Throwable t)
  {
    Throwable root = null;
    if ((t instanceof BundleException)) {
      root = ((BundleException)t).getNestedException();
    }
    if ((t instanceof InvocationTargetException)) {
      root = ((InvocationTargetException)t).getTargetException();
    }
    if (((root instanceof InvocationTargetException)) || ((root instanceof BundleException)))
    {
      Throwable deeplyNested = getRoot(root);
      if (deeplyNested != null) {
        root = deeplyNested;
      }
    }
    return root;
  }
  
  private void writeArgs(String header, String[] args)
    throws IOException
  {
    if ((args == null) || (args.length == 0)) {
      return;
    }
    write(header);
    for (int i = 0; i < args.length; i++) {
      if ((i > 0) && ("-password".equals(args[(i - 1)]))) {
        write(" (omitted)");
      } else {
        write(" " + args[i]);
      }
    }
    writeln();
  }
  
  private String getSessionTimestamp()
  {
    String ts = FrameworkProperties.getProperty("eclipse.startTime");
    if (ts != null) {
      try
      {
        return getDate(new Date(Long.parseLong(ts)));
      }
      catch (NumberFormatException localNumberFormatException) {}
    }
    return getDate(new Date());
  }
  
  private void writeSession()
    throws IOException
  {
    write("!SESSION");
    writeSpace();
    String date = getSessionTimestamp();
    write(date);
    writeSpace();
    for (int i = "!SESSION".length() + date.length(); i < 78; i++) {
      write("-");
    }
    writeln();
    try
    {
      String key = "eclipse.buildId";
      String value = FrameworkProperties.getProperty(key, "unknown");
      writeln(key + "=" + value);
      
      key = "java.fullversion";
      value = System.getProperty(key);
      if (value == null)
      {
        key = "java.version";
        value = System.getProperty(key);
        writeln(key + "=" + value);
        key = "java.vendor";
        value = System.getProperty(key);
        writeln(key + "=" + value);
      }
      else
      {
        writeln(key + "=" + value);
      }
    }
    catch (Exception localException) {}
    write("BootLoader constants: OS=" + EclipseEnvironmentInfo.getDefault().getOS());
    write(", ARCH=" + EclipseEnvironmentInfo.getDefault().getOSArch());
    write(", WS=" + EclipseEnvironmentInfo.getDefault().getWS());
    writeln(", NL=" + EclipseEnvironmentInfo.getDefault().getNL());
    
    writeArgs("Framework arguments: ", EclipseEnvironmentInfo.getDefault().getNonFrameworkArgs());
    writeArgs("Command-line arguments: ", EclipseEnvironmentInfo.getDefault().getCommandLineArgs());
  }
  
  public void close()
  {
    try
    {
      if (writer != null)
      {
        Writer tmpWriter = writer;
        writer = null;
        tmpWriter.close();
      }
    }
    catch (IOException e)
    {
      e.printStackTrace();
    }
  }
  
  private void openFile()
  {
    if (writer == null) {
      if (outFile != null) {
        try
        {
          writer = logForStream(secureAction.getFileOutputStream(outFile, true));
        }
        catch (IOException localIOException)
        {
          writer = logForStream(System.err);
        }
      } else {
        writer = logForStream(System.err);
      }
    }
  }
  
  private void closeFile()
  {
    if ((outFile != null) && 
      (writer != null))
    {
      try
      {
        writer.close();
      }
      catch (IOException e)
      {
        e.printStackTrace();
      }
      writer = null;
    }
  }
  
  /* Error */
  private synchronized void log(FrameworkLogEntry logEntry)
  {
    // Byte code:
    //   0: aload_1
    //   1: ifnonnull +4 -> 5
    //   4: return
    //   5: aload_0
    //   6: aload_1
    //   7: invokevirtual 649	org/eclipse/osgi/framework/log/FrameworkLogEntry:getSeverity	()I
    //   10: invokespecial 627	org/eclipse/core/runtime/internal/adaptor/EclipseLogWriter:isLoggable	(I)Z
    //   13: ifne +4 -> 17
    //   16: return
    //   17: aload_0
    //   18: invokespecial 625	org/eclipse/core/runtime/internal/adaptor/EclipseLogWriter:checkLogFileSize	()Z
    //   21: pop
    //   22: aload_0
    //   23: invokespecial 620	org/eclipse/core/runtime/internal/adaptor/EclipseLogWriter:openFile	()V
    //   26: aload_0
    //   27: getfield 551	org/eclipse/core/runtime/internal/adaptor/EclipseLogWriter:newSession	Z
    //   30: ifeq +12 -> 42
    //   33: aload_0
    //   34: invokespecial 622	org/eclipse/core/runtime/internal/adaptor/EclipseLogWriter:writeSession	()V
    //   37: aload_0
    //   38: iconst_0
    //   39: putfield 551	org/eclipse/core/runtime/internal/adaptor/EclipseLogWriter:newSession	Z
    //   42: aload_0
    //   43: iconst_0
    //   44: aload_1
    //   45: invokespecial 632	org/eclipse/core/runtime/internal/adaptor/EclipseLogWriter:writeLog	(ILorg/eclipse/osgi/framework/log/FrameworkLogEntry;)V
    //   48: aload_0
    //   49: getfield 553	org/eclipse/core/runtime/internal/adaptor/EclipseLogWriter:writer	Ljava/io/Writer;
    //   52: invokevirtual 580	java/io/Writer:flush	()V
    //   55: goto +89 -> 144
    //   58: astore_2
    //   59: getstatic 543	java/lang/System:err	Ljava/io/PrintStream;
    //   62: ldc_w 303
    //   65: invokevirtual 572	java/io/PrintStream:println	(Ljava/lang/String;)V
    //   68: aload_2
    //   69: getstatic 543	java/lang/System:err	Ljava/io/PrintStream;
    //   72: invokevirtual 583	java/lang/Exception:printStackTrace	(Ljava/io/PrintStream;)V
    //   75: getstatic 543	java/lang/System:err	Ljava/io/PrintStream;
    //   78: ldc_w 312
    //   81: invokevirtual 572	java/io/PrintStream:println	(Ljava/lang/String;)V
    //   84: aload_0
    //   85: aload_0
    //   86: getstatic 543	java/lang/System:err	Ljava/io/PrintStream;
    //   89: invokespecial 637	org/eclipse/core/runtime/internal/adaptor/EclipseLogWriter:logForStream	(Ljava/io/OutputStream;)Ljava/io/Writer;
    //   92: putfield 553	org/eclipse/core/runtime/internal/adaptor/EclipseLogWriter:writer	Ljava/io/Writer;
    //   95: aload_0
    //   96: iconst_0
    //   97: aload_1
    //   98: invokespecial 632	org/eclipse/core/runtime/internal/adaptor/EclipseLogWriter:writeLog	(ILorg/eclipse/osgi/framework/log/FrameworkLogEntry;)V
    //   101: aload_0
    //   102: getfield 553	org/eclipse/core/runtime/internal/adaptor/EclipseLogWriter:writer	Ljava/io/Writer;
    //   105: invokevirtual 580	java/io/Writer:flush	()V
    //   108: goto +20 -> 128
    //   111: astore_3
    //   112: getstatic 543	java/lang/System:err	Ljava/io/PrintStream;
    //   115: ldc_w 302
    //   118: invokevirtual 572	java/io/PrintStream:println	(Ljava/lang/String;)V
    //   121: aload_3
    //   122: getstatic 543	java/lang/System:err	Ljava/io/PrintStream;
    //   125: invokevirtual 583	java/lang/Exception:printStackTrace	(Ljava/io/PrintStream;)V
    //   128: aload_0
    //   129: invokespecial 619	org/eclipse/core/runtime/internal/adaptor/EclipseLogWriter:closeFile	()V
    //   132: goto +16 -> 148
    //   135: astore 4
    //   137: aload_0
    //   138: invokespecial 619	org/eclipse/core/runtime/internal/adaptor/EclipseLogWriter:closeFile	()V
    //   141: aload 4
    //   143: athrow
    //   144: aload_0
    //   145: invokespecial 619	org/eclipse/core/runtime/internal/adaptor/EclipseLogWriter:closeFile	()V
    //   148: return
    // Line number table:
    //   Java source line #265	-> byte code offset #0
    //   Java source line #266	-> byte code offset #4
    //   Java source line #267	-> byte code offset #5
    //   Java source line #268	-> byte code offset #16
    //   Java source line #270	-> byte code offset #17
    //   Java source line #271	-> byte code offset #22
    //   Java source line #272	-> byte code offset #26
    //   Java source line #273	-> byte code offset #33
    //   Java source line #274	-> byte code offset #37
    //   Java source line #276	-> byte code offset #42
    //   Java source line #277	-> byte code offset #48
    //   Java source line #278	-> byte code offset #58
    //   Java source line #280	-> byte code offset #59
    //   Java source line #281	-> byte code offset #68
    //   Java source line #282	-> byte code offset #75
    //   Java source line #285	-> byte code offset #84
    //   Java source line #286	-> byte code offset #95
    //   Java source line #287	-> byte code offset #101
    //   Java source line #288	-> byte code offset #111
    //   Java source line #289	-> byte code offset #112
    //   Java source line #290	-> byte code offset #121
    //   Java source line #293	-> byte code offset #128
    //   Java source line #292	-> byte code offset #135
    //   Java source line #293	-> byte code offset #137
    //   Java source line #294	-> byte code offset #141
    //   Java source line #293	-> byte code offset #144
    //   Java source line #295	-> byte code offset #148
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	149	0	this	EclipseLogWriter
    //   0	149	1	logEntry	FrameworkLogEntry
    //   58	11	2	e	Exception
    //   111	11	3	e2	Exception
    //   135	7	4	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   17	55	58	java/lang/Exception
    //   84	108	111	java/lang/Exception
    //   17	128	135	finally
  }
  
  public synchronized void setWriter(Writer newWriter, boolean append)
  {
    setOutput(null, newWriter, append);
  }
  
  public synchronized void setFile(File newFile, boolean append)
    throws IOException
  {
    if ((newFile != null) && (!newFile.equals(outFile)))
    {
      readLogProperties();
      backupIdx = 0;
    }
    setOutput(newFile, null, append);
    FrameworkProperties.setProperty("osgi.logfile", newFile == null ? "" : newFile.getAbsolutePath());
  }
  
  public synchronized File getFile()
  {
    return outFile;
  }
  
  public void setConsoleLog(boolean consoleLog)
  {
    this.consoleLog = consoleLog;
  }
  
  /* Error */
  private void setOutput(File newOutFile, Writer newWriter, boolean append)
  {
    // Byte code:
    //   0: aload_1
    //   1: ifnull +14 -> 15
    //   4: aload_1
    //   5: aload_0
    //   6: getfield 552	org/eclipse/core/runtime/internal/adaptor/EclipseLogWriter:outFile	Ljava/io/File;
    //   9: invokevirtual 562	java/io/File:equals	(Ljava/lang/Object;)Z
    //   12: ifne +231 -> 243
    //   15: aload_0
    //   16: getfield 553	org/eclipse/core/runtime/internal/adaptor/EclipseLogWriter:writer	Ljava/io/Writer;
    //   19: ifnull +25 -> 44
    //   22: aload_0
    //   23: getfield 553	org/eclipse/core/runtime/internal/adaptor/EclipseLogWriter:writer	Ljava/io/Writer;
    //   26: invokevirtual 579	java/io/Writer:close	()V
    //   29: goto +10 -> 39
    //   32: astore 4
    //   34: aload 4
    //   36: invokevirtual 566	java/io/IOException:printStackTrace	()V
    //   39: aload_0
    //   40: aconst_null
    //   41: putfield 553	org/eclipse/core/runtime/internal/adaptor/EclipseLogWriter:writer	Ljava/io/Writer;
    //   44: aload_0
    //   45: getfield 552	org/eclipse/core/runtime/internal/adaptor/EclipseLogWriter:outFile	Ljava/io/File;
    //   48: astore 4
    //   50: aload_0
    //   51: aload_1
    //   52: putfield 552	org/eclipse/core/runtime/internal/adaptor/EclipseLogWriter:outFile	Ljava/io/File;
    //   55: aload_0
    //   56: aload_2
    //   57: putfield 553	org/eclipse/core/runtime/internal/adaptor/EclipseLogWriter:writer	Ljava/io/Writer;
    //   60: iconst_0
    //   61: istore 5
    //   63: iload_3
    //   64: ifeq +179 -> 243
    //   67: aload 4
    //   69: ifnull +174 -> 243
    //   72: aload 4
    //   74: invokevirtual 560	java/io/File:isFile	()Z
    //   77: ifeq +166 -> 243
    //   80: aconst_null
    //   81: astore 6
    //   83: aload_0
    //   84: invokespecial 620	org/eclipse/core/runtime/internal/adaptor/EclipseLogWriter:openFile	()V
    //   87: new 324	java/io/InputStreamReader
    //   90: dup
    //   91: getstatic 556	org/eclipse/core/runtime/internal/adaptor/EclipseLogWriter:secureAction	Lorg/eclipse/osgi/framework/util/SecureAction;
    //   94: aload 4
    //   96: invokevirtual 658	org/eclipse/osgi/framework/util/SecureAction:getFileInputStream	(Ljava/io/File;)Ljava/io/FileInputStream;
    //   99: ldc_w 316
    //   102: invokespecial 568	java/io/InputStreamReader:<init>	(Ljava/io/InputStream;Ljava/lang/String;)V
    //   105: astore 6
    //   107: aload_0
    //   108: aload 6
    //   110: aload_0
    //   111: getfield 553	org/eclipse/core/runtime/internal/adaptor/EclipseLogWriter:writer	Ljava/io/Writer;
    //   114: invokespecial 638	org/eclipse/core/runtime/internal/adaptor/EclipseLogWriter:copyReader	(Ljava/io/Reader;Ljava/io/Writer;)V
    //   117: goto +91 -> 208
    //   120: astore 7
    //   122: iconst_1
    //   123: istore 5
    //   125: aload 7
    //   127: invokevirtual 566	java/io/IOException:printStackTrace	()V
    //   130: aload 6
    //   132: ifnull +29 -> 161
    //   135: aload 6
    //   137: invokevirtual 575	java/io/Reader:close	()V
    //   140: goto +10 -> 150
    //   143: astore 9
    //   145: aload 9
    //   147: invokevirtual 566	java/io/IOException:printStackTrace	()V
    //   150: iload 5
    //   152: ifne +9 -> 161
    //   155: aload 4
    //   157: invokevirtual 558	java/io/File:delete	()Z
    //   160: pop
    //   161: aload_0
    //   162: invokespecial 619	org/eclipse/core/runtime/internal/adaptor/EclipseLogWriter:closeFile	()V
    //   165: goto +78 -> 243
    //   168: astore 8
    //   170: aload 6
    //   172: ifnull +29 -> 201
    //   175: aload 6
    //   177: invokevirtual 575	java/io/Reader:close	()V
    //   180: goto +10 -> 190
    //   183: astore 9
    //   185: aload 9
    //   187: invokevirtual 566	java/io/IOException:printStackTrace	()V
    //   190: iload 5
    //   192: ifne +9 -> 201
    //   195: aload 4
    //   197: invokevirtual 558	java/io/File:delete	()Z
    //   200: pop
    //   201: aload_0
    //   202: invokespecial 619	org/eclipse/core/runtime/internal/adaptor/EclipseLogWriter:closeFile	()V
    //   205: aload 8
    //   207: athrow
    //   208: aload 6
    //   210: ifnull +29 -> 239
    //   213: aload 6
    //   215: invokevirtual 575	java/io/Reader:close	()V
    //   218: goto +10 -> 228
    //   221: astore 9
    //   223: aload 9
    //   225: invokevirtual 566	java/io/IOException:printStackTrace	()V
    //   228: iload 5
    //   230: ifne +9 -> 239
    //   233: aload 4
    //   235: invokevirtual 558	java/io/File:delete	()Z
    //   238: pop
    //   239: aload_0
    //   240: invokespecial 619	org/eclipse/core/runtime/internal/adaptor/EclipseLogWriter:closeFile	()V
    //   243: return
    // Line number table:
    //   Java source line #323	-> byte code offset #0
    //   Java source line #324	-> byte code offset #15
    //   Java source line #326	-> byte code offset #22
    //   Java source line #327	-> byte code offset #32
    //   Java source line #328	-> byte code offset #34
    //   Java source line #330	-> byte code offset #39
    //   Java source line #335	-> byte code offset #44
    //   Java source line #336	-> byte code offset #50
    //   Java source line #337	-> byte code offset #55
    //   Java source line #338	-> byte code offset #60
    //   Java source line #339	-> byte code offset #63
    //   Java source line #340	-> byte code offset #80
    //   Java source line #342	-> byte code offset #83
    //   Java source line #343	-> byte code offset #87
    //   Java source line #344	-> byte code offset #107
    //   Java source line #345	-> byte code offset #120
    //   Java source line #346	-> byte code offset #122
    //   Java source line #347	-> byte code offset #125
    //   Java source line #349	-> byte code offset #130
    //   Java source line #351	-> byte code offset #135
    //   Java source line #352	-> byte code offset #143
    //   Java source line #353	-> byte code offset #145
    //   Java source line #356	-> byte code offset #150
    //   Java source line #357	-> byte code offset #155
    //   Java source line #359	-> byte code offset #161
    //   Java source line #348	-> byte code offset #168
    //   Java source line #349	-> byte code offset #170
    //   Java source line #351	-> byte code offset #175
    //   Java source line #352	-> byte code offset #183
    //   Java source line #353	-> byte code offset #185
    //   Java source line #356	-> byte code offset #190
    //   Java source line #357	-> byte code offset #195
    //   Java source line #359	-> byte code offset #201
    //   Java source line #360	-> byte code offset #205
    //   Java source line #349	-> byte code offset #208
    //   Java source line #351	-> byte code offset #213
    //   Java source line #352	-> byte code offset #221
    //   Java source line #353	-> byte code offset #223
    //   Java source line #356	-> byte code offset #228
    //   Java source line #357	-> byte code offset #233
    //   Java source line #359	-> byte code offset #239
    //   Java source line #363	-> byte code offset #243
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	244	0	this	EclipseLogWriter
    //   0	244	1	newOutFile	File
    //   0	244	2	newWriter	Writer
    //   0	244	3	append	boolean
    //   32	3	4	e	IOException
    //   48	186	4	oldOutFile	File
    //   61	168	5	copyFailed	boolean
    //   81	133	6	fileIn	Reader
    //   120	6	7	e	IOException
    //   168	38	8	localObject	Object
    //   143	3	9	e	IOException
    //   183	3	9	e	IOException
    //   221	3	9	e	IOException
    // Exception table:
    //   from	to	target	type
    //   22	29	32	java/io/IOException
    //   83	117	120	java/io/IOException
    //   135	140	143	java/io/IOException
    //   83	130	168	finally
    //   175	180	183	java/io/IOException
    //   213	218	221	java/io/IOException
  }
  
  private void copyReader(Reader reader, Writer aWriter)
    throws IOException
  {
    char[] buffer = new char['?'];
    int count;
    while ((count = reader.read(buffer, 0, buffer.length)) > 0)
    {
      int count;
      aWriter.write(buffer, 0, count);
    }
  }
  
  private String getDate(Date date)
  {
    Calendar c = Calendar.getInstance();
    c.setTime(date);
    StringBuffer sb = new StringBuffer();
    appendPaddedInt(c.get(1), 4, sb).append('-');
    appendPaddedInt(c.get(2) + 1, 2, sb).append('-');
    appendPaddedInt(c.get(5), 2, sb).append(' ');
    appendPaddedInt(c.get(11), 2, sb).append(':');
    appendPaddedInt(c.get(12), 2, sb).append(':');
    appendPaddedInt(c.get(13), 2, sb).append('.');
    appendPaddedInt(c.get(14), 3, sb);
    return sb.toString();
  }
  
  private StringBuffer appendPaddedInt(int value, int pad, StringBuffer buffer)
  {
    
    if (pad == 0) {
      return buffer.append(Integer.toString(value));
    }
    int padding = (int)Math.pow(10.0D, pad);
    if (value >= padding) {
      return buffer.append(Integer.toString(value));
    }
    while ((padding > value) && (padding > 1))
    {
      buffer.append('0');
      padding /= 10;
    }
    buffer.append(value);
    return buffer;
  }
  
  private String g
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