public synchronized void registerListener(Listener listener, String viewName, String viewVersion) {

    String name = viewVersion == null ? viewName : ViewEntity.getViewName(viewName, viewVersion);

    Set<Listener> listeners = this.listeners.get(name);

    if (listeners == null) {
      listeners = Sets.newSetFromMap(new ConcurrentHashMap<Listener, Boolean>());
      this.listeners.put(name, listeners);
    }

    listeners.add(listener);
  }
Register the given listener to listen for events from the view identified by the given name and version.

@param listener    the listener
@param viewName    the view name
@param viewVersion the view version; null indicates all versions
ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java