Class JmDNSImpl.ServiceCollector

  • All Implemented Interfaces:
    java.util.EventListener, ServiceListener
    Enclosing class:
    JmDNSImpl

    private static class JmDNSImpl.ServiceCollector
    extends java.lang.Object
    implements ServiceListener
    Instances of ServiceCollector are used internally to speed up the performance of method list(type).
    See Also:
    list(long)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.concurrent.ConcurrentMap<java.lang.String,​ServiceEvent> _events
      A set of collected service event waiting to be resolved.
      private java.util.concurrent.ConcurrentMap<java.lang.String,​ServiceInfo> _infos
      A set of collected service instance names.
      private boolean _needToWaitForInfos
      This is used to force a wait on the first invocation of list.
      private java.lang.String _type
      This is the type we are listening for (only used for debugging).
    • Constructor Summary

      Constructors 
      Constructor Description
      ServiceCollector​(java.lang.String type)  
    • Field Detail

      • _infos

        private final java.util.concurrent.ConcurrentMap<java.lang.String,​ServiceInfo> _infos
        A set of collected service instance names.
      • _events

        private final java.util.concurrent.ConcurrentMap<java.lang.String,​ServiceEvent> _events
        A set of collected service event waiting to be resolved.
      • _type

        private final java.lang.String _type
        This is the type we are listening for (only used for debugging).
      • _needToWaitForInfos

        private volatile boolean _needToWaitForInfos
        This is used to force a wait on the first invocation of list.
    • Constructor Detail

      • ServiceCollector

        public ServiceCollector​(java.lang.String type)
    • Method Detail

      • serviceResolved

        public void serviceResolved​(ServiceEvent event)
        A service has been resolved. Its details are now available in the ServiceInfo record.
        Specified by:
        serviceResolved in interface ServiceListener
        Parameters:
        event - service event
      • list

        public ServiceInfo[] list​(long timeout)
        Returns an array of all service infos which have been collected by this ServiceCollector.
        Parameters:
        timeout - timeout if the info list is empty.
        Returns:
        Service Info array
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object