code: public static synchronized ServiceDiscoveryManager getInstanceFor(XMPPConnection connection) {
          ServiceDiscoveryManager sdm = instances.get(connection);
          if (sdm == null) {
              sdm = new ServiceDiscoveryManager(connection);
              // Register the new instance and associate it with the connection
              instances.put(connection, sdm);
          }
          return sdm;
      }
docs: Returns the ServiceDiscoveryManager instance associated with a given XMPPConnection.
  
  @param connection the connection used to look for the proper ServiceDiscoveryManager.
  @return the ServiceDiscoveryManager associated with a given XMPPConnection.