code: public static synchronized ChatManager getInstanceFor(XMPPConnection connection) {
          ChatManager manager = INSTANCES.get(connection);
          if (manager == null)
              manager = new ChatManager(connection);
          return manager;
      }
docs: Returns the ChatManager instance associated with a given XMPPConnection.
  
  @param connection the connection used to look for the proper ServiceDiscoveryManager.
  @return the ChatManager associated with a given XMPPConnection.