创建并初始化监听，监听所有事件
@param url URL
@param watcher {@link Watcher}
@return {@link WatchMonitor}
485131
public static WatchMonitor createAll(URL url, Watcher watcher){
		try {
			return createAll(Paths.get(url.toURI()), watcher);
		} catch (URISyntaxException e) {
			throw new WatchException(e);
		}
	}
28511
@SuppressWarnings("unchecked")
    static <T extends JUnitWatcher> Optional<T> getAttachedWatcher(Class<T> watcherType) {
        if (MethodWatcher.class.isAssignableFrom(watcherType)) {
            synchronized(methodWatcherLoader) {
                for (MethodWatcher watcher : methodWatcherLoader) {
                    if (watcher.getClass() == watcherType) {
                        return Optional.of((T) watcher);
                    }
                }
            }
        }
        return Optional.absent();
    }
248610
public CuratorFramework mkClient(Map conf, List<String> servers, Object port,
                                     String root, final WatcherCallBack watcher) {

        CuratorFramework fk = Utils.newCurator(conf, servers, port, root);

        fk.getCuratorListenable().addListener(new CuratorListener() {
            @Override
            public void eventReceived(CuratorFramework _fk, CuratorEvent e) throws Exception {
                if (e.getType().equals(CuratorEventType.WATCHED)) {
                    WatchedEvent event = e.getWatchedEvent();

                    watcher.execute(event.getState(), event.getType(), event.getPath());
                }

            }
        });

        fk.getUnhandledErrorListenable().addListener(new UnhandledErrorListener() {
            @Override
            public void unhandledError(String msg, Throwable error) {
                String errmsg = "Unrecoverable zookeeper error, halting process: " + msg;
                LOG.error(errmsg, error);
                JStormUtils.halt_process(1, "Unrecoverable zookeeper error");

            }
        });
        fk.start();
        return fk;
    }
1183906
function onEvent (watcher) {
    // Wait for write stream to end if write has been delayed.
    if (writeDelayed) { return undefined; }

    // If any watch events occur while writing to dest then restart
    // write stream with new changes.
    if (stream.isWriting()) {
        writeDelayed = true;

        stream.endWriteStream();
    // Initial write of files to dest.
    } else {
        writeStartTime = Date.now();

        writeFiles();
    }
}
516122
public static WatchMonitor create(File file, WatchEvent.Kind<?>... events){
		return create(file, 0, events);
	}
1276138
private void createMonitor(LinkListener l) throws KNXException
	{
		final KNXMediumSettings medium = (KNXMediumSettings) options.get("medium");
		if (options.containsKey("serial")) {
			final String p = (String) options.get("serial");
			try {
				m = new KNXNetworkMonitorFT12(Integer.parseInt(p), medium);
			}
			catch (final NumberFormatException e) {
				m = new KNXNetworkMonitorFT12(p, medium);
			}
		}
		else {
			// create local and remote socket address for monitor link
			final InetSocketAddress local = createLocalSocket((InetAddress) options
				.get("localhost"), (Integer) options.get("localport"));
			final InetSocketAddress host = new InetSocketAddress((InetAddress) options
				.get("host"), ((Integer) options.get("port")).intValue());
			// create the monitor link, based on the KNXnet/IP protocol
			// specify whether network address translation shall be used,
			// and tell the physical medium of the KNX network
			m = new KNXNetworkMonitorIP(local, host, options.containsKey("nat"), medium);
		}
		// add the log writer for monitor log events
		LogManager.getManager().addWriter(m.getName(), w);
		// on console we want to have all possible information, so enable
		// decoding of a received raw frame by the monitor link
		m.setDecodeRawFrames(true);
		// listen to monitor link events
		m.addMonitorListener(l);
		// we always need a link closed notification (even with user supplied listener)
		m.addMonitorListener(new LinkListener() {
			public void indication(FrameEvent e)
			{}

			public void linkClosed(CloseEvent e)
			{
				System.out.println("network monitor exit, " + e.getReason());
				synchronized (NetworkMonitor.this) {
					NetworkMonitor.this.notify();
				}
			}
		});
	}
41701
def addMonitor(self, monitorFriendlyName, monitorURL):
        
        url = self.baseUrl
        url += "newMonitor?apiKey=%s" % self.apiKey
        url += "&monitorFriendlyName=%s" % monitorFriendlyName
        url += "&monitorURL=%s&monitorType=1" % monitorURL
        url += "&monitorAlertContacts=%s" % monitorAlertContacts
        url += "&noJsonCallback=1&format=json"
        success, response = self.requestApi(url)
        if success:
            return True
        else:
            return False
290796
function setCallbackAsWatcherOf(callback, watchersSet) {
    if (!callback[WATCHER_IDENTIFIER]) {
        defineProperty(callback, WATCHER_IDENTIFIER, { watching: new Set() });

        defineProperty(callback, "stopWatchingAll", function(){
            callback[WATCHER_IDENTIFIER].watching.forEach(watcherList =>
                watcherList.delete(callback)
            );
            callback[WATCHER_IDENTIFIER].watching.clear();
        });
    }

    callback[WATCHER_IDENTIFIER].watching.add(watchersSet);
}
460845
public void weakAddWatcher(Path file, Listener watcher) {
        synchronized (mutex) {
            startWatchingInternal(file).add(new WeakReference<>(watcher)::get);
        }
    }
528759
public static WatchMonitor create(String path, WatchEvent.Kind<?>... events){
		return create(path, 0, events);
	}
259784
def monitor(args, watch):
    
    watch = watch if isinstance(watch, (list, tuple)) else [watch]
    watch = [Path(entry).expand().abspath() for entry in watch]
    event_handler = RunScriptChangeHandler(args)
    observer = Observer()
    for entry in watch:
        if entry.isfile():
            entry = entry.parent
        click.secho('watch recursive: {0}'.format(entry), fg='blue')
        observer.schedule(event_handler, entry, recursive=True)
    event_handler.run()  # run always once
    observer.start()

    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        observer.stop()
    observer.join()
897232
static public String createMonitor(XPathContext context, String url,
            String localName, String namespaceURI, NodeInfo params,
            String callId, TECore core) throws Exception {
        return createMonitor(context, url, localName, namespaceURI, params,
                null, "", callId, core);
    }
1003139
@Deprecated
    public void weakAddWatcher(Listener watcher) {
        if (watcher == null) {
            throw new IllegalArgumentException("Null watcher added");
        }

        synchronized (mutex) {
            if (watcherExecutor.isShutdown()) {
                throw new IllegalStateException("Adding watcher on closed FileWatcher");
            }
            watchers.add(new WeakReference<>(watcher)::get);
        }
    }
547038
private void startWatcher() {

        if (m_watcher == null) {
            try {
                m_watcher = new CmsUploadTimeoutWatcher(this);
                m_watcher.start();
            } catch (Exception e) {
                LOG.info(
                    Messages.get().getBundle().key(Messages.LOG_UPLOAD_CREATE_WATCH_DOG_2, getId(), e.getMessage()));
            }
        }
    }
256464
function(watcher){
    var dirty = false;
    if(!watcher) return;

    var now, last, tlast, tnow,  
      eq, diff, keyOf, trackDiff
     

    if(!watcher.test){

      now = watcher.get(this);
      last = watcher.last;
      keyOf = watcher.keyOf

      if(now !== last || watcher.force){
        tlast = _.typeOf(last);
        tnow = _.typeOf(now);
        eq = true; 

        // !Object
        if( !(tnow === 'object' && tlast==='object' && watcher.deep) ){
          // Array
          if( tnow === 'array' && ( tlast=='undefined' || tlast === 'array') ){
            if(typeof keyOf === 'function'){
              trackDiff = diffTrack(now, watcher.last || [], keyOf )
              diff = trackDiff.steps;
              if(trackDiff.dirty) dirty = true;
            }else{
              diff = diffArray(now, watcher.last || [], watcher.diff)
            }
            
            if(!dirty && (tlast !== 'array' || diff === true || diff.length) ) dirty = true;
          }else{
            eq = _.equals( now, last );
            if( !eq || watcher.force ){
              watcher.force = null;
              dirty = true; 
            }
          }
        }else{
          diff =  diffObject( now, last, watcher.diff, keyOf  );
          if(diff.isTrack){
            trackDiff = diff;
            diff = trackDiff.steps;
          }
          if( diff === true || diff.length ) dirty = true;
        }
      }

    } else{
      // @TODO 是否把多重改掉
      var result = watcher.test(this);
      if(result){
        dirty = true;
        watcher.fn.apply(this, result)
      }
    }
    if(dirty && !watcher.test){
      if(tnow === 'object' && watcher.deep || tnow === 'array'){
        watcher.last = _.clone(now);
      }else{
        watcher.last = now;
      }
      watcher.fn.call(this, now, last, diff, trackDiff && trackDiff.oldKeyMap, trackDiff && trackDiff.dirty)
      if(watcher.once) this.$unwatch(watcher)
    }

    return dirty;
  }
957062
public static WatchMonitor create(Path path, int maxDepth, WatchEvent.Kind<?>... events){
		return new WatchMonitor(path, maxDepth, events);
	}
850479
public static <T> CentralDogmaEndpointGroup<T> ofWatcher(Watcher<T> watcher,
                                                             EndpointListDecoder<T> endpointListDecoder) {
        return new CentralDogmaEndpointGroup<>(watcher, endpointListDecoder);
    }