/**
   * Returns the ServiceReference for the protocol provider corresponding to the specified accountID
   * or null if the accountID is unknown.
   *
   * @param accountID the accountID of the protocol provider we'd like to get
   * @return a ServiceReference object to the protocol provider with the specified account id and
   *     null if the account id is unknown to the provider factory.
   */
  public ServiceReference getProviderForAccount(AccountID accountID) {
    ServiceRegistration registration;

    synchronized (registeredAccounts) {
      registration = registeredAccounts.get(accountID);
    }
    return (registration == null) ? null : registration.getReference();
  }
  /** Prepares the factory for bundle shutdown. */
  public void stop() {
    logger.trace("Preparing to stop all SIP protocol providers.");
    Enumeration registrations = this.registeredAccounts.elements();

    while (registrations.hasMoreElements()) {
      ServiceRegistration reg = ((ServiceRegistration) registrations.nextElement());

      ProtocolProviderServiceSipImpl provider =
          (ProtocolProviderServiceSipImpl)
              SipActivator.getBundleContext().getService(reg.getReference());

      // do an attempt to kill the provider
      provider.shutdown();

      reg.unregister();
    }

    registeredAccounts.clear();
  }
  /**
   * Shuts down the <code>ProtocolProviderService</code> representing an account registered with
   * this factory.
   *
   * @param registeredAccount the <code>ServiceRegistration</code> of the <code>
   *     ProtocolProviderService</code> representing an account registered with this factory
   */
  protected void stop(ServiceRegistration registeredAccount) {
    ProtocolProviderService protocolProviderService =
        (ProtocolProviderService) getBundleContext().getService(registeredAccount.getReference());

    protocolProviderService.shutdown();
  }
  /**
   * Returns the ServiceReference for the protocol provider corresponding to the specified accountID
   * or null if the accountID is unknown.
   *
   * @param accountID the accountID of the protocol provider we'd like to get
   * @return a ServiceReference object to the protocol provider with the specified account id and
   *     null if the account id is unknwon to the provider factory.
   */
  public ServiceReference getProviderForAccount(AccountID accountID) {
    ServiceRegistration registration = (ServiceRegistration) registeredAccounts.get(accountID);

    return (registration == null) ? null : registration.getReference();
  }