Fetch or create a new listener for the given object name
968017
public void addClientNotificationListener(RESTRequest request, NotificationRegistration notificationRegistration, JSONConverter converter) {
        String objectNameStr = notificationRegistration.objectName.getCanonicalName();

        NotificationTargetInformation nti = toNotificationTargetInformation(request, objectNameStr);

        // Get the listener
        ClientNotificationListener listener = listeners.get(nti);
        if (listener == null) {
            listener = new ClientNotificationListener(this);
            ClientNotificationListener mapListener = listeners.putIfAbsent(nti, listener);

            if (mapListener != null) {
                listener = mapListener;
            }
        }

        // Grab the wrapper filter which will be registered in the MBeanServer
        NotificationFilter filter = listener.getClientWrapperFilter();

        // Check whether the producer of the notification is local or remote.
        if (nti.getRoutingInformation() == null) {
            // Add the notification in the MBeanServer        
            MBeanServerHelper.addClientNotification(notificationRegistration.objectName,
                                                    listener,
                                                    filter,
                                                    null,
                                                    converter);
        } else {
            // Add the notification listener to the Target-Client Manager through EventAdmin
            MBeanRoutedNotificationHelper helper = MBeanRoutedNotificationHelper.getMBeanRoutedNotificationHelper();
            helper.addRoutedNotificationListener(nti, listener, converter);
        }

        // Add the filters to the listener
        listener.addClientNotification(notificationRegistration.filters);
    }
173206
function getListener(event, id) {
    if (hasListeners(event)) {
      var listeners = getListeners(event);

      if (_.has(listeners, id)) {
        return listeners[id];
      }
    }

    return false;
  }
1222632
def add_listener(self, event, callback, single=False, priority=1):
        
        event_stack = self._events[event]
        event_stack.append({
            "callback": callback,
            "single": single,
            "priority": priority
        })
        event_stack.sort(key=lambda x: x['priority'])
868380
function on(priv, eventName, listener) {
  check(eventName, 'eventName').is.aString.and.oneOf(EVENT_NAMES)();
  check(listener, 'listener').is.aFunction();

  getListeners(priv, eventName).push(listener);
}
517765
function (name, data, options) {
            var _listeners = this.__handlers__[name],
                _listener,
                _result = null;
            if (_listeners) {
                for (var i = 0, length = _listeners.length; i < length; i++) {
                    _listener = _listeners[i];
                    if (_listener && _listener.handler) {
                        if(options && options.method=='apply'){
                            _result = _listener.handler.apply(_listener.context || _listener.owner, data);
                        } else {
                            _result = _listener.handler.call(_listener.context || _listener.owner, _listener.owner, data, options);
                        }
                        if (false === _result) {
                            return false;
                        }
                    }
                }
            }

            return this;
        }
92193
function eventListenerHub(emitter, eventName) {
  var self = object.create(eventListenerHub.prototype);

  self.emitter = emitter;
  self.eventName = eventName;
  self.handlers = [];
  self.defaultHandlerFn = null;

  return self;
}
790458
function (object, event, callback) {
        var index = this.indexOf(object);
        var listener = this.listeners[index];
        if (!listener) {
            listener = {
                'object': object,
                'events': {}
            };
            this.listeners.push(listener);
        }

        var callbacks = listener.events[event];
        if (!callbacks) {
            callbacks = [];
            listener.events[event] = callbacks;
        }

        // add the callback if it does not yet exist
        if (callbacks.indexOf(callback) == -1) {
            callbacks.push(callback);
        }
    }
41636
public void addNamingObjectListener(NamingObjectListener nol) {
        if (nol == null)
            throw new IllegalArgumentException("The NameingObjectListener must not be null");

        ArrayList listener = getListener();

        synchronized(listener) {
            if (listener.contains(nol))
                return;
            listener.add(nol);
        }
    }
1024177
function executeListener( listener, data, scope ){
    const isFunction = typeof listener === 'function';
    
    switch( data.length ){
        case 0:
            listenEmpty    ( listener, isFunction, scope );
            break;
        case 1:
            listenOne      ( listener, isFunction, scope, data[ 0 ] );
            break;
        case 2:
            listenTwo      ( listener, isFunction, scope, data[ 0 ], data[ 1 ] );
            break;
        case 3:
            listenThree    ( listener, isFunction, scope, data[ 0 ], data[ 1 ], data[ 2 ] );
            break;
        default:
            listenMany     ( listener, isFunction, scope, data );
            break;
    }
}
360704
function(object, events) {
        if (!object.__isInterfaceImplemented('events')) {
            object.__implementInterface('events', this.interface);
        }

        object.__initEvents();

        _.each(events, function(eventListeners, eventName) {
            _.each(eventListeners, function(listener, listenerName) {
                object.__addEventListener(eventName, listenerName, listener);
            });
        });
    }
1033688
function ( obj, args ) {
		args = args || {};

		utility.iterate( args, function ( v, k ) {
			if ( regex.element_update.test( k ) ) {
				obj[k] = v;
			}
			else if ( k === "class" ) {
				!string.isEmpty( v ) ? element.klass( obj, v ) : element.klass( obj, "*", false );
			}
			else if ( k.indexOf( "data-" ) === 0 ) {
				element.data( obj, k.replace( "data-", "" ), v );
			}
			else if ( k === "id" ) {
				var o = observer.listeners;

				if ( o[obj.id] !== undefined ) {
					o[k] = o[obj.id];
					delete o[obj.id];
				}
			}
			else {
				element.attr ( obj, k, v );
			}
		});

		return obj;
	}
876320
function listen(name, callback) {
    if (!showdown.helper.isString(name)) {
      throw Error('Invalid argument in converter.listen() method: name must be a string, but ' + typeof name + ' given');
    }

    if (typeof callback !== 'function') {
      throw Error('Invalid argument in converter.listen() method: callback must be a function, but ' + typeof callback + ' given');
    }

    if (!listeners.hasOwnProperty(name)) {
      listeners[name] = [];
    }
    listeners[name].push(callback);
  }
760223
function appendListener(event, listener, once) {

    this.events[event] = this.events[event] || [];
    this.events[event].push({
      "listener": listener,
      "once": !!once
    });

    this.emit('newListener', event, listener);

    if (this.events[event].length > this.maxListeners) {

      console.warn('warning: possible EventEmitter memory leak detected. ',
        this.events[event].length, ' listeners added. ',
        'Use emitter.setMaxListeners() to increase limit. ',
        this);

    }

  }
108454
def on(self, name, callback, once=False):
        
        if name not in self.event_listeners:
            self.event_listeners[name] = []

        self.event_listeners[name].append((callback, once))
115174
public void addListeners(PropertyChangeListener listener, Object newObject, Set updateSet) {
        removeListeners();
        if (newObject != null) {
            // check for local synthetics
            TriggerBinding syntheticTrigger = getSyntheticTriggerBinding(newObject);
            MetaClass mc = InvokerHelper.getMetaClass(newObject);
            if (syntheticTrigger != null) {
                PropertyBinding psb = new PropertyBinding(newObject, propertyName);
                PropertyChangeProxyTargetBinding proxytb = new PropertyChangeProxyTargetBinding(newObject, propertyName, listener);

                syntheticFullBinding = syntheticTrigger.createBinding(psb, proxytb);
                syntheticFullBinding.bind();
                updateSet.add(newObject);
            } else if (!mc.respondsTo(newObject, "addPropertyChangeListener", NAME_PARAMS).isEmpty()) {
                InvokerHelper.invokeMethod(newObject, "addPropertyChangeListener", new Object[] {propertyName, listener});
                localListener = listener;
                updateSet.add(newObject);
            } else if (!mc.respondsTo(newObject, "addPropertyChangeListener", GLOBAL_PARAMS).isEmpty()) {
                InvokerHelper.invokeMethod(newObject, "addPropertyChangeListener", listener);
                globalListener = listener;
                updateSet.add(newObject);
            }
        }
        currentObject = newObject;
    }
345502
function addListener(attr,func,child,update)
        {
          if(typeof func !== 'function') return bind;

          var isInput = (['value','checked'].indexOf(attr) !== -1),
              isStyle = (_allStyles.indexOf(attr) !== -1),
              listeners;

          if(this.toString() !== bind.toString())
          {
            if(child)
            {
              var children = this.querySelectorAll('*'),
                  len = children.length,
                  listenerObj;
              for(var x=0;x<len;x++)
              {
                listenerObj = children[x].attrListeners();
                if(isInput || (attr === _all))
                {
                  if(children[x].addInputBinding !== undefined) children[x].addInputBinding();
                  if(children[x].addInputBoxBinding !== undefined) children[x].addInputBoxBinding();
                }
                if(isStyle)
                {
                  bind.injectStyleProperty(children[x],attr);
                  listeners = (update ? '_parentStyleUpdateListeners' : '_parentStyleListeners');
                  if(listenerObj[listeners][attr] === undefined) listenerObj[listeners][attr] = [];
                  listenerObj[listeners][attr].push({parent:this,func:func});
                }
                else
                {
                  if(attr === _all)
                  {
                    listeners = (update ? '_parentStyleUpdateListeners' : '_parentStyleListeners');
                    var len = _allStyles.length;
                    for(var i = 0;i<len;i++)
                    {
                      bind.injectStyleProperty(children[x],_allStyles[i]);
                    }
                    if(listenerObj[listeners][_all] === undefined) listenerObj[listeners][_all] = [];
                      listenerObj[listeners][_all].push({parent:this,func:func});
                  }
                  listeners = (update ? '_parentAttrUpdateListeners' : '_parentAttrListeners');
                  if(listenerObj[listeners][attr] === undefined) listenerObj[listeners][attr] = [];
                  listenerObj[listeners][attr].push({parent:this,func:func});
                }
              }
            }
            else
            {
              listenerObj = this.attrListeners();
              if(isStyle)
              {
                listeners = (update ? '_styleUpdateListeners' : '_styleListeners');
                bind.injectStyleProperty(this,attr);
                if(listenerObj[listeners][attr] === undefined) listenerObj[listeners][attr] = [];
                listenerObj[listeners][attr].push(func);
              }
              else
              {
                if(isInput || (attr === _all))
                {
                  if(this.addInputBinding !== undefined) this.addInputBinding();
                  if(this.addInputBoxBinding !== undefined) this.addInputBoxBinding();
                }
                if(attr === _all)
                {
                  listeners = (update ? '_styleUpdateListeners' : '_styleListeners');
                  var len = _allStyles.length;
                  for(var x = 0;x<len;x++)
                  {
                    bind.injectStyleProperty(this,_allStyles[x]);
                  }
                  if(listenerObj[listeners][attr] === undefined) listenerObj[listeners][attr] = [];
                  listenerObj[listeners][attr].push(func);
                }
                listeners = (update ? '_attrUpdateListeners' : '_attrListeners');
                if(listenerObj[listeners][attr] === undefined) listenerObj[listeners][attr] = [];
                listenerObj[listeners][attr].push(func);
              }
            }
          }
          else
          {
            if(isInput || (attr === _all))
            {
              var inputs = document.querySelectorAll('input, textarea'),
                  len = inputs.length;
              for(var x=0;x<len;x++)
              {
                if(inputs[x].addInputBinding !== undefined) inputs[x].addInputBinding();
                if(inputs[x].addInputBoxBinding !== undefined) inputs[x].addInputBoxBinding();
              }
            }
            if(isStyle)
            {
              var els = Array.prototype.slice.call(document.body.querySelectorAll('*')),
                  len = (els.length+1);
              els.unshift(document.body);
              for(var x=0;x<len;x++)
              {
                bind.injectStyleProperty(els[x],attr);
              }
              listeners = (update ? _styleUpdateListeners : _styleListeners);
              if(listeners[attr] === undefined) listeners[attr] = [];
              listeners[attr].push(func);
            }
            else
            {
              if(attr === _all)
              {
                var els = Array.prototype.slice.call(document.body.querySelectorAll('*')),
                    len = (els.length+1),
                    lenStyles = _allStyles.length;
                els.unshift(document.body);
                for(var x=0;x<len;x++)
                {
                  for(var i=0;i<lenStyles;i++)
                  {
                    bind.injectStyleProperty(els[x],_allStyles[i]);
                  }
                }
                listeners = (update ? _styleUpdateListeners : _styleListeners);
                if(listeners[attr] === undefined) listeners[attr] = [];
                listeners[attr].push(func);
              }
              listeners = (update ? _attrUpdateListeners : _attrListeners);
              if(listeners[attr] === undefined) listeners[attr] = [];
              listeners[attr].push(func);
            }
          }
        }
71938
def add_listener(self, listener, question):
        """"""
        now = current_time_millis()
        self.listeners.append(listener)
        if question is not None:
            for record in self.cache.entries_with_name(question.name):
                if question.answered_by(record) and not record.is_expired(now):
                    listener.update_record(self, now, record)
        self.notify_all()