org.eclipse.equinox.util_1.0.400.v20120917-192807

newElement);
    }
  }
  
  void doInsertElement(QueueElement firstEl, QueueElement elToInsert)
  {
    QueueElement tmp = firstEl;
    QueueElement prev = firstEl;
    while ((tmp != null) && (node.runOn < node.runOn))
    {
      prev = tmp;
      tmp = next;
    }
    if (tmp == null)
    {
      next = elToInsert;
    }
    else
    {
      next = elToInsert;
      next = tmp;
    }
    lastInserted = elToInsert;
  }
  
  void removeTimerNode(TimerQueueNode node)
  {
    QueueElement tmp = first;
    QueueElement prev = null;
    while (tmp != null)
    {
      if ((listener == node.listener) && (event == node.event))
      {
        if (prev != null)
        {
          if (lastInserted == tmp) {
            lastInserted = prev;
          }
          next = next;
          if (filled >= 20) {
            break;
          }
          freeQueueElement(tmp); break;
        }
        if (lastInserted == first) {
          lastInserted = null;
        }
        if (filled < 20)
        {
          QueueElement toFree = first;
          first = first.next;
          freeQueueElement(toFree); break;
        }
        first = first.next;
        
        break;
      }
      prev = tmp;
      tmp = next;
    }
  }
  
  private QueueElement getQueueElement()
  {
    return filled > 0 ? pool[(--filled)] : new QueueElement();
  }
  
  private void freeQueueElement(QueueElement toFree)
  {
    if (filled < 20)
    {
      pool[filled] = toFree;
      filled += 1;
      next = null;
      node = null;
    }
  }
  
  private class QueueElement
  {
    QueueElement next;
    TimerQueueNode node;
    
    public QueueElement() {}
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.util.impl.tpt.timer.TimerQueue
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.util.impl.tpt.timer;

import java.security.AccessControlContext;
import org.eclipse.equinox.internal.util.impl.tpt.ServiceFactoryImpl;
import org.eclipse.equinox.internal.util.pool.ObjectCreator;
import org.eclipse.equinox.internal.util.pool.ObjectPool;
import org.eclipse.equinox.internal.util.ref.Log;
import org.eclipse.equinox.internal.util.timer.TimerListener;

class TimerQueueNode
  implements Runnable, ObjectCreator
{
  public static final String PERIODICAL_TASK_NAME = "[Timer] - Periodical Task";
  public static final String PERIODICAL_NO_DELAY_TASK_NAME = "[Timer] - Periodical No Delay Task";
  public static final String ONE_SHOT_TASK_NAME = "[Timer] - One Shot Task";
  public static final String ONE_SHOT_NO_DELAY_TASK_NAME = "[Timer] - One Shot No Delay Task";
  TimerListener listener = null;
  int event;
  long runOn = -1L;
  int type = -1;
  int priority = -1;
  long period = -1L;
  boolean running = false;
  private int theHash;
  String name;
  boolean named = false;
  String context;
  AccessControlContext acc;
  boolean enabled = false;
  
  public String getEName()
  {
    if ((ServiceFactoryImpl.useNames) && (!named))
    {
      named = true;
      String tmp = null;
      switch (type)
      {
      case 0: 
        tmp = "[Timer] - One Shot Task";
        break;
      case 2: 
        tmp = "[Timer] - One Shot No Delay Task";
        break;
      case 1: 
        tmp = "[Timer] - Periodical Task";
        break;
      case 3: 
        tmp = "[Timer] - Periodical No Delay Task";
      }
      name = (name != null ? tmp.concat(name) : tmp);
    }
    return name == null ? "" : name;
  }
  
  public void setEvent(TimerListener listener, int priority, int timerType, long runOn, long periodMilis, int event, String name, AccessControlContext acc)
  {
    enabled = true;
    this.listener = listener;
    theHash = (listener.hashCode() + event);
    this.priority = priority;
    type = timerType;
    period = periodMilis;
    this.runOn = runOn;
    this.event = event;
    this.name = name;
    named = false;
    this.acc = acc;
  }
  
  void returnInPool()
  {
    synchronized (this)
    {
      if ((!enabled) || ((running) && (type == 0))) {
        return;
      }
      clear();
    }
    if (TimerImpl.nodePool != null) {
      TimerImpl.nodePool.releaseObject(this);
    }
  }
  
  public void run()
  {
    synchronized (this)
    {
      running = true;
    }
    TimerListener tmp = listener;
    try
    {
      if ((tmp != null) && (enabled)) {
        tmp.timer(event);
      }
    }
    catch (Throwable t)
    {
      if (ServiceFactoryImpl.log != null) {
        ServiceFactoryImpl.log.error("[Timer] - Error while notifying:\r\n" + tmp, t);
      }
    }
    tmp = null;
    if (type == 0) {
      returnInPool();
    }
    running = false;
  }
  
  public Object getInstance()
  {
    return new TimerQueueNode();
  }
  
  private void clear()
  {
    named = false;
    name = null;
    enabled = false;
    listener = null;
    event = -1;
    runOn = Long.MAX_VALUE;
    type = -1;
    acc = null;
  }
  
  public int hashCode()
  {
    TimerListener lis = listener;
    return lis != null ? (theHash = lis.hashCode() + event) : theHash;
  }
  
  public String toString()
  {
    return "QueueNode: " + super.toString() + "\r\n" + "\t\tListener: " + listener + "\r\n" + "\t\tEvent: " + event + "\r\n" + "\t\tType: " + type + "\r\n" + "\t\trunafter: " + (runOn - System.currentTimeMillis()) + "\r\n" + "\t\tEnabled: " + enabled;
  }
  
  public boolean equals(Object a)
  {
    if ((a instanceof TimerQueueNode))
    {
      TimerQueueNode b = (TimerQueueNode)a;
      return (listener == listener) && (event == event);
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.util.impl.tpt.timer.TimerQueueNode
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.util.pool;

public abstract interface ObjectCreator
{
  public abstract Object getInstance()
    throws Exception;
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.util.pool.ObjectCreator
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.util.pool;

public class ObjectPool
{
  private Class template;
  protected Object[][] buff;
  protected int nextFree;
  protected int size;
  protected int minimumFill;
  protected int factor;
  protected int minfSize;
  protected int minffactor;
  protected boolean dontExtend = false;
  protected ObjectCreator oc;
  
  public Object getInstance()
    throws Exception
  {
    return oc != null ? oc.getInstance() : template.newInstance();
  }
  
  public ObjectPool(ObjectCreator oc, int size, int factor)
  {
    this(null, oc, size, factor, size * factor);
  }
  
  public ObjectPool(Class template, int size, int factor)
  {
    this(template, null, size, factor, size * factor);
  }
  
  public ObjectPool(Class template, int size, int factor, int minimumFill)
  {
    this(template, null, size, factor, minimumFill = minimumFill > size * factor ? size * factor : minimumFill);
  }
  
  public ObjectPool(ObjectCreator oc, int size, int factor, int minimumFill)
  {
    this(null, oc, size, factor, minimumFill = minimumFill > size * factor ? size * factor : minimumFill);
  }
  
  protected ObjectPool(Class template, ObjectCreator oc, int size, int factor, int minimumFill)
  {
    if ((size <= 1) || (factor < 1)) {
      throw new IllegalArgumentException(size + " is less or equal to 1");
    }
    this.minimumFill = (minimumFill < 1 ? 1 : minimumFill);
    this.oc = oc;
    if (template != null) {
      try
      {
        template.getConstructor(new Class[0]);
        this.template = template;
      }
      catch (NoSuchMethodException localNoSuchMethodException)
      {
        throw new IllegalArgumentException(template + " don't have default constructor!");
      }
    }
    buff = new Object[size][];
    this.size = size;
    this.factor = factor;
    minfSize = (this.minimumFill / factor);
    minffactor = (this.minimumFill % factor);
    if (minimumFill <= 1)
    {
      nextFree = -1;
    }
    else
    {
      for (int i = 0; i < (minfSize == 0 ? 1 : minfSize); i++) {
        buff[i] = new Object[factor];
      }
      fill();
    }
  }
  
  private void fill()
  {
    int i = 0;
    synchronized (buff)
    {
      for (; i < minfSize; i++) {
        put(i, factor);
      }
      if (minffactor > 0) {
        put(i, minffactor);
      }
    }
    nextFree = (minimumFill - 1);
  }
  
  private void put(int i, int count)
  {
    for (int j = 0; j < count; j++) {
      try
      {
        if (buff[i] == null) {
          buff[i] = new Object[factor];
        }
        buff[i][j] = getInstance();
        nextFree = (i * j);
      }
      catch (Throwable t)
      {
        throw new RuntimeException("buffer fill failed: " + t);
      }
    }
  }
  
  public void clear()
  {
    dontExtend = true;
    shrink(-1);
  }
  
  protected void shrink(int count)
  {
    synchronized (buff)
    {
      for (; nextFree > count; nextFree -= 1) {
        buff[(nextFree / factor)][(nextFree % factor)] = null;
      }
    }
  }
  
  public void shrink()
  {
    dontExtend = true;
    shrink(minimumFill);
    dontExtend = false;
  }
  
  public Object getObject()
  {
    Object tmp = null;
    synchronized (buff)
    {
      if (nextFree < 0)
      {
        if (dontExtend) {
          throw new RuntimeException();
        }
        if (minimumFill <= 1) {
          try
          {
            return getInstance();
          }
          catch (Throwable e)
          {
            throw new RuntimeException("buffer fill failed: " + e);
          }
        }
        fill();
      }
      tmp = buff[(nextFree / factor)][(nextFree % factor)];
      buff[(nextFree / factor)][(nextFree % factor)] = null;
      nextFree -= 1;
      
      return tmp;
    }
  }
  
  public boolean releaseObject(Object obj)
  {
    if (dontExtend) {
      return false;
    }
    synchronized (buff)
    {
      int tmp = nextFree + 1;
      int telement = tmp / factor;
      if (telement < size)
      {
        if (buff[telement] == null) {
          buff[telement] = new Object[factor];
        }
        buff[telement][(tmp % factor)] = obj;
        nextFree = tmp;
        return true;
      }
      return false;
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.util.pool.ObjectPool
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.util.ref;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Vector;
import org.eclipse.equinox.internal.util.UtilActivator;
import org.eclipse.equinox.internal.util.event.Queue;
import org.eclipse.equinox.internal.util.hash.HashIntObjNS;
import org.eclipse.equinox.internal.util.impl.tpt.threadpool.ThreadPoolFactoryImpl;
import org.eclipse.equinox.internal.util.security.PrivilegedRunner.PrivilegedDispatcher;
import org.eclipse.equinox.internal.util.security.SecurityUtil;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.log.LogService;
import org.osgi.util.tracker.ServiceTracker;
import org.osgi.util.tracker.ServiceTrackerCustomizer;

public class Log
  implements LogInterface, ServiceTrackerCustomizer, PrivilegedRunner.PrivilegedDispatcher
{
  /**
   * @deprecated
   */
  public boolean printOnConsole = false;
  public boolean autoPrintOnConsole = false;
  /**
   * @deprecated
   */
  public boolean debug = false;
  private boolean logErrorLevel = false;
  private ServiceTracker logTracker;
  private ServiceReference traceRef;
  protected static final SecurityUtil securityUtil = new SecurityUtil();
  private boolean isClosed = false;
  private long bundleId;
  protected BundleContext bc;
  private static Vector logs = new Vector();
  private static Log listener;
  
  public Log(BundleContext bc)
  {
    this(bc, true);
  }
  
  public Log(BundleContext bc, boolean initDebug)
  {
    if (initDebug)
    {
      debug = securityUtil.getBooleanProperty("equinox.util.ref.log.debug");
      logErrorLevel = securityUtil.getBooleanProperty("equinox.log.errorlevel");
      autoPrintOnConsole = securityUtil.getBooleanProperty("equinox.util.ref.log.autoPrintOnConsole");
      printOnConsole = securityUtil.getBooleanProperty("equinox.util.ref.log.printOnConsole");
    }
    if (bc != null)
    {
      this.bc = bc;
      bundleId = bc.getBundle().getBundleId();
      if ((UtilActivator.startup) && (UtilActivator.points != null)) {
        UtilActivator.points[0] = System.currentTimeMillis();
      }
      initSysServices();
      if ((UtilActivator.startup) && (UtilActivator.points != null)) {
        UtilActivator.points[1] = System.currentTimeMillis();
      }
      synchronized (logs)
      {
        if (listener == null) {
          initListener();
        }
        logs.addElement(this);
      }
      if ((UtilActivator.startup) && (UtilActivator.points != null)) {
        UtilActivator.points[2] = System.currentTimeMillis();
      }
    }
    else
    {
      printOnConsole = true;
    }
  }
  
  private void initListener()
  {
    try
    {
      securityUtil.doPrivileged(this, 0, null);
    }
    catch (IllegalStateException ise)
    {
      throw ise;
    }
    catch (Throwable ignore)
    {
      ignore.printStackTrace();
    }
  }
  
  void initListener0()
  {
    synchronized (logs)
    {
      initListenerNS();
    }
  }
  
  void initListenerNS()
  {
    logTracker = new ServiceTracker(bc, "org.osgi.service.log.LogService", this);
    logTracker.open();
    listener = this;
  }
  
  public void error(String str, Throwable ex)
  {
    if (isClosed) {
      return;
    }
    boolean logResult = logMessage(1, str, ex);
    if ((printOnConsole) || ((!logResult) && (autoPrintOnConsole)) || (logErrorLevel)) {
      dumpOnConsole("ERROR ", str, bundleId, ex);
    }
  }
  
  public void error(int moduleID, int msgID, String msg, Throwable t, boolean synch)
  {
    if (isClosed) {
      return;
    }
    boolean logResult = true;
    if ((msg != null) || (t != null)) {
      logResult = logMessage(1, msg, t);
    }
    if ((printOnConsole) || ((!logResult) && (autoPrintOnConsole)) || (logErrorLevel)) {
      dumpOnConsole(buildDebugString(moduleID, msgID, msg, "ERROR " + bundleId + " "), t);
    }
  }
  
  public void warning(String str, Throwable ex)
  {
    if (isClosed) {
      return;
    }
    boolean logResult = logMessage(2, str, ex);
    if ((printOnConsole) || ((!logResult) && (autoPrintOnConsole)) || (logErrorLevel)) {
      dumpOnConsole("WARNING ", str, bundleId, ex);
    }
  }
  
  public void warning(int moduleID, int msgID, String msg, Throwable t, boolean synch)
  {
    if (isClosed) {
      return;
    }
    boolean logResult = true;
    if ((msg != null) || (t != null)) {
      logResult = logMessage(2, msg, t);
    }
    if ((printOnConsole) || ((!logResult) && (autoPrintOnConsole)) || (logErrorLevel)) {
      dumpOnConsole(buildDebugString(moduleID, msgID, msg, "WARNING " + bundleId + " "), t);
    }
  }
  
  public void info(String str)
  {
    if (isClosed) {
      return;
    }
    boolean logResult = logMessage(3, str, null);
    if ((printOnConsole) || ((!logResult) && (autoPrintOnConsole))) {
      dumpOnConsole("INFO ", str, bundleId, null);
    }
  }
  
  public void info(int moduleID, int msgID, String msg, boolean synch)
  {
    if (isClosed) {
      return;
    }
    boolean logResult = true;
    if (msg != null) {
      logResult = logMessage(3, msg, null);
    }
    if ((printOnConsole) || ((!logResult) && (autoPrintOnConsole))) {
      dumpOnConsole(buildDebugString(moduleID, msgID, msg, "INFO " + bundleId + " "), null);
    }
  }
  
  public void debug(String str, Throwable ex)
  {
    if ((!debug) || (isClosed)) {
      return;
    }
    boolean logResult = logMessage(4, str, ex);
    if ((printOnConsole) || ((!logResult) && (autoPrintOnConsole))) {
      dumpOnConsole("DEBUG ", str, bundleId, ex);
    }
  }
  
  public void debug(int moduleID, int msgID, String msg, Throwable t, boolean synch)
  {
    debug(moduleID, msgID, msg, t, synch, false, false, true);
  }
  
  public void debug(int moduleID, int msgID, String msg, Throwable t, boolean synch, boolean measurement)
  {
    debug(moduleID, msgID, msg, t, synch, measurement, false, true);
  }
  
  public void debug(int moduleID, int msgID, String msg, Throwable t, boolean synch, boolean measurement, boolean display)
  {
    debug(moduleID, msgID, msg, t, synch, measurement, display, true);
  }
  
  public void debug(int moduleID, int msgID, String msg, Throwable t, boolean synch, boolean measurement, boolean display, boolean logInFile)
  {
    if (((!debug) && (!measurement)) || (isClosed)) {
      return;
    }
    String message = msg;
    if (measurement) {
      message = buildDebugString(moduleID, msgID, msg, "DEBUG " + bundleId + " ");
    }
    boolean logResult = logInFile;
    if ((logInFile) && ((message != null) || (t != null))) {
      logResult = logMessage(4, message, t);
    }
    if ((printOnConsole) || ((!logResult) && (autoPrintOnConsole)))
    {
      message = buildDebugString(moduleID, msgID, msg, "DEBUG " + bundleId + " ");
      dumpOnConsole(message, t);
    }
  }
  
  private void initSysServices()
  {
    if (security) {
      try
      {
        securityUtil.doPrivileged(this, 2, null);
      }
      catch (Throwable ignore)
      {
        ignore.printStackTrace();
      }
    }
  }
  
  LogService getService0()
    throws IllegalArgumentException
  {
    synchronized (logs)
    {
      ServiceReference logRef = (ServiceReference)listenerlogTracker.getService();
      LogService ls = null;
      if (logRef != null) {
        ls = (LogService)bc.getService(logRef);
      }
      return ls;
    }
  }
  
  private LogService getService()
    throws IllegalArgumentException
  {
    if (bc == null) {
      return null;
    }
    try
    {
      return (LogService)securityUtil.doPrivileged(this, 1, null);
    }
    catch (IllegalArgumentException e)
    {
      throw e;
    }
    catch (Exception e)
    {
      e.printStackTrace();
      throw new IllegalArgumentException(e.toString());
    }
  }
  
  private boolean logMessage(int messageType, String messageText, Throwable t)
  {
    LogService ls = null;
    try
    {
      ls = getService();
    }
    catch (IllegalStateException localIllegalStateException1)
    {
      synchronized (logs)
      {
        close0();
      }
      return false;
    }
    boolean result = true;
    if (ls == null)
    {
      result = false;
      testClose();
    }
    else
    {
      try
      {
        ls.log(messageType, messageText, t);
      }
      catch (IllegalStateException localIllegalStateException2)
      {
        result = false;
        testClose();
      }
    }
    return result;
  }
  
  private void dumpOnConsole(String prefix, String msg, long bundleId, Throwable t)
  {
    System.out.println(prefix + bundleId + " " + msg);
    if (t != null) {
      t.printStackTrace();
    }
  }
  
  private void dumpOnConsole(String msg, Throwable t)
  {
    System.out.println(msg);
    if (t != null) {
      t.printStackTrace();
    }
  }
  
  private void testClose()
  {
    synchronized (logs)
    {
      if (listener != null) {
        try
        {
          listenerbc.getBundle();
          return;
        }
        catch (IllegalStateException localIllegalStateException)
        {
          listener.close0();
        }
      }
    }
  }
  
  public void close()
  {
    if (bc != null)
    {
      if (traceRef != null)
      {
        bc.ungetService(traceRef);
        traceRef = null;
      }
      synchronized (logs)
      {
        close0();
      }
    }
  }
  
  private boolean close0()
  {
    logs.removeElement(this);
    isClosed = true;
    if (listener == this)
    {
      try
      {
        logTracker.close();
        logTracker = null;
      }
      catch (IllegalStateException localIllegalStateException1) {}
      Log ls = null;
      while (logs.size() > 0)
      {
        ls = (Log)logs.elementAt(0);
        try
        {
          ls.initListener();
        }
        catch (IllegalStateException localIllegalStateException2)
        {
          logs.removeElementAt(0);
          ls = null;
        }
      }
      listener = ls;
    }
    return listener != null;
  }
  
  public void setPrintOnConsole(boolean value)
  {
    printOnConsole = value;
  }
  
  public void setDebug(boolean value)
  {
    debug = value;
  }
  
  public boolean getDebug()
  {
    return debug;
  }
  
  public boolean getPrintOnConsole()
  {
    return printOnConsole;
  }
  
  public Object addingService(ServiceReference reference)
  {
    return reference;
  }
  
  private HashIntObjNS map = null;
  private HashIntObjNS starts = null;
  
  public void modifiedService(ServiceReference reference, Object service) {}
  
  public void removedService(ServiceReference reference, Object service) {}
  
  public void setMaps(HashIntObjNS map0, HashIntObjNS starts0)
  {
    map = map0;
    starts = starts0;
  }
  
  private String getModuleName(int moduleID)
  {
    return (String)map.get(-moduleID);
  }
  
  private String getMsgValue(int msgID)
  {
    String res = (String)map.get(msgID);
    if ((res == null) && (starts != null)) {
      try
      {
        int startID = ((Integer)starts.get(msgID)).intValue();
        res = "END OF " + (String)map.get(startID);
      }
      catch (Exception localException) {}
    }
    return res;
  }
  
  private static final char[] chars = { ']', ' ', ':', ' ' };
  
  private String buildDebugString(int moduleID, int msgID, String message, String prefix)
  {
    if (map == null) {
      return prefix + " [" + moduleID + "] " + msgID + " : " + (message == null ? "" : message);
    }
    StringBuffer sBuf = new StringBuffer(prefix).append("[");
    
    String module = getModuleName(moduleID);
    sBuf.append(moduleID);
    
    sBuf.append(chars, 0, 2);
    if (msgID != 0)
    {
      String msg = getMsgValue(msgID);
      sBuf.append(msgID);
    }
    if (message != null) {
      sBuf.append(chars, 2, 2).append(message);
    }
    return sBuf.toString();
  }
  
  private static boolean security = false;
  String baseName;
  boolean synch;
  
  public static boolean security()
  {
    if (UtilActivator.bc != null) {
      try
      {
        Object ssecurity = UtilActivator.bc.getProperty("equinox.security");
        security = (ssecurity != null) && (!"none".equals(ssecurity));
      }
      catch (Throwable localThrowable1) {}
    } else {
      try
      {
        Object ssecurity = System.getProperty("equinox.security");
        security = (ssecurity != null) && (!"none".equals(ssecurity));
      }
      catch (Throwable localThrowable2) {}
    }
    return security;
  }
  
  FileOutputStream fos = null;
  static String logsdir = null;
  static Queue queue;
  static boolean running = false;
  static Saver saver;
  long lastTime;
  private static final byte OPEN_TYPE = 0;
  private static final byte GET_SERVICE_TYPE = 1;
  private static final byte GET_SYS_SERVICES_TYPE = 2;
  
  public Log(String baseName, boolean synch, BundleContext bc)
  {
    this(bc);
    this.baseName = baseName;
    this.synch = synch;
    if (!synch) {
      synchronized (Log.class)
      {
        if (queue == null)
        {
          queue = new Queue(20);
          saver = new Saver();
        }
      }
    }
  }
  
  public void trace(byte[] bytes)
  {
    if (!synch) {
      synchronized (queue)
      {
        queue.put(this);
        queue.put(bytes);
        if (!running)
        {
          running = true;
          UtilActivator.thMan.execute(saver, "File Log Thread");
        }
      }
    }
    trace(bytes, 0, bytes.length);
  }
  
  public void trace(byte[] bytes, int off, int len)
  {
    if (logsdir == null) {
      synchronized (Log.class)
      {
        if (logsdir == null) {
          try
          {
            logsdir = UtilActivator.bc.getProperty("equinox.logsDir");
            if (logsdir == null) {
              logsdir = "./logs";
            }
            File logs = new File(logsdir);
            logs.mkdirs();
          }
          catch (Exception exc)
          {
            exc.printStackTrace();
          }
        }
      }
    }
    if (fos == null) {
      synchronized (this)
      {
        if (fos == null)
        {
          StringBuffer fname = new StringBuffer(logsdir.length() + baseName.length() + 1);
          fname.append(logsdir).append(File.separatorChar).append(baseName);
          try
          {
            fos = new FileOutputStream(fname.toString(), true);
          }
          catch (IOException ioExc)
          {
            ioExc.printStackTrace();
          }
        }
      }
    }
    try
    {
      fos.write(bytes, off, len);
      fos.write(10);
    }
    catch (IOException ioExc)
    {
      ioExc.printStackTrace();
    }
  }
  
  public void finalize()
  {
    if (fos != null) {
      try
      {
        fos.close();
      }
      catch (IOException ioExc)
      {
        ioExc.printStackTrace();
      }
    }
  }
  
  public boolean isAutoPrintOnConsole()
  {
    return autoPrintOnConsole;
  }
  
  public void setAutoPrintOnConsole(boolean autoPrintOnConsole)
  {
    this.autoPrintOnConsole = autoPrintOnConsole;
  }
  
  public boolean isLogErrorLevel()
  {
    return logErrorLevel;
  }
  
  public Object dispatchPrivileged(int type, Object arg1, Object arg2, Object arg3, Object arg4)
    throws Exception
  {
    switch (type)
    {
    case 0: 
      initListener0();
      break;
    case 1: 
      return getService0();
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.util.ref.Log
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.util.ref;

public abstract interface LogInterface
{
  public static final boolean printOnConsole = true;
  public static final boolean debug = false;
  
  public abstract void error(String paramString, Throwable paramThrowable);
  
  public abstract void warning(String paramString, Throwable paramThrowable);
  
  public abstract void info(String paramString);
  
  public abstract void debug(String paramString, Throwable paramThrowable);
  
  public abstract void close();
  
  public abstract void setPrintOnConsole(boolean paramBoolean);
  
  public abstract void setDebug(boolean paramBoolean);
  
  public abstract boolean getDebug();
  
  public abstract boolean getPrintOnConsole();
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.util.ref.LogInterface
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.util.ref;

import org.eclipse.equinox.internal.util.event.Queue;

class Saver
  implements Runnable
{
  public void run()
  {
    byte[] bytes = null;
    Log log = null;
    for (;;)
    {
      synchronized (Log.queue)
      {
        log = (Log)Log.queue.get();
        if (log == null)
        {
          Log.running = false;
          bytes = null;
          return;
        }
        bytes = (byte[])Log.queue.get();
      }
      log.trace(bytes, 0, bytes.length);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.util.ref.Saver
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.util.ref;

import org.eclipse.equinox.internal.util.timer.Timer;
import org.eclipse.equinox.internal.util.timer.TimerListener;

public class TimerRef
{
  public static Timer timer = null;
  
  public static void notifyAfter(TimerListener listener, long millis, int event)
  {
    if (timer == null)
    {
      listener.timer(event);
      return;
    }
    timer.addNotifyListener(listener, 5, 0, millis, event);
  }
  
  public static void removeListener(TimerListener listener, int event)
  {
    if (timer == null) {
      return;
    }
    timer.removeListener(listener, event);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.util.ref.TimerRef
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.util.security;

/**
 * @deprecated
 */
public abstract interface PrivilegedAction
{
  public abstract Object run0()
    throws Exception;
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.util.security.PrivilegedAction
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.util.security;

import java.security.PrivilegedExceptionAction;

class PrivilegedRunner$PA
  implements PrivilegedExceptionAction
{
  int type;
  Object arg1;
  Object arg2;
  Object arg3;
  Object arg4;
  PrivilegedRunner.PrivilegedDispatcher dispatcher;
  
  void recycle()
  {
    dispatcher = null;
    type = -1;
    arg1 = (arg2 = arg3 = arg4 = null);
  }
  
  public Object run()
    throws Exception
  {
    return dispatcher.dispatchPrivileged(type, arg1, arg2, arg3, arg4);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.util.security.PrivilegedRunner.PA
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.util.security;

public abstract interface PrivilegedRunner$PrivilegedDispatcher
{
  public abstract Object dispatchPrivileged(int paramInt, Object paramObject1, Object paramObject2, Object paramObject3, Object paramObject4)
    throws Exception;
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.util.security.PrivilegedRunner.PrivilegedDispatcher
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.util.security;

import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import org.eclipse.equinox.internal.util.pool.ObjectCreator;
import org.eclipse.equinox.internal.util.pool.ObjectPool;

public final class PrivilegedRunner
  implements ObjectCreator
{
  private static ObjectPool POOL;
  
  static
  {
    try
    {
      POOL = new ObjectPool(new PrivilegedRunner(), 5, 10);
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
  }
  
  public static final Object doPrivileged(Object context, PrivilegedDispatcher dispatcher, int type, Object arg1)
    throws Exception
  {
    return doPrivileged(context, dispatcher, type, arg1, null, null, null);
  }
  
  public static final Object doPrivileged(Object context, PrivilegedDispatcher dispatcher, int type, Object arg1, Object arg2, Object arg3, Object arg4)
    throws Exception
  {
    PA runner = (PA)POOL.getObject();
    dispatcher = dispatcher;
    type = type;
    arg1 = arg1;
    arg2 = arg2;
    arg3 = arg3;
    arg4 = arg4;
    try
    {
      Object localObject2;
      if (System.getSecurityManager() != null) {
        return context != null ? 
        
          AccessController.doPrivileged(runner, (AccessControlContext)context) : 
          AccessController.doPrivileged(runner);
      }
      return runner.run();
    }
    catch (PrivilegedActionException e)
    {
      throw e.getException();
    }
    finally
    {
      runner.recycle();
      POOL.releaseObject(runner);
    }
  }
  
  public Object getInstance()
    throws Exception
  {
    return new PA();
  }
  
  static class PA
    implements PrivilegedExceptionAction
  {
    int type;
    Object arg1;
    Object arg2;
    Object arg3;
    Object arg4;
    PrivilegedRunner.PrivilegedDispatcher dispatcher;
    
    void recycle()
    {
      dispatcher = null;
      type = -1;
      arg1 = (arg2 = arg3 = arg4 = null);
    }
    
    public Object run()
      throws Exception
    {
      return dispatcher.dispatchPrivileged(type, arg1, arg2, arg3, arg4);
    }
  }
  
  public static abstract interface PrivilegedDispatcher
  {
    public abstract Object dispatchPrivileged(int paramInt, Object paramObject1, Object paramObject2, Object paramObject3, Object paramObject4)
      throws Exception;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.util.security.PrivilegedRunner
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.util.security;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.util.Dictionary;
import java.util.Properties;
import org.eclipse.equinox.internal.util.UtilActivator;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;

public final class SecurityUtil
  implements PrivilegedRunner.PrivilegedDispatcher
{
  private Object controlContext;
  private static final int SYSTEM_GET_PROPERTY = 41;
  private static final int CREATE_THREAD = 42;
  private static final int CLASS_FOR_NAME = 43;
  private static final int SYSTEM_SET_PROPERTY = 44;
  private static final int FILE_BASE = 50;
  private static final int FILE_GET_INPUT_STREAM = 50;
  private static final int FILE_GET_OUTPUT_STREAM = 51;
  private static final int FILE_LENGTH = 52;
  private static final int FILE_EXISTS = 53;
  private static final int FILE_ISDIR = 54;
  private static final int FILE_LAST_MODIFIED = 55;
  private static final int FILE_LIST = 56;
  private static final int FILE_DELETE = 57;
  private static final int FILE_RENAME = 58;
  private static final int FILE_GET_RANDOM_ACCESS_FILE = 59;
  private static final int SERVICE_BASE = 60;
  private static final int SERVICE_GET_REFERENCE = 60;
  private static final int SERVICE_GET_SERVICE = 61;
  private static final int SERVICE_REG_CLASS = 62;
  private static final int SERVICE_REG_CLASSES = 63;
  private static final int BUNDLE_BASE = 70;
  private static final int BUNDLE_GET_LOCATION = 70;
  private static final int BUNDLE_GET_HEADERS = 71;
  private static final int BUNDLE_START = 72;
  private static final int BUNDLE_STOP = 73;
  private static final int BUNDLE_UNINSTALL = 74;
  private static final int BUNDLE_UPDATE = 75;
  private static final int BUNDLE_UPDATE_IS = 76;
  
  public SecurityUtil()
  {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
      controlContext = sm.getSecurityContext();
    }
  }
  
  public Thread createThread(Runnable target, String name)
  {
    try
    {
      return (Thread)PrivilegedRunner.doPrivileged(controlContext, this, 42, target, name, null, null);
    }
    catch (Exception t)
    {
      throw new RuntimeException(t.getMessage());
    }
  }
  
  public Class forName(String name)
    throws ClassNotFoundException
  {
    try
    {
      return (Class)PrivilegedRunner.doPrivileged(controlContext, this, 43, name, null, null, null);
    }
    catch (ClassNotFoundException t)
    {
      throw t;
    }
    catch (Exception t)
    {
      throw new RuntimeException(t.getMessage());
    }
  }
  
  public String getProperty(String property)
  {
    if (property == null) {
      throw new NullPointerException("property is null");
    }
    String ret;
    try
    {
      ret = (String)PrivilegedRunner.doPrivileged(controlContext, this, 41, property, null, null, null);
    }
    catch (Exception localException)
    {
      String ret;
      ret = null;
    }
    return ret;
  }
  
  public String getProperty(String property, String def)
  {
    String ret = getProperty(property);
    return ret != null ? ret : def;
  }
  
  public boolean getBooleanProperty(String property)
  {
    String ret = getProperty(property);
    return ret != null ? Boolean.valueOf(ret).booleanValue() : false;
  }
  
  public String setProperty(String key, String value)
  {
    if (key == null) {
      throw new NullPointerException("key is null");
    }
    if (value == null) {
      throw new NullPointerException("key is null");
    }
    try
    {
      return (String)PrivilegedRunner.doPrivileged(controlContext, this, 44, key, value, null, null);
    }
    catch (Exception t)
    {
      throw new RuntimeException(t.getMessage());
    }
  }
  
  public FileInputStream getFileInputStream(File file)
    throws FileNotFoundException
  {
    try
    {
      return (FileInputStream)PrivilegedRunner.doPrivileged(controlContext, this, 50, file, null, null, null);
    }
    catch (FileNotFoundException t)
    {
      throw t;
    }
    catch (Exception t)
    {
      throw new RuntimeException(t.getMessage());
    }
  }
  
  public RandomAccessFile getRandomAccessFile(File file, String mode)
    throws FileNotFoundException
  {
    try
    {
      return (RandomAccessFile)PrivilegedRunner.doPrivileged(controlContext, this, 59, file, mode, null, null);
    }
    catch (FileNotFoundException t)
    {
      throw t;
    }
    catch (Exception t)
    {
      throw new RuntimeException(t.getMessage());
    }
  }
  
  public FileOutputStream getFileOutputStream(File file, boolean append)
    throws FileNotFoundException
  {
    try
    {
      return (FileOutputStream)PrivilegedRunner.doPrivileged(
        controlContext, this, 51, file, 
        append ? Boolean.TRUE : Boolean.FALSE, null, null);
    }
    catch (FileNotFoundException t)
    {
      throw t;
    }
    catch (Exception t)
    {
      throw new RuntimeException(t.getMessage());
    }
  }
  
  public boolean exists(File file)
  {
    try
    {
      return ((Boolean)PrivilegedRunner.doPrivileged(controlContext, this, 53, file, null, null, null)).booleanValue();
    }
    catch (Exception t)
    {
      throw new RuntimeException(t.getMessage());
    }
  }
  
  public boolean isDirectory(File file)
  {
    try
    {
      return ((Boolean)PrivilegedRunner.doPrivileged(controlContext, this, 54, file, null, null, null)).booleanValue();
    }
    catch (Exception t)
    {
      throw new RuntimeException(t.getMessage());
    }
  }
  
  public long length(File file)
  {
    try
    {
      return ((Long)PrivilegedRunner.doPrivileged(controlContext, this, 52, file, null, null, null)).longValue();
    }
    catch (Throwable localThrowable) {}
    return -1L;
  }
  
  public long lastModified(File file)
  {
    try
    {
      return ((Long)PrivilegedRunner.doPrivileged(controlContext, this, 55, file, null, null, null)).longValue();
    }
    catch (Exception localException) {}
    return -1L;
  }
  
  public String[] list(File file)
  {
    try
    {
      return (String[])PrivilegedRunner.doPrivileged(controlContext, this, 56, file, null, null, null);
    }
    catch (Exception localException) {}
    return null;
  }
  
  public boolean delete(File file)
  {
    try
    {
      return ((Boolean)PrivilegedRunner.doPrivileged(controlContext, this, 57, file, null, null, null)).booleanValue();
    }
    catch (Exception t)
    {
      throw new RuntimeException(t.getMessage());
    }
  }
  
  public boolean renameTo(File source, File target)
  {
    try
    {
      return ((Boolean)PrivilegedRunner.doPrivileged(controlContext, this, 58, source, target, null, null)).booleanValue();
    }
    catch (Exception t)
    {
      throw new RuntimeException(t.getMessage());
    }
  }
  
  public Object getService(ServiceReference reference, BundleContext context)
  {
    if (context == null) {
      throw new NullPointerException("Context is null");
    }
    if (reference == null) {
      throw new NullPointerException("Reference is null");
    }
    try
    {
      return PrivilegedRunner.doPrivileged(controlContext, this, 61, context, reference, null, null);
    }
    catch (Exception t)
    {
      throw new RuntimeException(t.getMessage());
    }
  }
  
  public ServiceReference[] getServiceReferences(String clazz, String filter, B
1 2 3 4

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