Registers a listener for bundle events and scans already active bundles.
167635
@Override
    protected void onStart()
    {
        m_mappings = new HashMap<Bundle, List<T>>();
        // listen to bundles events
        m_context.addBundleListener( m_bundleListener = new SynchronousBundleListener()
        {

            public void bundleChanged( final BundleEvent bundleEvent )
            {
                switch( bundleEvent.getType() )
                {
                    case BundleEvent.STARTED:
                        register( bundleEvent.getBundle() );
                        break;
                    case BundleEvent.STOPPED:
                        unregister( bundleEvent.getBundle() );
                        break;
                }
            }

        }
            );

        // scan already started bundles
        Bundle[] bundles = m_context.getBundles();
        if( bundles != null )
        {
            for( Bundle bundle : bundles )
            {
                if( bundle.getState() == Bundle.ACTIVE )
                {
                    register( bundle );
                }
            }
        }
    }
934326
protected function registerListeners()
    {
        Orm::addListener(
            $this->entityDescriptor->className(),
            Select::ACTION_BEFORE_SELECT,
            [$this, 'beforeSelect']
        );

        Orm::addListener(
            $this->entityDescriptor->className(),
            Select::ACTION_AFTER_SELECT,
            [$this, 'afterSelect']
        );

        Orm::addListener(
            $this->entityDescriptor->className(),
            Delete::ACTION_BEFORE_DELETE,
            [$this, 'beforeDelete']
        );
    }
1350477
protected final void notifyListeners() {
        Iterator<SMTPClientFutureListener<E>> it = null;
        synchronized (this) {
            if (listeners != null) {
                // notify the listeners
                it  = listeners.iterator();

                listeners = null;
            }
        }
        if (it != null) {
            while(it.hasNext()) {
                SMTPClientFutureListener<E> listener = null;
                try {
                    listener = it.next();
                    listener.operationComplete(this);
                } catch (Throwable e) {
                    LOGGER.warn("Exception thrown while executing " + SMTPClientFutureListener.class.getName() + " " + listener, e);
                }
            }
        }
    }
1273630
function registerListeners(scope, listeners) {
        var fns = [];

        for (var name in listeners) {
            if (listeners.hasOwnProperty(name) && listeners[name]) {
                fns.push(eventBus.on(name, $injector.invoke(listeners[name])));
            }
        }

        // make sure handlers are destroyed along with scope
        scope.$on('$destroy', function () {
            for (var i = 0; i < fns.length; i++) {
                fns[i]();
            }
        });
    }
945823
function addListeners() {
	if (listenersAdded) return;
	listenersAdded = true;

	if (cluster.isMaster) {
		// Listen for worker responses to requests for local metrics
		cluster.on('message', (worker, message) => {
			if (message.type === GET_METRICS_RES) {
				const request = requests.get(message.requestId);
				message.metrics.forEach(registry => request.responses.push(registry));
				request.pending--;

				if (request.pending === 0) {
					// finalize
					requests.delete(message.requestId);
					clearTimeout(request.errorTimeout);

					if (request.failed) return; // Callback already run with Error.

					const registry = AggregatorRegistry.aggregate(request.responses);
					const promString = registry.metrics();
					request.done(null, promString);
				}
			}
		});
	}
}
266791
public void onCreate(Bundle bundle) {
		if (mParentDelegate == null && bundle != null) {
			bundle = bundle.getBundle(MOXY_DELEGATE_TAGS_KEY);
		}

		mIsAttached = false;
		mBundle = bundle != null ? bundle : new Bundle();

		//get base tag for presenters
		if (bundle == null || !mBundle.containsKey(mKeyTag)) {
			mDelegateTag = generateTag();
		} else {
			mDelegateTag = bundle.getString(mKeyTag);
		}

		//bind presenters to view
		mPresenters = MvpFacade.getInstance().getMvpProcessor().getMvpPresenters(mDelegated, mDelegateTag);

		for (MvpDelegate childDelegate : mChildDelegates) {
			childDelegate.onCreate(bundle);
		}
	}
375109
@Override
    public void bundleChanged(BundleEvent event) {
        switch (event.getType()) {
            case BundleEvent.INSTALLED:
                processBundle(event.getBundle());
                break;
            case BundleEvent.UNINSTALLED:
                // TODO: remove entries?  how do i know if this bundle's entries have been overridden by another bundle?
                break;
        }
    }
39611
public void bundleChanged(BundleEvent bundleEvent) {
        final String topic = getTopic(bundleEvent);

        // Bail quickly if the event is one that should be ignored
        if (topic == null) {
            return;
        }

        // Event properties
        Map<String, Object> eventProperties = new HashMap<String, Object>();

        // "event" --> the original event object
        eventProperties.put(EventConstants.EVENT, bundleEvent);

        // Non-null result from getBundle
        // "bundle.id" --> source bundle id as Long
        // "bundle.symbolicName" --> source bundle's symbolic name
        // "bundle" --> the source bundle object
        Bundle bundle = bundleEvent.getBundle();
        if (bundle != null) {
            eventProperties.put(EventConstants.BUNDLE_ID, Long.valueOf(bundle.getBundleId()));
            String symbolicName = bundle.getSymbolicName();
            if (symbolicName != null) {
                eventProperties.put(EventConstants.BUNDLE_SYMBOLICNAME, symbolicName);
            }
            eventProperties.put(EventConstants.BUNDLE, bundle);
        }

        // Construct and fire the event
        Event event = new Event(topic, eventProperties);
        eventAdmin.postEvent(event);
    }
45262
def _register_event_listeners(self, cls):
        
        event.listen(cls, 'after_insert', self._new_listener)
        event.listen(cls, 'after_update', self._update_listener)
        event.listen(cls, 'after_delete', self._delete_listener)
182297
protected function registerListeners()
    {
        $listeners  = (array) $this->get('listeners');
        $dispatcher = $this->getDispatcher();

        $defaultOptions = [
            'class' => '',
            'priority' => ListenerPriority::NORMAL,
            'enabled' => true,
        ];

        foreach ($listeners as $name => $listener) {
            if ($listener instanceof ClassMeta || is_string($listener) || is_callable($listener)) {
                $listener = ['class' => $listener];
            }

            $listener = array_merge($defaultOptions, (array) $listener);

            if (!$listener['enabled']) {
                continue;
            }

            if (!is_numeric($name) && is_callable($listener['class'])) {
                $dispatcher->listen($name, $listener['class']);
            } else {
                $dispatcher->addListener($this->container->newInstance($listener['class']), $listener['priority']);
            }
        }
    }
788937
public void addComponentListeners() {
        // avoid duplicate registration
        removeListeners();

        for (final AbstractField<?> field : allComponents) {
            if (field instanceof TextChangeNotifier) {
                ((TextChangeNotifier) field).addTextChangeListener(new ChangeListener(field));
            }

            if (field instanceof Table) {
                ((Table) field).addItemSetChangeListener(new ChangeListener(field));
            }
            field.addValueChangeListener(new ChangeListener(field));
        }
    }
228858
void register(Object listener) {
    Multimap<Class<?>, Subscriber> listenerMethods = findAllSubscribers(listener);

    for (Map.Entry<Class<?>, Collection<Subscriber>> entry : listenerMethods.asMap().entrySet()) {
      Class<?> eventType = entry.getKey();
      Collection<Subscriber> eventMethodsInListener = entry.getValue();

      CopyOnWriteArraySet<Subscriber> eventSubscribers = subscribers.get(eventType);

      if (eventSubscribers == null) {
        CopyOnWriteArraySet<Subscriber> newSet = new CopyOnWriteArraySet<Subscriber>();
        eventSubscribers =
            MoreObjects.firstNonNull(subscribers.putIfAbsent(eventType, newSet), newSet);
      }

      eventSubscribers.addAll(eventMethodsInListener);
    }
  }
712463
private void trackFilters(final BundleContext bundleContext) {
		final ServiceTracker<Filter, FilterWebElement> filterTracker = FilterTracker
				.createTracker(extenderContext, bundleContext);

		filterTracker.open();
		trackers.add(0, filterTracker);

		// FIXME needed?
		final ServiceTracker<FilterMapping, FilterMappingWebElement> filterMappingTracker = FilterMappingTracker
				.createTracker(extenderContext, bundleContext);

		filterMappingTracker.open();
		trackers.add(0, filterMappingTracker);
	}
385467
public void registerListenerExtensions() {
    if (listenerExtensionsRegistered) {
      throw H2O.fail("Listeners already registered");
    }

    long before = System.currentTimeMillis();
    ServiceLoader<H2OListenerExtension> extensionsLoader = ServiceLoader.load(H2OListenerExtension.class);
    for (H2OListenerExtension ext : extensionsLoader) {
      ext.init();
      listenerExtensions.put(ext.getName(), ext);
    }
    listenerExtensionsRegistered = true;
    registerListenerExtensionsMillis = System.currentTimeMillis() - before;
  }
100770
def add_bundle_listener(self, listener):
        
        if listener is None or not hasattr(listener, "bundle_changed"):
            raise BundleException("Invalid bundle listener given")

        with self.__bnd_lock:
            if listener in self.__bnd_listeners:
                self._logger.warning(
                    "Already known bundle listener '%s'", listener
                )
                return False

            self.__bnd_listeners.append(listener)
            return True
799960
private void notifyActive(Peer peer) {
		for(Listener listener : new HashSet<>(listeners)) {
			listener.onActive(peer);
		}
	}
174964
protected void addListeners() {
    // Listen for result changes, including the one we monitor
    context.addResultListener(this);
    context.addVisualizationListener(this);
    // Listen for database events only when needed.
    if(task.has(UpdateFlag.ON_DATA)) {
      context.addDataStoreListener(this);
    }
  }