org.eclipse.osgi_3.8.2.v20130124-134944

 builtinSession;
  private ConsoleSocketGetter socketGetter;
  private final boolean isEnabled;
  private final String consoleBundle;
  
  class ConsoleSocketGetter
    implements Runnable
  {
    private final ServerSocket server;
    private volatile boolean shutdown = false;
    
    ConsoleSocketGetter(ServerSocket server)
    {
      this.server = server;
      try
      {
        Method reuseAddress = server.getClass().getMethod("setReuseAddress", new Class[] { Boolean.TYPE });
        reuseAddress.invoke(server, new Object[] { Boolean.TRUE });
      }
      catch (Exception localException) {}
      Thread t = new Thread(this, "ConsoleSocketGetter");
      t.setDaemon(false);
      t.start();
    }
    
    public void run()
    {
      System.out.println(NLS.bind(ConsoleMsg.CONSOLE_LISTENING_ON_PORT, server.getInetAddress().toString() + ':' + Integer.toString(server.getLocalPort())));
      while (!shutdown) {
        try
        {
          Socket socket = server.accept();
          if (socket == null) {
            throw new IOException("No socket available.  Probably caused by a shutdown.");
          }
          FrameworkConsoleSession session = new FrameworkConsoleSession(socket.getInputStream(), socket.getOutputStream(), socket); Class 
            tmp108_105 = ConsoleManager.class$0;
          if (tmp108_105 == null)
          {
            tmp108_105;
            try
            {
              tmpTernaryOp = (ConsoleManager.class$0 = Class.forName("org.eclipse.osgi.framework.console.ConsoleSession"));
            }
            catch (ClassNotFoundException localClassNotFoundException)
            {
              throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
            }
          }
          framework.getSystemBundleContext().registerService(tmp108_105.getName(), session, null);
        }
        catch (Exception e)
        {
          if (!shutdown) {
            e.printStackTrace();
          }
        }
      }
    }
    
    public void shutdown()
    {
      if (shutdown) {
        return;
      }
      shutdown = true;
      try
      {
        server.close();
      }
      catch (IOException e)
      {
        e.printStackTrace();
      }
    }
  }
  
  public ConsoleManager(Framework framework, String consolePropValue)
  {
    String port = null;
    String host = null;
    if (consolePropValue != null)
    {
      int index = consolePropValue.lastIndexOf(":");
      if (index > -1) {
        host = consolePropValue.substring(0, index);
      }
      port = consolePropValue.substring(index + 1);
    }
    this.framework = framework;
    consoleHost = (host != null ? host.trim() : host);
    consolePort = (port != null ? port.trim() : port);
    String enabled = FrameworkProperties.getProperty("osgi.console.enable.builtin", "org.eclipse.equinox.console");
    if ((!"true".equals(enabled)) || ("none".equals(port)))
    {
      isEnabled = false;
      cpTracker = null;
      sessions = null;
      consoleBundle = ("false".equals(enabled) ? "org.eclipse.equinox.console" : enabled);
      if ((consolePort == null) || (consolePort.length() > 0)) {
        FrameworkProperties.setProperty("gosh.args", "--nointeractive");
      } else {
        FrameworkProperties.setProperty("gosh.args", "--noshutdown");
      }
      return;
    }
    isEnabled = true;
    cpTracker = new ServiceTracker(framework.getSystemBundleContext(), CommandProvider.class.getName(), null);
    sessions = new ServiceTracker(framework.getSystemBundleContext(), ConsoleSession.class.getName(), this);
    consoleBundle = "unknown";
  }
  
  public static ConsoleManager startConsole(Framework framework)
  {
    ConsoleManager consoleManager = new ConsoleManager(framework, FrameworkProperties.getProperty("osgi.console"));
    consoleManager.startConsole();
    return consoleManager;
  }
  
  private void startConsole()
  {
    if (!isEnabled) {
      return;
    }
    cpTracker.open();
    sessions.open();
    fwkCommands = new FrameworkCommandProvider(framework);
    fwkCommands.start();
    if (consolePort == null) {
      return;
    }
    int port = -1;
    try
    {
      if (consolePort.length() > 0) {
        port = Integer.parseInt(consolePort);
      }
    }
    catch (NumberFormatException localNumberFormatException) {}
    if (port < 0)
    {
      InputStream in = new FilterInputStream(System.in)
      {
        public void close()
          throws IOException
        {}
      };
      OutputStream out = new FilterOutputStream(System.out)
      {
        public void close()
          throws IOException
        {}
        
        public void write(byte[] var0, int var1, int var2)
          throws IOException
        {
          out.write(var0, var1, var2);
        }
      };
      FrameworkConsoleSession session = new FrameworkConsoleSession(in, out, null);
      Dictionary<String, Object> props = null;
      props = new Hashtable(1);
      props.put("console.systemInOut", Boolean.TRUE);
      builtinSession = framework.getSystemBundleContext().registerService(ConsoleSession.class.getName(), session, props);
    }
    else
    {
      try
      {
        if (consoleHost != null) {
          socketGetter = new ConsoleSocketGetter(new ServerSocket(port, 0, InetAddress.getByName(consoleHost)));
        } else {
          socketGetter = new ConsoleSocketGetter(new ServerSocket(port));
        }
      }
      catch (IOException e)
      {
        e.printStackTrace();
      }
    }
  }
  
  public void checkForConsoleBundle()
    throws BundleException
  {
    if (isEnabled) {
      return;
    }
    if ("none".equals(consolePort)) {
      return;
    }
    Bundle[] consoles = framework.getBundleBySymbolicName(consoleBundle);
    if ((consoles == null) || (consoles.length == 0))
    {
      if (consolePort != null) {
        throw new BundleException("Could not find bundle: " + consoleBundle, 1);
      }
      return;
    }
    try
    {
      consoles[0].start(1);
    }
    catch (BundleException e)
    {
      throw new BundleException("Could not start bundle: " + consoleBundle, 1, e);
    }
  }
  
  public void stopConsole()
  {
    if (!isEnabled) {
      return;
    }
    if (builtinSession != null) {
      try
      {
        builtinSession.unregister();
      }
      catch (IllegalStateException localIllegalStateException) {}
    }
    sessions.close();
    cpTracker.close();
    if (socketGetter != null) {
      socketGetter.shutdown();
    }
    if (fwkCommands != null) {
      fwkCommands.stop();
    }
  }
  
  public FrameworkConsole addingService(ServiceReference<ConsoleSession> reference)
  {
    FrameworkConsole console = null;
    
    Boolean isSystemInOut = (Boolean)reference.getProperty("console.systemInOut");
    if (isSystemInOut == null) {
      isSystemInOut = Boolean.FALSE;
    }
    ConsoleSession session = (ConsoleSession)framework.getSystemBundleContext().getService(reference);
    console = new FrameworkConsole(framework.getSystemBundleContext(), session, isSystemInOut.booleanValue(), cpTracker);
    
    Thread t = new Thread(console, "OSGi Console");
    t.setDaemon(false);
    t.start();
    return console;
  }
  
  public void modifiedService(ServiceReference<ConsoleSession> reference, FrameworkConsole service) {}
  
  public void removedService(ServiceReference<ConsoleSession> reference, FrameworkConsole service)
  {
    service.shutdown();
  }
}

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

import org.eclipse.osgi.util.NLS;

public class ConsoleMsg
  extends NLS
{
  private static final String BUNDLE_NAME = "org.eclipse.osgi.framework.internal.core.ConsoleMessages";
  public static String CONSOLE_LINES_TO_SCROLL_NEGATIVE_ERROR;
  public static String CONSOLE_NESTED_EXCEPTION;
  public static String CONSOLE_ERROR_READING_RESOURCE;
  public static String CONSOLE_RESOURCE_NOT_IN_BUNDLE;
  public static String CONSOLE_MORE;
  public static String CONSOLE_HELP_CONTROLLING_CONSOLE_HEADING;
  public static String CONSOLE_HELP_MORE;
  public static String CONSOLE_HELP_DISCONNECT;
  public static String CONSOLE_CONFIRM_MORE;
  public static String CONSOLE_CONFIRM_DISCONNECT;
  public static String CONSOLE_CONFIRM;
  public static String CONSOLE_CONFIRM_VALUES;
  public static String CONSOLE_Y;
  public static String CONSOLE_N;
  public static String CONSOLE_PROMPT_DEFAULT;
  public static String CONSOLE_INVALID_INPUT;
  public static String CONSOLE_TOO_MUCH_INVALID_INPUT;
  public static String CONSOLE_MORE_ENTER_LINES;
  public static String CONSOLE_LISTENING_ON_PORT;
  public static String CONSOLE_PROMPT;
  public static String CONSOLE_HELP_CONTROLLING_FRAMEWORK_HEADER;
  public static String CONSOLE_HELP_LAUNCH_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_SHUTDOWN_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_CLOSE_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_EXIT_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_GC_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_INIT_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_KEYVALUE_ARGUMENT_DESCRIPTION;
  public static String CONSOLE_HELP_SETPROP_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_CONTROLLING_BUNDLES_HEADER;
  public static String CONSOLE_HELP_INSTALL_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_UNINSTALL_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_START_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_STOP_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_REFRESH_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_DISPLAYING_STATUS_HEADER;
  public static String CONSOLE_HELP_STATUS_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_STATE_ARGUMENT_DESCRIPTION;
  public static String CONSOLE_HELP_SS_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_FILTER_ARGUMENT_DESCRIPTION;
  public static String CONSOLE_HELP_SERVICES_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_PACKAGES_ARGUMENT_DESCRIPTION;
  public static String CONSOLE_HELP_PACKAGES_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_BUNDLES_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_IDLOCATION_ARGUMENT_DESCRIPTION;
  public static String CONSOLE_HELP_BUNDLE_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_HEADERS_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_EXTRAS_HEADER;
  public static String CONSOLE_HELP_COMMAND_ARGUMENT_DESCRIPTION;
  public static String CONSOLE_HELP_GETPROP_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_GETPROP_ARGUMENT_DESCRIPTION;
  public static String CONSOLE_HELP_EXEC_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_FORK_COMMAND_DESCRIPTION;
  public static String STARTLEVEL_HELP_HEADING;
  public static String CONSOLE_HELP_OPTIONAL_IDLOCATION_ARGUMENT_DESCRIPTION;
  public static String STARTLEVEL_HELP_SL;
  public static String STARTLEVEL_ARGUMENT_DESCRIPTION;
  public static String STARTLEVEL_HELP_SETFWSL;
  public static String STARTLEVEL_IDLOCATION_ARGUMENT_DESCRIPTION;
  public static String STARTLEVEL_HELP_SETBSL;
  public static String STARTLEVEL_HELP_SETIBSL;
  public static String CONSOLE_HELP_PROFILE_HEADING;
  public static String CONSOLE_HELP_PROFILELOG_DESCRIPTION;
  public static String CONSOLE_HELP_UPDATE_COMMAND_DESCRIPTION;
  public static String CONSOLE_HELP_HELP_COMMAND_DESCRIPTION;
  public static String CONSOLE_NO_BUNDLE_SPECIFIED_ERROR;
  public static String CONSOLE_NOTHING_TO_INSTALL_ERROR;
  public static String CONSOLE_BUNDLE_ID_MESSAGE;
  public static String CONSOLE_NO_INSTALLED_BUNDLES_ERROR;
  public static String CONSOLE_REGISTERED_SERVICES_MESSAGE;
  public static String CONSOLE_FRAMEWORK_IS_LAUNCHED_MESSAGE;
  public static String CONSOLE_FRAMEWORK_IS_SHUTDOWN_MESSAGE;
  public static String CONSOLE_ID;
  public static String CONSOLE_BUNDLE_LOCATION_MESSAGE;
  public static String CONSOLE_STATE_BUNDLE_FILE_NAME_HEADER;
  public static String CONSOLE_BUNDLES_USING_SERVICE_MESSAGE;
  public static String CONSOLE_NO_REGISTERED_SERVICES_MESSAGE;
  public static String CONSOLE_NO_BUNDLES_USING_SERVICE_MESSAGE;
  public static String CONSOLE_REGISTERED_BY_BUNDLE_MESSAGE;
  public static String CONSOLE_IMPORTS_MESSAGE;
  public static String CONSOLE_STALE_MESSAGE;
  public static String CONSOLE_NO_EXPORTED_PACKAGES_NO_PACKAGE_ADMIN_MESSAGE;
  public static String CONSOLE_NO_EXPORTED_PACKAGES_MESSAGE;
  public static String CONSOLE_REMOVAL_PENDING_MESSAGE;
  public static String CONSOLE_SERVICES_IN_USE_MESSAGE;
  public static String CONSOLE_NO_SERVICES_IN_USE_MESSAGE;
  public static String CONSOLE_ID_MESSAGE;
  public static String CONSOLE_STATUS_MESSAGE;
  public static String CONSOLE_DATA_ROOT_MESSAGE;
  public static String CONSOLE_IMPORTED_PACKAGES_MESSAGE;
  public static String CONSOLE_NO_IMPORTED_PACKAGES_MESSAGE;
  public static String CONSOLE_HOST_MESSAGE;
  public static String CONSOLE_EXPORTED_PACKAGES_MESSAGE;
  public static String CONSOLE_EXPORTED_REMOVAL_PENDING_MESSAGE;
  public static String CONSOLE_EXPORTED_MESSAGE;
  public static String CONSOLE_NO_HOST_MESSAGE;
  public static String CONSOLE_FRAGMENT_MESSAGE;
  public static String CONSOLE_NO_FRAGMENT_MESSAGE;
  public static String CONSOLE_NO_NAMED_CLASS_SPACES_MESSAGE;
  public static String CONSOLE_NAMED_CLASS_SPACE_MESSAGE;
  public static String CONSOLE_PROVIDED_MESSAGE;
  public static String CONSOLE_REQUIRED_BUNDLES_MESSAGE;
  public static String CONSOLE_NO_REQUIRED_BUNDLES_MESSAGE;
  public static String CONSOLE_TOTAL_MEMORY_MESSAGE;
  public static String CONSOLE_FREE_MEMORY_BEFORE_GARBAGE_COLLECTION_MESSAGE;
  public static String CONSOLE_FREE_MEMORY_AFTER_GARBAGE_COLLECTION_MESSAGE;
  public static String CONSOLE_MEMORY_GAINED_WITH_GARBAGE_COLLECTION_MESSAGE;
  public static String CONSOLE_FRAMEWORK_LAUNCHED_PLEASE_SHUTDOWN_MESSAGE;
  public static String CONSOLE_INVALID_BUNDLE_SPECIFICATION_ERROR;
  public static String CONSOLE_CAN_NOT_REFRESH_NO_PACKAGE_ADMIN_ERROR;
  public static String CONSOLE_NO_COMMAND_SPECIFIED_ERROR;
  public static String CONSOLE_STARTED_IN_MESSAGE;
  public static String CONSOLE_EXECUTED_RESULT_CODE_MESSAGE;
  public static String CONSOLE_BUNDLE_HEADERS_TITLE;
  public static String CONSOLE_SYSTEM_PROPERTIES_TITLE;
  public static String CONSOLE_NO_PARAMETERS_SPECIFIED_TITLE;
  public static String CONSOLE_SETTING_PROPERTIES_TITLE;
  public static String CONSOLE_STATE_BUNDLE_TITLE;
  public static String CONSOLE_THREADGROUP_TITLE;
  public static String CONSOLE_THREADTYPE_TITLE;
  public static String CONSOLE_REQUIRES_MESSAGE;
  public static String CONSOLE_CAN_NOT_USE_STARTLEVEL_NO_STARTLEVEL_SVC_ERROR;
  public static String CONSOLE_CANNOT_FIND_BUNDLE_ERROR;
  public static String CONSOLE_PROPS_COMMAND_DESCRIPTION;
  public static String CONSOLE_THREADS_COMMAND_DESCRIPTION;
  public static String STARTLEVEL_FRAMEWORK_ACTIVE_STARTLEVEL;
  public static String STARTLEVEL_BUNDLE_STARTLEVEL;
  public static String STARTLEVEL_NO_STARTLEVEL_GIVEN;
  public static String STARTLEVEL_NO_STARTLEVEL_OR_BUNDLE_GIVEN;
  public static String STARTLEVEL_INITIAL_BUNDLE_STARTLEVEL;
  public static String STARTLEVEL_POSITIVE_INTEGER;
  
  static
  {
    NLS.initializeMessages("org.eclipse.osgi.framework.internal.core.ConsoleMessages", ConsoleMsg.class);
  }
}

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

public class Constants
  implements org.osgi.framework.Constants
{
  public static final String OSGI_FRAMEWORK_VERSION = "1.3";
  public static final String OSGI_FRAMEWORK_VENDOR = "Eclipse";
  public static final String OSGI_BUNDLE_MANIFEST = "META-INF/MANIFEST.MF";
  public static final String OSGI_FRAMEWORK_PACKAGE = "org.osgi.framework";
  public static final String OSGI_RESOURCE_URL_PROTOCOL = "bundleresource";
  public static final String OSGI_ENTRY_URL_PROTOCOL = "bundleentry";
  public static final String OSGI_PROCESSOR_ALIASES = "processor.aliases";
  public static final String OSGI_OSNAME_ALIASES = "osname.aliases";
  public static final String OSGI_DEFAULT_DEFAULT_PERMISSIONS = "default.permissions";
  public static final String OSGI_BASE_IMPLIED_PERMISSIONS = "implied.permissions";
  public static final String OSGI_LOGSERVICE_NAME = "org.osgi.service.log.LogService";
  public static final String OSGI_PACKAGEADMIN_NAME = "org.osgi.service.packageadmin.PackageAdmin";
  public static final String OSGI_PERMISSIONADMIN_NAME = "org.osgi.service.permissionadmin.PermissionAdmin";
  public static final String OSGI_STARTLEVEL_NAME = "org.osgi.service.startlevel.StartLevel";
  public static final String JVM_VM_NAME = "java.vm.name";
  public static final String JVM_OS_ARCH = "os.arch";
  public static final String JVM_OS_NAME = "os.name";
  public static final String JVM_OS_VERSION = "os.version";
  public static final String JVM_USER_LANGUAGE = "user.language";
  public static final String JVM_USER_REGION = "user.region";
  public static final String J2ME_MICROEDITION_CONFIGURATION = "microedition.configuration";
  public static final String J2ME_MICROEDITION_PROFILES = "microedition.profiles";
  public static final int BUNDLE_STARTED = 1;
  public static final int BUNDLE_LAZY_START = 2;
  public static final int BUNDLE_ACTIVATION_POLICY = 4;
  public static final String OSGI_PROPERTIES = "osgi.framework.properties";
  public static final String DEFAULT_OSGI_PROPERTIES = "osgi.properties";
  private static String INTERNAL_SYSTEM_BUNDLE = "org.eclipse.osgi";
  public static final String OSGI_IMPL_VERSION_KEY = "osgi.framework.version";
  public static final String OSGI_JAVA_PROFILE = "osgi.java.profile";
  public static final String OSGI_JAVA_PROFILE_NAME = "osgi.java.profile.name";
  public static final String OSGI_JAVA_PROFILE_BOOTDELEGATION = "osgi.java.profile.bootdelegation";
  public static final String OSGI_BOOTDELEGATION_IGNORE = "ignore";
  public static final String OSGI_BOOTDELEGATION_OVERRIDE = "override";
  public static final String OSGI_BOOTDELEGATION_NONE = "none";
  public static final String OSGI_RESOLVER_MODE = "osgi.resolverMode";
  public static final String STRICT_MODE = "strict";
  public static final String DEVELOPMENT_MODE = "development";
  public static final String STATE_SYSTEM_BUNDLE = "osgi.system.bundle";
  public static final String PROP_OSGI_RELAUNCH = "osgi.framework.relaunch";
  
  public static String getInternalSymbolicName()
  {
    return INTERNAL_SYSTEM_BUNDLE;
  }
  
  static void setInternalSymbolicName(String name)
  {
    INTERNAL_SYSTEM_BUNDLE = name;
  }
  
  public static String OSGI_COMPATIBILITY_BOOTDELEGATION = "osgi.compatibility.bootdelegation";
  public static final String ECLIPSE_SYSTEMBUNDLE = "Eclipse-SystemBundle";
  public static final String ECLIPSE_PLATFORMFILTER = "Eclipse-PlatformFilter";
  public static final String Eclipse_JREBUNDLE = "Eclipse-JREBundle";
  public static final String INTERNAL_DIRECTIVE = "x-internal";
  public static final String FRIENDS_DIRECTIVE = "x-friends";
  /**
   * @deprecated
   */
  public static final String PROVIDE_PACKAGE = "Provide-Package";
  /**
   * @deprecated
   */
  public static final String REPROVIDE_ATTRIBUTE = "reprovide";
  /**
   * @deprecated
   */
  public static final String OPTIONAL_ATTRIBUTE = "optional";
  public static final String BUDDY_LOADER = "Eclipse-BuddyPolicy";
  public static final String REGISTERED_POLICY = "Eclipse-RegisterBuddy";
  public static final String INTERNAL_HANDLER_PKGS = "equinox.interal.handler.pkgs";
  public static final String PLUGIN_CLASS = "Plugin-Class";
  public static final String ECLIPSE_LAZYSTART = "Eclipse-LazyStart";
  public static final String ECLIPSE_LAZYSTART_EXCEPTIONS = "exceptions";
  /**
   * @deprecated
   */
  public static final String ECLIPSE_AUTOSTART = "Eclipse-AutoStart";
  /**
   * @deprecated
   */
  public static final String ECLIPSE_AUTOSTART_EXCEPTIONS = "exceptions";
  public static final String REFRESH_DUPLICATE_BSN = "equinox.refresh.duplicate.bsn";
}

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

import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import org.eclipse.osgi.framework.debug.Debug;
import org.eclipse.osgi.internal.serviceregistry.ServiceReferenceImpl;
import org.eclipse.osgi.internal.serviceregistry.ShrinkableCollection;
import org.osgi.framework.hooks.resolver.ResolverHook;
import org.osgi.framework.wiring.BundleCapability;
import org.osgi.framework.wiring.BundleRequirement;
import org.osgi.framework.wiring.BundleRevision;

class CoreResolverHookFactory$CoreResolverHook
  implements ResolverHook
{
  private final List<CoreResolverHookFactory.HookReference> hooks;
  final CoreResolverHookFactory this$0;
  
  CoreResolverHookFactory$CoreResolverHook(List<CoreResolverHookFactory.HookReference> arg1)
  {
    this.hooks = hooks;
  }
  
  public void filterResolvable(Collection<BundleRevision> candidates)
  {
    if (Debug.DEBUG_HOOKS) {
      Debug.println("ResolverHook.filterResolvable(" + candidates + ")");
    }
    if (hooks.isEmpty()) {
      return;
    }
    candidates = new ShrinkableCollection(candidates);
    for (Iterator<CoreResolverHookFactory.HookReference> iHooks = hooks.iterator(); iHooks.hasNext();)
    {
      CoreResolverHookFactory.HookReference hookRef = (CoreResolverHookFactory.HookReference)iHooks.next();
      if (reference.getBundle() == null) {
        this$0.handleHookException(null, hook, "filterResolvable");
      } else {
        try
        {
          hook.filterResolvable(candidates);
        }
        catch (Throwable t)
        {
          this$0.handleHookException(t, hook, "filterResolvable");
        }
      }
    }
  }
  
  public void filterSingletonCollisions(BundleCapability singleton, Collection<BundleCapability> collisionCandidates)
  {
    if (Debug.DEBUG_HOOKS) {
      Debug.println("ResolverHook.filterSingletonCollisions(" + singleton + ", " + collisionCandidates + ")");
    }
    if (hooks.isEmpty()) {
      return;
    }
    collisionCandidates = new ShrinkableCollection(collisionCandidates);
    for (Iterator<CoreResolverHookFactory.HookReference> iHooks = hooks.iterator(); iHooks.hasNext();)
    {
      CoreResolverHookFactory.HookReference hookRef = (CoreResolverHookFactory.HookReference)iHooks.next();
      if (reference.getBundle() == null) {
        this$0.handleHookException(null, hook, "filterSingletonCollisions");
      } else {
        try
        {
          hook.filterSingletonCollisions(singleton, collisionCandidates);
        }
        catch (Throwable t)
        {
          this$0.handleHookException(t, hook, "filterSingletonCollisions");
        }
      }
    }
  }
  
  public void filterMatches(BundleRequirement requirement, Collection<BundleCapability> candidates)
  {
    if (Debug.DEBUG_HOOKS) {
      Debug.println("ResolverHook.filterMatches(" + requirement + ", " + candidates + ")");
    }
    if (hooks.isEmpty()) {
      return;
    }
    candidates = new ShrinkableCollection(candidates);
    for (Iterator<CoreResolverHookFactory.HookReference> iHooks = hooks.iterator(); iHooks.hasNext();)
    {
      CoreResolverHookFactory.HookReference hookRef = (CoreResolverHookFactory.HookReference)iHooks.next();
      if (reference.getBundle() == null) {
        this$0.handleHookException(null, hook, "filterMatches");
      } else {
        try
        {
          hook.filterMatches(requirement, candidates);
        }
        catch (Throwable t)
        {
          this$0.handleHookException(t, hook, "filterMatches");
        }
      }
    }
  }
  
  /* Error */
  public void end()
  {
    // Byte code:
    //   0: getstatic 131	org/eclipse/osgi/framework/debug/Debug:DEBUG_HOOKS	Z
    //   3: ifeq +8 -> 11
    //   6: ldc 3
    //   8: invokestatic 141	org/eclipse/osgi/framework/debug/Debug:println	(Ljava/lang/String;)V
    //   11: aload_0
    //   12: getfield 132	org/eclipse/osgi/framework/internal/core/CoreResolverHookFactory$CoreResolverHook:hooks	Ljava/util/List;
    //   15: invokeinterface 148 1 0
    //   20: ifeq +4 -> 24
    //   23: return
    //   24: aconst_null
    //   25: astore_1
    //   26: aconst_null
    //   27: astore_2
    //   28: aconst_null
    //   29: astore_3
    //   30: aload_0
    //   31: getfield 132	org/eclipse/osgi/framework/internal/core/CoreResolverHookFactory$CoreResolverHook:hooks	Ljava/util/List;
    //   34: invokeinterface 149 1 0
    //   39: astore 4
    //   41: goto +61 -> 102
    //   44: aload 4
    //   46: invokeinterface 147 1 0
    //   51: checkcast 72	org/eclipse/osgi/framework/internal/core/CoreResolverHookFactory$HookReference
    //   54: astore 5
    //   56: aload 5
    //   58: getfield 134	org/eclipse/osgi/framework/internal/core/CoreResolverHookFactory$HookReference:reference	Lorg/eclipse/osgi/internal/serviceregistry/ServiceReferenceImpl;
    //   61: invokevirtual 144	org/eclipse/osgi/internal/serviceregistry/ServiceReferenceImpl:getBundle	()Lorg/osgi/framework/Bundle;
    //   64: ifnonnull +13 -> 77
    //   67: aload_1
    //   68: ifnonnull +34 -> 102
    //   71: aload 5
    //   73: astore_1
    //   74: goto +28 -> 102
    //   77: aload 5
    //   79: getfield 135	org/eclipse/osgi/framework/internal/core/CoreResolverHookFactory$HookReference:hook	Lorg/osgi/framework/hooks/resolver/ResolverHook;
    //   82: invokeinterface 150 1 0
    //   87: goto +15 -> 102
    //   90: astore 6
    //   92: aload_2
    //   93: ifnonnull +9 -> 102
    //   96: aload 6
    //   98: astore_2
    //   99: aload 5
    //   101: astore_3
    //   102: aload 4
    //   104: invokeinterface 146 1 0
    //   109: ifne -65 -> 44
    //   112: aload_1
    //   113: ifnull +17 -> 130
    //   116: aload_0
    //   117: getfield 133	org/eclipse/osgi/framework/internal/core/CoreResolverHookFactory$CoreResolverHook:this$0	Lorg/eclipse/osgi/framework/internal/core/CoreResolverHookFactory;
    //   120: aconst_null
    //   121: aload_1
    //   122: getfield 135	org/eclipse/osgi/framework/internal/core/CoreResolverHookFactory$HookReference:hook	Lorg/osgi/framework/hooks/resolver/ResolverHook;
    //   125: ldc 7
    //   127: invokevirtual 143	org/eclipse/osgi/framework/internal/core/CoreResolverHookFactory:handleHookException	(Ljava/lang/Throwable;Ljava/lang/Object;Ljava/lang/String;)V
    //   130: aload_2
    //   131: ifnull +36 -> 167
    //   134: aload_0
    //   135: getfield 133	org/eclipse/osgi/framework/internal/core/CoreResolverHookFactory$CoreResolverHook:this$0	Lorg/eclipse/osgi/framework/internal/core/CoreResolverHookFactory;
    //   138: aload_2
    //   139: aload_3
    //   140: getfield 135	org/eclipse/osgi/framework/internal/core/CoreResolverHookFactory$HookReference:hook	Lorg/osgi/framework/hooks/resolver/ResolverHook;
    //   143: ldc 7
    //   145: invokevirtual 143	org/eclipse/osgi/framework/internal/core/CoreResolverHookFactory:handleHookException	(Ljava/lang/Throwable;Ljava/lang/Object;Ljava/lang/String;)V
    //   148: goto +19 -> 167
    //   151: astore 7
    //   153: aload_0
    //   154: getfield 133	org/eclipse/osgi/framework/internal/core/CoreResolverHookFactory$CoreResolverHook:this$0	Lorg/eclipse/osgi/framework/internal/core/CoreResolverHookFactory;
    //   157: aload_0
    //   158: getfield 132	org/eclipse/osgi/framework/internal/core/CoreResolverHookFactory$CoreResolverHook:hooks	Ljava/util/List;
    //   161: invokevirtual 142	org/eclipse/osgi/framework/internal/core/CoreResolverHookFactory:releaseHooks	(Ljava/util/List;)V
    //   164: aload 7
    //   166: athrow
    //   167: aload_0
    //   168: getfield 133	org/eclipse/osgi/framework/internal/core/CoreResolverHookFactory$CoreResolverHook:this$0	Lorg/eclipse/osgi/framework/internal/core/CoreResolverHookFactory;
    //   171: aload_0
    //   172: getfield 132	org/eclipse/osgi/framework/internal/core/CoreResolverHookFactory$CoreResolverHook:hooks	Ljava/util/List;
    //   175: invokevirtual 142	org/eclipse/osgi/framework/internal/core/CoreResolverHookFactory:releaseHooks	(Ljava/util/List;)V
    //   178: return
    // Line number table:
    //   Java source line #179	-> byte code offset #0
    //   Java source line #180	-> byte code offset #6
    //   Java source line #182	-> byte code offset #11
    //   Java source line #183	-> byte code offset #23
    //   Java source line #185	-> byte code offset #24
    //   Java source line #186	-> byte code offset #26
    //   Java source line #187	-> byte code offset #28
    //   Java source line #188	-> byte code offset #30
    //   Java source line #189	-> byte code offset #44
    //   Java source line #191	-> byte code offset #56
    //   Java source line #192	-> byte code offset #67
    //   Java source line #193	-> byte code offset #71
    //   Java source line #194	-> byte code offset #74
    //   Java source line #196	-> byte code offset #77
    //   Java source line #197	-> byte code offset #87
    //   Java source line #200	-> byte code offset #92
    //   Java source line #201	-> byte code offset #96
    //   Java source line #202	-> byte code offset #99
    //   Java source line #188	-> byte code offset #102
    //   Java source line #207	-> byte code offset #112
    //   Java source line #208	-> byte code offset #116
    //   Java source line #209	-> byte code offset #130
    //   Java source line #210	-> byte code offset #134
    //   Java source line #211	-> byte code offset #148
    //   Java source line #212	-> byte code offset #153
    //   Java source line #213	-> byte code offset #164
    //   Java source line #212	-> byte code offset #167
    //   Java source line #214	-> byte code offset #178
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	179	0	this	CoreResolverHook
    //   25	97	1	missingHook	CoreResolverHookFactory.HookReference
    //   27	112	2	endError	Throwable
    //   29	111	3	endBadHook	CoreResolverHookFactory.HookReference
    //   39	64	4	iHooks	Iterator<CoreResolverHookFactory.HookReference>
    //   54	46	5	hookRef	CoreResolverHookFactory.HookReference
    //   90	7	6	t	Throwable
    //   151	14	7	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   77	87	90	java/lang/Throwable
    //   24	151	151	finally
  }
}

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

import org.eclipse.osgi.internal.serviceregistry.ServiceReferenceImpl;
import org.osgi.framework.hooks.resolver.ResolverHook;
import org.osgi.framework.hooks.resolver.ResolverHookFactory;

class CoreResolverHookFactory$HookReference
{
  final ServiceReferenceImpl<ResolverHookFactory> reference;
  final ResolverHook hook;
  
  public CoreResolverHookFactory$HookReference(ServiceReferenceImpl<ResolverHookFactory> reference, ResolverHook hook)
  {
    this.reference = reference;
    this.hook = hook;
  }
}

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

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import org.eclipse.osgi.framework.debug.Debug;
import org.eclipse.osgi.internal.serviceregistry.ServiceReferenceImpl;
import org.eclipse.osgi.internal.serviceregistry.ServiceRegistry;
import org.eclipse.osgi.internal.serviceregistry.ShrinkableCollection;
import org.eclipse.osgi.service.resolver.ResolverHookException;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.hooks.resolver.ResolverHook;
import org.osgi.framework.hooks.resolver.ResolverHookFactory;
import org.osgi.framework.wiring.BundleCapability;
import org.osgi.framework.wiring.BundleRequirement;
import org.osgi.framework.wiring.BundleRevision;

public class CoreResolverHookFactory
  implements ResolverHookFactory
{
  private final BundleContextImpl context;
  private final ServiceRegistry registry;
  
  static class HookReference
  {
    final ServiceReferenceImpl<ResolverHookFactory> reference;
    final ResolverHook hook;
    
    public HookReference(ServiceReferenceImpl<ResolverHookFactory> reference, ResolverHook hook)
    {
      this.reference = reference;
      this.hook = hook;
    }
  }
  
  public CoreResolverHookFactory(BundleContextImpl context, ServiceRegistry registry)
  {
    this.context = context;
    this.registry = registry;
  }
  
  void handleHookException(Throwable t, Object hook, String method)
  {
    if (Debug.DEBUG_HOOKS)
    {
      Debug.println(hook.getClass().getName() + "." + method + "() exception:");
      if (t != null) {
        Debug.printStackTrace(t);
      }
    }
    String message = NLS.bind(Msg.SERVICE_FACTORY_EXCEPTION, hook.getClass().getName(), method);
    throw new ResolverHookException(message, t);
  }
  
  private ServiceReferenceImpl<ResolverHookFactory>[] getHookReferences()
  {
    try
    {
      return registry.getServiceReferences(context, ResolverHookFactory.class.getName(), null, false, false);
    }
    catch (InvalidSyntaxException localInvalidSyntaxException) {}
    return null;
  }
  
  public ResolverHook begin(Collection<BundleRevision> triggers)
  {
    if (Debug.DEBUG_HOOKS) {
      Debug.println("ResolverHook.begin");
    }
    ServiceReferenceImpl[] refs = getHookReferences();
    
    List<HookReference> hookRefs = refs == null ? Collections.EMPTY_LIST : new ArrayList(refs.length);
    if (refs != null)
    {
      ServiceReferenceImpl[] arrayOfServiceReferenceImpl1;
      int j = (arrayOfServiceReferenceImpl1 = refs).length;
      for (int i = 0; i < j; i++)
      {
        ServiceReferenceImpl<ResolverHookFactory> hookRef = arrayOfServiceReferenceImpl1[i];
        ResolverHookFactory factory = (ResolverHookFactory)context.getService(hookRef);
        if (factory != null) {
          try
          {
            ResolverHook hook = factory.begin(triggers);
            if (hook != null) {
              hookRefs.add(new HookReference(hookRef, hook));
            }
          }
          catch (Throwable t)
          {
            try
            {
              new CoreResolverHook(hookRefs).end();
            }
            catch (Throwable localThrowable1) {}
            handleHookException(t, factory, "begin");
          }
        }
      }
    }
    return new CoreResolverHook(hookRefs);
  }
  
  void releaseHooks(List<HookReference> hookRefs)
  {
    for (Iterator localIterator = hookRefs.iterator(); localIterator.hasNext();)
    {
      HookReference hookRef = (HookReference)localIterator.next();
      context.ungetService(reference);
    }
    hookRefs.clear();
  }
  
  class CoreResolverHook
    implements ResolverHook
  {
    private final List<CoreResolverHookFactory.HookReference> hooks;
    
    CoreResolverHook()
    {
      this.hooks = hooks;
    }
    
    public void filterResolvable(Collection<BundleRevision> candidates)
    {
      if (Debug.DEBUG_HOOKS) {
        Debug.println("ResolverHook.filterResolvable(" + candidates + ")");
      }
      if (hooks.isEmpty()) {
        return;
      }
      candidates = new ShrinkableCollection(candidates);
      for (Iterator<CoreResolverHookFactory.HookReference> iHooks = hooks.iterator(); iHooks.hasNext();)
      {
        CoreResolverHookFactory.HookReference hookRef = (CoreResolverHookFactory.HookReference)iHooks.next();
        if (reference.getBundle() == null) {
          handleHookException(null, hook, "filterResolvable");
        } else {
          try
          {
            hook.filterResolvable(candidates);
          }
          catch (Throwable t)
          {
            handleHookException(t, hook, "filterResolvable");
          }
        }
      }
    }
    
    public void filterSingletonCollisions(BundleCapability singleton, Collection<BundleCapability> collisionCandidates)
    {
      if (Debug.DEBUG_HOOKS) {
        Debug.println("ResolverHook.filterSingletonCollisions(" + singleton + ", " + collisionCandidates + ")");
      }
      if (hooks.isEmpty()) {
        return;
      }
      collisionCandidates = new ShrinkableCollection(collisionCandidates);
      for (Iterator<CoreResolverHookFactory.HookReference> iHooks = hooks.iterator(); iHooks.hasNext();)
      {
        CoreResolverHookFactory.HookReference hookRef = (CoreResolverHookFactory.HookReference)iHooks.next();
        if (reference.getBundle() == null) {
          handleHookException(null, hook, "filterSingletonCollisions");
        } else {
          try
          {
            hook.filterSingletonCollisions(singleton, collisionCandidates);
          }
          catch (Throwable t)
          {
            handleHookException(t, hook, "filterSingletonCollisions");
          }
        }
      }
    }
    
    public void filterMatches(BundleRequirement requirement, Collection<BundleCapability> candidates)
    {
      if (Debug.DEBUG_HOOKS) {
        Debug.println("ResolverHook.filterMatches(" + requirement + ", " + candidates + ")");
      }
      if (hooks.isEmpty()) {
        return;
      }
      candidates = new ShrinkableCollection(candidates);
      for (Iterator<CoreResolverHookFactory.HookReference> iHooks = hooks.iterator(); iHooks.hasNext();)
      {
        CoreResolverHookFactory.HookReference hookRef = (CoreResolverHookFactory.HookReference)iHooks.next();
        if (reference.getBundle() == null) {
          handleHookException(null, hook, "filterMatches");
        } else {
          try
          {
            hook.filterMatches(requirement, candidates);
          }
          catch (Throwable t)
          {
            handleHookException(t, hook, "filterMatches");
          }
        }
      }
    }
    
    /* Error */
    public void end()
    {
      // Byte code:
      //   0: getstatic 131	org/eclipse/osgi/framework/debug/Debug:DEBUG_HOOKS	Z
      //   3: ifeq +8 -> 11
      //   6: ldc 3
      //   8: invokestatic 141	org/eclipse/osgi/framework/debug/Debug:println	(Ljava/lang/String;)V
      //   11: aload_0
      //   12: getfield 132	org/eclipse/osgi/framework/internal/core/CoreResolverHookFactory$CoreResolverHook:hooks	Ljava/util/List;
      //   15: invokeinterface 148 1 0
      //   20: ifeq +4 -> 24
      //   23: return
      //   24: aconst_null
      //   25: astore_1
      //   26: aconst_null
      //   27: astore_2
      //   28: aconst_null
      //   29: astore_3
      //   30: aload_0
      //   31: getfield 132	org/eclipse/osgi/framework/internal/core/CoreResolverHookFactory$CoreResolverHook:hooks	Ljava/util/List;
      //   34: invokeinterface 149 1 0
      //   39: astore 4
      //   41: goto +61 -> 102
      //   44: aload 4
      //   46: invokeinterface 147 1 0
      //   51: checkcast 72	org/eclipse/osgi/framework/internal/core/CoreResolverHookFactory$HookReference
      //   54: astore 5
      //   56: aload 5
      //   58: getfield 134	org/eclipse/osgi/framework/internal/core/CoreResolverHookFactory$HookReference:reference	Lorg/eclipse/osgi/internal/serviceregistry/ServiceReferenceImpl;
      //   61: invokevirtual 144	org/eclipse/osgi/internal/serviceregistry/ServiceReferenceImpl:getBundle	()Lorg/osgi/framework/Bundle;
      //   64: ifnonnull +13 -> 77
      //   67: aload_1
      //   68: ifnonnull +34 -> 102
      //   71: aloa
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-2019. Infinite Loop Ltd