org.eclipse.osgi_3.8.2.v20130124-134944

    checkShutdown();
    if (listener == null) {
      throw new IllegalArgumentException("LogListener must not be null");
    }
    factory.removeLogListener(listener);
    listeners.remove(listener);
  }
  
  private synchronized void checkShutdown()
  {
    if (listeners == null) {
      throw new IllegalStateException("LogReaderService is shutdown.");
    }
  }
  
  synchronized void shutdown()
  {
    for (Iterator localIterator = listeners.iterator(); localIterator.hasNext();)
    {
      LogListener listener = (LogListener)localIterator.next();
      factory.removeLogListener(listener);
    }
    listeners = null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.log.internal.ExtendedLogReaderServiceImpl
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.log.internal;

import java.security.Permission;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.equinox.log.ExtendedLogService;
import org.eclipse.equinox.log.LogPermission;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleListener;
import org.osgi.framework.ServiceFactory;
import org.osgi.framework.ServiceRegistration;

public class ExtendedLogServiceFactory
  implements ServiceFactory<ExtendedLogService>, BundleListener
{
  private final Permission logPermission = new LogPermission("*", "log");
  private final ExtendedLogReaderServiceFactory logReaderServiceFactory;
  private final Map<Bundle, ExtendedLogService> logServices = new HashMap();
  
  public ExtendedLogServiceFactory(ExtendedLogReaderServiceFactory logReaderServiceFactory)
  {
    this.logReaderServiceFactory = logReaderServiceFactory;
  }
  
  public ExtendedLogServiceImpl getService(Bundle bundle, ServiceRegistration<ExtendedLogService> registration)
  {
    return getLogService(bundle);
  }
  
  public void ungetService(Bundle bundle, ServiceRegistration<ExtendedLogService> registration, ExtendedLogService service) {}
  
  public void bundleChanged(BundleEvent event)
  {
    if (event.getType() == 16) {
      removeLogService(event.getBundle());
    }
  }
  
  synchronized ExtendedLogServiceImpl getLogService(Bundle bundle)
  {
    ExtendedLogServiceImpl logService = (ExtendedLogServiceImpl)logServices.get(bundle);
    if (logService == null)
    {
      logService = new ExtendedLogServiceImpl(this, bundle);
      if ((bundle != null) && (bundle.getState() != 1)) {
        logServices.put(bundle, logService);
      }
    }
    return logService;
  }
  
  synchronized void shutdown()
  {
    logServices.clear();
  }
  
  synchronized void removeLogService(Bundle bundle)
  {
    logServices.remove(bundle);
  }
  
  boolean isLoggable(Bundle bundle, String name, int level)
  {
    return logReaderServiceFactory.isLoggable(bundle, name, level);
  }
  
  void log(Bundle bundle, String name, Object context, int level, String message, Throwable exception)
  {
    logReaderServiceFactory.log(bundle, name, context, level, message, exception);
  }
  
  void checkLogPermission()
    throws SecurityException
  {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
      sm.checkPermission(logPermission);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.log.internal.ExtendedLogServiceFactory
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.log.internal;

import java.util.HashMap;
import org.eclipse.equinox.log.ExtendedLogService;
import org.eclipse.equinox.log.Logger;
import org.osgi.framework.Bundle;
import org.osgi.framework.ServiceReference;
import org.osgi.service.log.LogService;

public class ExtendedLogServiceImpl
  implements ExtendedLogService, LogService
{
  private final ExtendedLogServiceFactory factory;
  private volatile Bundle bundle;
  private final HashMap<String, Logger> loggerCache = new HashMap();
  
  public ExtendedLogServiceImpl(ExtendedLogServiceFactory factory, Bundle bundle)
  {
    this.factory = factory;
    this.bundle = bundle;
  }
  
  public void log(int level, String message)
  {
    log(null, level, message, null);
  }
  
  public void log(int level, String message, Throwable exception)
  {
    log(null, level, message, exception);
  }
  
  public void log(ServiceReference sr, int level, String message)
  {
    log(sr, level, message, null);
  }
  
  public void log(ServiceReference sr, int level, String message, Throwable exception)
  {
    getLogger(null).log(sr, level, message, exception);
  }
  
  public void log(Object context, int level, String message)
  {
    log(context, level, message, null);
  }
  
  public void log(Object context, int level, String message, Throwable exception)
  {
    getLogger(null).log(context, level, message, exception);
  }
  
  public synchronized Logger getLogger(String name)
  {
    Logger logger = (Logger)loggerCache.get(name);
    if (logger == null)
    {
      logger = new LoggerImpl(this, name);
      loggerCache.put(name, logger);
    }
    return logger;
  }
  
  public Logger getLogger(Bundle logBundle, String name)
  {
    if ((logBundle == null) || (logBundle == bundle)) {
      return getLogger(name);
    }
    factory.checkLogPermission();
    ExtendedLogService bundleLogService = factory.getLogService(logBundle);
    return bundleLogService.getLogger(name);
  }
  
  public String getName()
  {
    return getLogger(null).getName();
  }
  
  public boolean isLoggable(int level)
  {
    return getLogger(null).isLoggable(level);
  }
  
  boolean isLoggable(String name, int level)
  {
    return factory.isLoggable(bundle, name, level);
  }
  
  void log(String name, Object context, int level, String message, Throwable exception)
  {
    factory.log(bundle, name, context, level, message, exception);
  }
  
  void setBundle(Bundle bundle)
  {
    this.bundle = bundle;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.log.internal.ExtendedLogServiceImpl
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.log.internal;

import java.io.File;
import java.io.InputStream;
import java.net.URL;
import java.security.cert.X509Certificate;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.Version;

class LogServiceManager$MockSystemBundle
  implements Bundle
{
  public int compareTo(Bundle o)
  {
    long idcomp = getBundleId() - o.getBundleId();
    return idcomp > 0L ? 1 : idcomp < 0L ? -1 : 0;
  }
  
  public int getState()
  {
    return 4;
  }
  
  public void start(int options) {}
  
  public void start() {}
  
  public void stop(int options) {}
  
  public void stop() {}
  
  public void update(InputStream input) {}
  
  public void update() {}
  
  public void uninstall() {}
  
  public Dictionary<String, String> getHeaders()
  {
    return new Hashtable();
  }
  
  public long getBundleId()
  {
    return 0L;
  }
  
  public String getLocation()
  {
    return "System Bundle";
  }
  
  public ServiceReference<?>[] getRegisteredServices()
  {
    return null;
  }
  
  public ServiceReference<?>[] getServicesInUse()
  {
    return null;
  }
  
  public boolean hasPermission(Object permission)
  {
    return true;
  }
  
  public URL getResource(String name)
  {
    return null;
  }
  
  public Dictionary<String, String> getHeaders(String locale)
  {
    return null;
  }
  
  public String getSymbolicName()
  {
    return "org.eclipse.osgi";
  }
  
  public Class<?> loadClass(String name)
    throws ClassNotFoundException
  {
    throw new ClassNotFoundException();
  }
  
  public Enumeration<URL> getResources(String name)
  {
    return null;
  }
  
  public Enumeration<String> getEntryPaths(String path)
  {
    return null;
  }
  
  public URL getEntry(String path)
  {
    return null;
  }
  
  public long getLastModified()
  {
    return System.currentTimeMillis();
  }
  
  public Enumeration<URL> findEntries(String path, String filePattern, boolean recurse)
  {
    return null;
  }
  
  public BundleContext getBundleContext()
  {
    return null;
  }
  
  public Map<X509Certificate, List<X509Certificate>> getSignerCertificates(int signersType)
  {
    return new HashMap();
  }
  
  public Version getVersion()
  {
    return new Version(0, 0, 0);
  }
  
  public <A> A adapt(Class<A> type)
  {
    return null;
  }
  
  public File getDataFile(String filename)
  {
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.log.internal.LogServiceManager.MockSystemBundle
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.log.internal;

import java.io.File;
import java.io.InputStream;
import java.net.URL;
import java.security.cert.X509Certificate;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import org.eclipse.equinox.log.ExtendedLogReaderService;
import org.eclipse.equinox.log.ExtendedLogService;
import org.eclipse.equinox.log.LogFilter;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleListener;
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.FrameworkListener;
import org.osgi.framework.ServiceEvent;
import org.osgi.framework.ServiceListener;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.framework.Version;
import org.osgi.service.log.LogListener;
import org.osgi.service.log.LogReaderService;
import org.osgi.service.log.LogService;

public class LogServiceManager
  implements BundleListener, FrameworkListener, ServiceListener
{
  private static final String[] LOGSERVICE_CLASSES = { LogService.class.getName(), ExtendedLogService.class.getName() };
  private static final String[] LOGREADERSERVICE_CLASSES = { LogReaderService.class.getName(), ExtendedLogReaderService.class.getName() };
  private ServiceRegistration<?> logReaderServiceRegistration;
  private ServiceRegistration<?> logServiceRegistration;
  private final ExtendedLogReaderServiceFactory logReaderServiceFactory = new ExtendedLogReaderServiceFactory();
  private final ExtendedLogServiceFactory logServiceFactory = new ExtendedLogServiceFactory(logReaderServiceFactory);
  private final ExtendedLogServiceImpl systemBundleLog = logServiceFactory.getLogService(new MockSystemBundle());
  private EventAdminAdapter eventAdminAdapter;
  
  public LogServiceManager(LogListener[] systemListeners)
  {
    LogListener[] arrayOfLogListener;
    int j = (arrayOfLogListener = systemListeners).length;
    for (int i = 0; i < j; i++)
    {
      LogListener logListener = arrayOfLogListener[i];
      if ((logListener instanceof LogFilter)) {
        logReaderServiceFactory.addLogListener(logListener, (LogFilter)logListener);
      } else {
        logReaderServiceFactory.addLogListener(logListener, ExtendedLogReaderServiceFactory.NULL_LOGGER_FILTER);
      }
    }
  }
  
  public void start(BundleContext context)
  {
    systemBundleLog.setBundle(context.getBundle());
    context.addBundleListener(this);
    context.addServiceListener(this);
    context.addFrameworkListener(this);
    
    context.addBundleListener(logServiceFactory);
    logReaderServiceRegistration = context.registerService(LOGREADERSERVICE_CLASSES, logReaderServiceFactory, null);
    logServiceRegistration = context.registerService(LOGSERVICE_CLASSES, logServiceFactory, null);
    
    eventAdminAdapter = new EventAdminAdapter(context, logReaderServiceFactory);
    eventAdminAdapter.start();
  }
  
  public void stop(BundleContext context)
  {
    eventAdminAdapter.stop();
    eventAdminAdapter = null;
    logServiceRegistration.unregister();
    logServiceRegistration = null;
    logReaderServiceRegistration.unregister();
    logReaderServiceRegistration = null;
    logServiceFactory.shutdown();
    context.removeFrameworkListener(this);
    context.removeServiceListener(this);
    context.removeBundleListener(this);
  }
  
  public ExtendedLogService getSystemBundleLog()
  {
    return systemBundleLog;
  }
  
  public void bundleChanged(BundleEvent event)
  {
    Bundle bundle = event.getBundle();
    if (logReaderServiceFactory.isLoggable(bundle, null, 3)) {
      logReaderServiceFactory.log(bundle, null, null, 3, getBundleEventTypeName(event.getType()), null);
    }
  }
  
  public void serviceChanged(ServiceEvent event)
  {
    ServiceReference<?> reference = event.getServiceReference();
    Bundle bundle = reference.getBundle();
    int eventType = event.getType();
    int logType = eventType == 2 ? 4 : 3;
    if (logReaderServiceFactory.isLoggable(bundle, null, logType)) {
      logReaderServiceFactory.log(bundle, null, reference, logType, getServiceEventTypeName(eventType), null);
    }
  }
  
  public void frameworkEvent(FrameworkEvent event)
  {
    Bundle bundle = event.getBundle();
    int eventType = event.getType();
    int logType = eventType == 2 ? 1 : 3;
    Throwable throwable = eventType == 2 ? event.getThrowable() : null;
    if (logReaderServiceFactory.isLoggable(bundle, null, logType)) {
      logReaderServiceFactory.log(bundle, null, null, logType, getFrameworkEventTypeName(eventType), throwable);
    }
  }
  
  private static String getBundleEventTypeName(int type)
  {
    switch (type)
    {
    case 1: 
      return "BundleEvent INSTALLED";
    case 32: 
      return "BundleEvent RESOLVED";
    case 2: 
      return "BundleEvent STARTED";
    case 128: 
      return "BundleEvent STARTING";
    case 4: 
      return "BundleEvent STOPPED";
    case 256: 
      return "BundleEvent STOPPING";
    case 16: 
      return "BundleEvent UNINSTALLED";
    case 64: 
      return "BundleEvent UNRESOLVED";
    case 8: 
      return "BundleEvent UPDATED";
    }
    return "BundleEvent " + Integer.toHexString(type);
  }
  
  private static String getServiceEventTypeName(int type)
  {
    switch (type)
    {
    case 1: 
      return "ServiceEvent REGISTERED";
    case 2: 
      return "ServiceEvent MODIFIED";
    case 4: 
      return "ServiceEvent UNREGISTERING";
    }
    return "ServiceEvent " + Integer.toHexString(type);
  }
  
  private static String getFrameworkEventTypeName(int type)
  {
    switch (type)
    {
    case 2: 
      return "FrameworkEvent ERROR";
    case 32: 
      return "FrameworkEvent INFO";
    case 4: 
      return "FrameworkEvent PACKAGES REFRESHED";
    case 1: 
      return "FrameworkEvent STARTED";
    case 8: 
      return "FrameworkEvent STARTLEVEL CHANGED";
    case 16: 
      return "FrameworkEvent WARNING";
    }
    return "FrameworkEvent " + Integer.toHexString(type);
  }
  
  static class MockSystemBundle
    implements Bundle
  {
    public int compareTo(Bundle o)
    {
      long idcomp = getBundleId() - o.getBundleId();
      return idcomp > 0L ? 1 : idcomp < 0L ? -1 : 0;
    }
    
    public int getState()
    {
      return 4;
    }
    
    public void start(int options) {}
    
    public void start() {}
    
    public void stop(int options) {}
    
    public void stop() {}
    
    public void update(InputStream input) {}
    
    public void update() {}
    
    public void uninstall() {}
    
    public Dictionary<String, String> getHeaders()
    {
      return new Hashtable();
    }
    
    public long getBundleId()
    {
      return 0L;
    }
    
    public String getLocation()
    {
      return "System Bundle";
    }
    
    public ServiceReference<?>[] getRegisteredServices()
    {
      return null;
    }
    
    public ServiceReference<?>[] getServicesInUse()
    {
      return null;
    }
    
    public boolean hasPermission(Object permission)
    {
      return true;
    }
    
    public URL getResource(String name)
    {
      return null;
    }
    
    public Dictionary<String, String> getHeaders(String locale)
    {
      return null;
    }
    
    public String getSymbolicName()
    {
      return "org.eclipse.osgi";
    }
    
    public Class<?> loadClass(String name)
      throws ClassNotFoundException
    {
      throw new ClassNotFoundException();
    }
    
    public Enumeration<URL> getResources(String name)
    {
      return null;
    }
    
    public Enumeration<String> getEntryPaths(String path)
    {
      return null;
    }
    
    public URL getEntry(String path)
    {
      return null;
    }
    
    public long getLastModified()
    {
      return System.currentTimeMillis();
    }
    
    public Enumeration<URL> findEntries(String path, String filePattern, boolean recurse)
    {
      return null;
    }
    
    public BundleContext getBundleContext()
    {
      return null;
    }
    
    public Map<X509Certificate, List<X509Certificate>> getSignerCertificates(int signersType)
    {
      return new HashMap();
    }
    
    public Version getVersion()
    {
      return new Version(0, 0, 0);
    }
    
    public <A> A adapt(Class<A> type)
    {
      return null;
    }
    
    public File getDataFile(String filename)
    {
      return null;
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.log.internal.LogServiceManager
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.log.internal;

import org.eclipse.equinox.log.Logger;
import org.osgi.framework.ServiceReference;

public class LoggerImpl
  implements Logger
{
  private final ExtendedLogServiceImpl logServiceImpl;
  private final String name;
  
  public LoggerImpl(ExtendedLogServiceImpl logServiceImpl, String name)
  {
    this.logServiceImpl = logServiceImpl;
    this.name = name;
  }
  
  public String getName()
  {
    return name;
  }
  
  public boolean isLoggable(int level)
  {
    return logServiceImpl.isLoggable(name, level);
  }
  
  public void log(int level, String message)
  {
    log(null, level, message, null);
  }
  
  public void log(int level, String message, Throwable exception)
  {
    log(null, level, message, exception);
  }
  
  public void log(ServiceReference sr, int level, String message)
  {
    log(sr, level, message, null);
  }
  
  public void log(ServiceReference sr, int level, String message, Throwable exception)
  {
    logServiceImpl.log(name, sr, level, message, exception);
  }
  
  public void log(Object context, int level, String message)
  {
    log(context, level, message, null);
  }
  
  public void log(Object context, int level, String message, Throwable exception)
  {
    logServiceImpl.log(name, context, level, message, exception);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.log.internal.LoggerImpl
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.log.internal;

class SerializedTaskQueue$1
  extends Thread
{
  final SerializedTaskQueue this$0;
  
  SerializedTaskQueue$1(SerializedTaskQueue paramSerializedTaskQueue, String $anonymous0)
  {
    super($anonymous0);
  }
  
  public void run()
  {
    Runnable task = this$0.nextTask(5000);
    while (task != null)
    {
      task.run();
      task = this$0.nextTask(5000);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.log.internal.SerializedTaskQueue.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.log.internal;

import java.util.LinkedList;

public class SerializedTaskQueue
{
  private static final int MAX_WAIT = 5000;
  private final LinkedList<Runnable> tasks = new LinkedList();
  private Thread thread;
  private final String queueName;
  
  public SerializedTaskQueue(String queueName)
  {
    this.queueName = queueName;
  }
  
  public synchronized void put(Runnable newTask)
  {
    tasks.add(newTask);
    if (thread == null)
    {
      thread = new Thread(queueName)
      {
        public void run()
        {
          Runnable task = nextTask(5000);
          while (task != null)
          {
            task.run();
            task = nextTask(5000);
          }
        }
      };
      thread.start();
    }
    else
    {
      notify();
    }
  }
  
  synchronized Runnable nextTask(int maxWait)
  {
    if (tasks.isEmpty())
    {
      try
      {
        wait(maxWait);
      }
      catch (InterruptedException localInterruptedException) {}
      if (tasks.isEmpty())
      {
        thread = null;
        return null;
      }
    }
    return (Runnable)tasks.removeFirst();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.log.internal.SerializedTaskQueue
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.baseadaptor;

class BaseAdaptor$1
  extends ClassLoader
{
  BaseAdaptor$1(ClassLoader $anonymous0)
  {
    super($anonymous0);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.baseadaptor.BaseAdaptor.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.baseadaptor;

import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.io.Writer;
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 BaseAdaptor$2
  implements FrameworkLog
{
  final BaseAdaptor this$0;
  
  BaseAdaptor$2(BaseAdaptor paramBaseAdaptor) {}
  
  public void log(FrameworkEvent frameworkEvent)
  {
    log(new FrameworkLogEntry(frameworkEvent.getBundle().getSymbolicName() == null ? frameworkEvent.getBundle().getLocation() : frameworkEvent.getBundle().getSymbolicName(), 4, 0, "FrameworkEvent.ERROR", 0, frameworkEvent.getThrowable(), null));
  }
  
  public void log(FrameworkLogEntry logEntry)
  {
    System.err.print(logEntry.getEntry() + " ");
    System.err.println(logEntry.getMessage());
    if (logEntry.getThrowable() != null) {
      logEntry.getThrowable().printStackTrace(System.err);
    }
  }
  
  public void setWriter(Writer newWriter, boolean append) {}
  
  public void setFile(File newFile, boolean append)
    throws IOException
  {}
  
  public File getFile()
  {
    return null;
  }
  
  public void setConsoleLog(boolean consoleLog) {}
  
  public void close() {}
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.baseadaptor.BaseAdaptor.2
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.baseadaptor;

import org.eclipse.osgi.framework.adaptor.BundleWatcher;
import org.osgi.framework.Bundle;

class BaseAdaptor$3
  implements BundleWatcher
{
  final BaseAdaptor this$0;
  
  BaseAdaptor$3(BaseAdaptor paramBaseAdaptor, BundleWatcher[] paramArrayOfBundleWatcher) {}
  
  public void watchBundle(Bundle bundle, int type)
  {
    for (int i = 0; i < val$watchers.length; i++) {
      val$watchers[i].watchBundle(bundle, type);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.baseadaptor.BaseAdaptor.3
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.baseadaptor;

import java.net.URL;
import java.util.Enumeration;
import java.util.NoSuchElementException;
import org.eclipse.osgi.framework.adaptor.BundleData;

class BaseAdaptor$4
  implements Enumeration<URL>
{
  private int curPathIndex = 0;
  private int curDataIndex = 0;
  private URL nextElement = null;
  final BaseAdaptor this$0;
  
  BaseAdaptor$4(BaseAdaptor paramBaseAdaptor, String[] paramArrayOfString, BundleData[] paramArrayOfBundleData) {}
  
  public boolean hasMoreElements()
  {
    if (nextElement != null) {
      return true;
    }
    getNextElement();
    return nextElement != null;
  }
  
  public URL nextElement()
  {
    if (!hasMoreElements()) {
      throw new NoSuchElementException();
    }
    URL result = nextElement;
    
    getNextElement();
    return result;
  }
  
  private void getNextElement()
  {
    nextElement = null;
    if (curPathIndex >= val$pathArray.length) {
      return;
    }
    while ((nextElement == null) && (curPathIndex < val$pathArray.length))
    {
      String curPath = val$pathArray[curPathIndex];
      while ((nextElement == null) && (curDataIndex < val$dataArray.length)) {
        nextElement = val$dataArray[(curDataIndex++)].getEntry(curPath);
      }
      if (curDataIndex >= val$dataArray.length)
      {
        curPathIndex += 1;
        curDataIndex = 0;
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.baseadaptor.BaseAdaptor.4
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.baseadaptor;

import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.io.Writer;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import org.eclipse.core.runtime.adaptor.LocationManager;
import org.eclipse.osgi.baseadaptor.bundlefile.BundleFile;
import org.eclipse.osgi.baseadaptor.hooks.AdaptorHook;
import org.eclipse.osgi.baseadaptor.hooks.ClassLoadingHook;
import org.eclipse.osgi.baseadaptor.hooks.StorageHook;
import org.eclipse.osgi.framework.adaptor.BundleData;
import org.eclipse.osgi.framework.adaptor.BundleOperation;
import org.eclipse.osgi.framework.adaptor.BundleWatcher;
import org.eclipse.osgi.framework.adaptor.EventPublisher;
import org.eclipse.osgi.framework.adaptor.FrameworkAdaptor;
import org.eclipse.osgi.framework.adaptor.PermissionStorage;
import org.eclipse.osgi.framework.internal.core.FilterImpl;
import org.eclipse.osgi.framework.internal.core.Framework;
import org.eclipse.osgi.framework.internal.core.FrameworkProperties;
import org.eclipse.osgi.framework.log.FrameworkLog;
import org.eclipse.osgi.framework.log.FrameworkLogEntry;
import org.eclipse.osgi.internal.baseadaptor.AdaptorMsg;
import org.eclipse.osgi.internal.baseadaptor.BaseStorage;
import org.eclipse.osgi.internal.baseadaptor.BaseStorageHook;
import org.eclipse.osgi.internal.baseadaptor.StateManager;
import org.eclipse.osgi.internal.baseadaptor.SystemBundleData;
import org.eclipse.osgi.service.resolver.PlatformAdmin;
import org.eclipse.osgi.service.resolver.State;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.Filter;
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.InvalidSyntaxException;

public class BaseAdaptor
  implements FrameworkAdaptor
{
  private static final String PROP_PARENT_CLASSLOADER = "osgi.parentClassloader";
  private static final String PARENT_CLASSLOADER_APP = "app";
  private static final String PARENT_CLASSLOADER_EXT = "ext";
  private static final String PARENT_CLASSLOADER_BOOT = "boot";
  private static final String PARENT_CLASSLOADER_FWK = "fwk";
  private static ClassLoader bundleClassLoaderParent;
  private Framework eventPublisher;
  private boolean stopping;
  private HookRegistry hookRegistry;
  private FrameworkLog log;
  private BundleContext context;
  private BaseStorage storage;
  private BundleWatcher bundleWatcher;
  
  static
  {
    String type = FrameworkProperties.getProperty("org.osgi.framework.bundle.parent");
    if (type != null)
    {
      if ("framework".equals(type)) {
        type = "fwk";
      }
    }
    else {
      type = FrameworkProperties.getProperty("osgi.parentClassloader", "boot");
    }
    if ("fwk".equalsIgnoreCase(type))
    {
      bundleClassLoaderParent = FrameworkAdaptor.class.getClassLoader();
    }
    else if ("app".equalsIgnoreCase(type))
    {
      bundleClassLoaderParent = ClassLoader.getSystemClassLoader();
    }
    else if ("ext".equalsIgnoreCase(type))
    {
      ClassLoader appCL = ClassLoader.getSystemClassLoader();
      if (appCL != null) {
        bundleClassLoaderParent = appCL.getParent();
      }
    }
    if (bundleClassLoaderParent == null) {
      bundleClassLoaderParent = new ClassLoader(Object.class.getClassLoader()) {};
    }
  }
  
  public BaseAdaptor(String[] args)
  {
    if (LocationManager.getConfigurationLocation() == null) {
      LocationManager.initializeLocations();
    }
    hookRegistry = new HookRegistry(this);
    FrameworkLogEntry[] errors = hookRegistry.initialize();
    if (errors.length > 0) {
      for (int i = 0; i < errors.length; i++) {
        getFrameworkLog().log(errors[i]);
      }
    }
    storage = getStorage();
  }
  
  public void initialize(EventPublisher publisher)
  {
    eventPublisher = ((Framework)publisher);
    
    AdaptorHook[] adaptorHooks = getHookRegistry().getAdaptorHooks();
    for (int i = 0; i < adaptorHooks.length; i++) {
      adaptorHooks[i].initialize(this);
    }
  }
  
  public void initializeStorage()
    throws IOException
  {
    storage.initialize(this);
  }
  
  public void compactStorage()
    throws IOException
  {
    storage.compact();
  }
  
  /* Error */
  public java.util.Properties getProperties()
  {
    // Byte code:
    //   0: new 277	java/util/Properties
    //   3: dup
    //   4: invokespecial 569	java/util/Properties:<init>	()V
    //   7: astore_1
    //   8: ldc 10
    //   10: ldc 12
    //   12: invokestatic 597	org/eclipse/osgi/framework/internal/core/FrameworkProperties:getProperty	(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    //   15: astore_2
    //   16: aconst_null
    //   17: astore_3
    //   18: new 259	java/io/File
    //   21: dup
    //   22: aload_2
    //   23: invokespecial 535	java/io/File:<init>	(Ljava/lang/String;)V
    //   26: astore 4
    //   28: aload 4
    //   30: invokevirtual 534	java/io/File:exists	()Z
    //   33: ifeq +13 -> 46
    //   36: new 260	java/io/FileInputStream
    //   39: dup
    //   40: aload 4
    //   42: invokespecial 536	java/io/FileInputStream:<init>	(Ljava/io/File;)V
    //   45: astore_3
    //   46: aload_3
    //   47: ifnonnull +12 -> 59
    //   50: aload_0
    //   51: invokevirtual 546	java/lang/Object:getClass	()Ljava/lang/Class;
    //   54: aload_2
    //   55: invokevirtual 540	java/lang/Class:getResourceAsStream	(Ljava/lang/String;)Ljava/io/InputStream;
    //   58: astore_3
    //   59: aload_3
    //   60: ifnull +42 -> 102
    //   63: aload_1
    //   64: new 258	java/io/BufferedInputStream
    //   67: dup
    //   68: aload_3
    //   69: invokespecial 533	java/io/BufferedInputStream:<init>	(Ljava/io/InputStream;)V
    //   72: invokevirtual 570	java/util/Properties:load	(Ljava/io/InputStream;)V
    //   75: goto +16 -> 91
    //   78: astore 5
    //   80: aload_3
    //   81: invokevirtual 538	java/io/InputStream:close	()V
    //   84: goto +4 -> 88
    //   87: pop
    //   88: aload 5
    //   90: athrow
    //   91: aload_3
    //   92: invokevirtual 538	java/io/InputStream:close	()V
    //   95: goto +65 -> 160
    //   98: pop
    //   99: goto +61 -> 160
    //   102: getstatic 531	org/eclipse/osgi/framework/debug/Debug:DEBUG_GENERAL	Z
    //   105: ifeq +55 -> 160
    //   108: new 269	java/lang/StringBuffer
    //   111: dup
    //   112: ldc 1
    //   114: invokespecial 559	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   117: aload_2
    //   118: invokevirtual 561	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   121: invokevirtual 558	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   124: invokestatic 592	org/eclipse/osgi/framework/debug/Debug:println	(Ljava/lang/String;)V
    //   127: goto +33 -> 160
    //   130: astore_3
    //   131: getstatic 531	org/eclipse/osgi/framework/debug/Debug:DEBUG_GENERAL	Z
    //   134: ifeq +26 -> 160
    //   137: new 269	java/lang/StringBuffer
    //   140: dup
    //   141: ldc_w 254
    //   144: invokespecial 559	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   147: aload_3
    //   148: invokevirtual 537	java/io/IOException:getMessage	()Ljava/lang/String;
    //   151: invokevirtual 561	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   154: invokevirtual 558	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   157: invokestatic 592	org/eclipse/osgi/framework/debug/Debug:println	(Ljava/lang/String;)V
    //   160: aload_0
    //   161: getfield 529	org/eclipse/osgi/baseadaptor/BaseAdaptor:storage	Lorg/eclipse/osgi/internal/baseadaptor/BaseStorage;
    //   164: aload_1
    //   165: invokevirtual 603	org/eclipse/osgi/internal/baseadaptor/BaseStorage:addProperties	(Ljava/util/Properties;)V
    //   168: aload_0
    //   169: invokevirtual 573	org/eclipse/osgi/baseadaptor/BaseAdaptor:getHookRegistry	()Lorg/eclipse/osgi/baseadaptor/HookRegistry;
    //   172: invokevirtual 585	org/eclipse/osgi/baseadaptor/HookRegistry:getAdaptorHooks	()[Lorg/eclipse/osgi/baseadaptor/hooks/AdaptorHook;
    //   175: astore_3
    //   176: iconst_0
    //   177: istore 4
    //   179: goto +16 -> 195
    //   182: aload_3
    //   183: iload 4
    //   185: aaload
    //   186: aload_1
    //   187: invokeinterface 631 2 0
    //   192: iinc 4 1
    //   195: iload 4
    //   197: aload_3
    //   198: arraylength
    //   199: if_icmplt -17 -> 182
    //   202: aload_1
    //   203: areturn
    // Line number table:
    //   Java source line #139	-> byte code offset #0
    //   Java source line #140	-> byte code offset #8
    //   Java source line #142	-> byte code offset #16
    //   Java source line #143	-> byte code offset #18
    //   Java source line #144	-> byte code offset #28
    //   Java source line #145	-> byte code offset #36
    //   Java source line #146	-> byte code offset #46
    //   Java source line #147	-> byte code offset #50
    //   Java source line #148	-> byte code offset #59
    //   Java source line #150	-> byte code offset #63
    //   Java source line #151	-> byte code offset #75
    //   Java source line #153	-> byte code offset #80
    //   Java source line #154	-> byte code offset #84
    //   Java source line #157	-> byte code offset #88
    //   Java source line #153	-> byte code offset #91
    //   Java source line #154	-> byte code offset #95
    //   Java source line #158	-> byte code offset #99
    //   Java source line #159	-> byte code offset #102
    //   Java source line #160	-> byte code offset #108
    //   Java source line #162	-> byte code offset #127
    //   Java source line #163	-> byte code offset #131
    //   Java source line #164	-> byte code offset #137
    //   Java source line #167	-> byte code offset #160
    //   Java source line #169	-> byte code offset #168
    //   Java source line #170	-> byte code offset #176
    //   Java source line #171	-> byte code offset #182
    //   Java source line #170	-> byte code offset #192
    //   Java source line #172	-> byte code offset #202
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	204	0	this	BaseAdaptor
    //   7	196	1	props	java.util.Properties
    //   15	103	2	resource	String
    //   17	75	3	in	java.io.InputStream
    //   130	18	3	e	IOException
    //   175	23	3	adaptorHooks	AdaptorHook[]
    //   26	15	4	file	File
    //   177	19	4	i	int
    //   78	11	5	localObject	Object
    //   87	1	9	localIOException1	IOException
    //   98	1	10	localIOException2	IOException
    // Exception table:
    //   from	to	target	type
    //   63	78	78	finally
    //   80	84	87	java/io/IOException
    //   91	95	98	java/io/IOException
    //   16	127	130	java/io/IOException
  }
  
  public BundleData[] getInstalledBundles()
  {
    return storage.getInstalledBundles();
  }
  
  public URLConnection mapLocationToURLConnection(String location)
    throws BundleException
  {
    try
    {
      URLConnection result = null;
      
      AdaptorHook[] adaptorHooks = getHookRegistry().getAdaptorHooks();
      for (int i = 0; i < adaptorHooks.length; i++)
      {
        result = adaptorHooks[i].mapLocationToURLConnection(location);
        if (result != null) {
          return result;
        }
      }
      return new URL(location).openConnection();
    }
    catch (IOException e)
    {
      throw new BundleException(NLS.bind(AdaptorMsg.ADAPTOR_URL_CREATE_EXCEPTION, location), e);
    }
  }
  
  public BundleOperation installBundle(String location, URLConnection source)
  {
    return storage.installBundle(location, source);
  }
  
  public BundleOperation updateBundle(BundleData bundledata, URLConnection source)
  {
    return storage.updateBundle((BaseData)bundledata, source);
  }
  
  public BundleOperation uninstallBundle(BundleData bundledata)
  {
    return storage.uninstallBundle((BaseData)bundledata);
  }
  
  public long getTotalFreeSpace()
    throws IOException
  {
    return storage.getFreeSpace();
  }
  
  public PermissionStorage getPermissionStorage()
    throws IOException
  {
    return storage.getPermissionStorage();
  }
  
  public void frameworkStart(BundleContext fwContext)
    throws BundleException
  {
    context = fwContext;
    stopping = false;
    
    storage.frameworkStart(fwContext);
    AdaptorHook[] adaptorHooks = getHookRegistry().getAdaptorHooks();
    for (int i = 0; i < adaptorHooks.length; i++) {
      adaptorHooks[i].frameworkStart(fwContext);
    }
  }
  
  public void frameworkStop(BundleContext fwContext)
    throws BundleException
  {
    AdaptorHook[] adaptorHooks = getHookRegistry().getAdaptorHooks();
    for (int i = 0; i < adaptorHooks.length; i++) {
      adaptorHooks[i].frameworkStop(fwContext);
    }
    storage.frameworkStop(fwContext);
  }
  
  public void frameworkStopping(BundleContext fwContext)
  {
    stopping = true;
    
    storage.frameworkStopping(fwContext);
    
    AdaptorHook[] adaptorHooks = getHookRegistry().getAdaptorHooks();
    for (int i = 0; i < adaptorHooks.length; i++) {
      adaptorHooks[i].frameworkStopping(fwContext);
    }
  }
  
  public int getInitialBundleStartLevel()
  {
    return storage.getInitialBundleStartLevel();
  }
  
  public void setInitialBundleStartLevel(int value)
  {
    storage.setInitialBundleStartLevel(value);
  }
  
  public FrameworkLog getFrameworkLog()
  {
    if (log != null) {
      return log;
    }
    AdaptorHook[] adaptorHooks = getHookRegistry().getAdaptorHooks();
    for (int i = 0; i < adaptorHooks.length; i++)
    {
      log = adaptorHooks[i].createFrameworkLog();
      if (log != null) {
        return log;
      }
    }
    log = new FrameworkLog()
    {
      public void log(FrameworkEvent frameworkEvent)
      {
        log(new FrameworkLogEntry(frameworkEvent.getBundle().getSymbolicName() == null ? frameworkEvent.getBundle().getLocation() : frameworkEvent.getBundle().getSymbolicName(), 4, 0, "FrameworkEvent.ERROR", 0, frameworkEvent.getThrowable(), null));
      }
      
      public void log(FrameworkLogEntry logEntry)
      {
        System.err.print(logEntry.getEntry() + " ");
        System.err.println(logEntry.getMessage());
        if (logEntry.getThrowable() != null) {
          logEntry.getThrowable().printStackTrace(System.err);
        }
      }
      
      public void setWriter(Writer newWriter, boolean append) {}
      
      public void setFile(File newFile, boolean append)
        throws IOException
      {}
      
      public File getFile()
      {
        return null;
      }
      
      public void setConsoleLog(boolean consoleLog) {}
      
      public void close() {}
    };
    return log;
  }
  
  public BundleData createSystemBundleData()
    throws BundleException
  {
    return new SystemBundleData(this);
  }
  
  public BundleWatcher getBundleWatcher()
  {
    if (bundleWatcher != null) {
      return bundleWatcher;
    }
    final BundleWatcher[] watchers = hookRegistry.getWatchers();
    if (watchers.length == 0) {
   
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87

Further reading...

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

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd