/** Unregister and shutdown all services registered with smart spaces. */
  private void unregisterSmartSpacesServices() {
    ServiceRegistry serviceRegistry =
        smartspacesEnvironmentTracker.getMyService().getServiceRegistry();
    for (Service service : registeredServices) {
      serviceRegistry.unregisterService(service);

      if (SupportedService.class.isAssignableFrom(service.getClass())) {
        ((SupportedService) service).shutdown();
      }
    }
    registeredServices.clear();
  }
  /**
   * Register a new service with IS.
   *
   * @param service the service to be registered
   */
  public void registerNewSmartSpacesService(Service service) {
    try {
      smartspacesEnvironmentTracker.getMyService().getServiceRegistry().registerService(service);

      if (SupportedService.class.isAssignableFrom(service.getClass())) {
        ((SupportedService) service).startup();
      }

      registeredServices.add(service);
    } catch (Exception e) {
      smartspacesEnvironmentTracker
          .getMyService()
          .getLog()
          .error(String.format("Error while starting up service %s", service.getName()), e);
    }
  }