Initializes the event listeners and subscribers configured in the configuration.
424746
public function initializeEventListeners()
    {
        $configuration = $this->getConfiguration();
        $eventDispatcher = $this->getContainer()->get('event_dispatcher');
        foreach ($configuration->getEventListeners() as $eventName => $listeners) {
            foreach ($listeners as $listener) {
                list($listenerClassName, $listenerMethodName) = explode('::', $listener);

                $listenerInstance = ObjectFactory::getInstance()->newInstance($listenerClassName);
                if ($listenerInstance !== null) {
                    $eventDispatcher->addListener($eventName, array($listenerInstance, $listenerMethodName));
                }
            }
        }

        foreach ($configuration->getEventSubscribers() as $subscriber) {
            $subscriberInstance = ObjectFactory::getInstance()->newInstance($subscriber['class'], $subscriber);
            if ($subscriberInstance instanceof EventSubscriberInterface) {
                $eventDispatcher->addSubscriber($subscriberInstance);
            }
        }
    }
1083297
private void setupStartEndListeners() {
        TransitionSetListener listener = new TransitionSetListener(this);
        for (Transition childTransition : mTransitions) {
            childTransition.addListener(listener);
        }
        mCurrentListeners = mTransitions.size();
    }
1176133
protected <E extends Event> void subscribeEvent(Class<E> eventClass, final Listener<E> listener) {
        locator.inject(listener);
        locator.postConstruct(listener);
        subscribe(eventClass, listener);
    }
718899
public void register(final Object listener) {
		for (Class clazz = listener.getClass(); clazz != null; clazz = clazz.getSuperclass()) {
			Method[] methods = clazz.getMethods();
			for (Method m : methods) {
				if (!m.isAnnotationPresent(Subscribe.class)) continue;
				Class[] params = m.getParameterTypes();

				if (params.length != 1)
					throw new IllegalArgumentException("Method " + m + " has @Subscribe annotation" +
							"and requires " + params.length +
							" arguments, but event-handling methods must require just one argument");
				Class event = params[0];
				EventHandler handler = new EventHandler(listener, m);
				this.handlersByEventType.put(event, handler);
			}
		}
	}
318088
public function initialize()
    {
        Notifire::reset();

        $manager = new NotificationManager();
        $manager->setThrowIfNotNotified(true);
        foreach ($this->handlers as $handler) {
            $manager->addHandler($handler);
        }

        if (null === $this->dispatcher) {
            $this->dispatcher = new EventDispatcher();
        }

        $manager->setEventDispatcher($this->dispatcher);
        foreach ($this->notifications as $notificationName => $notificationClass) {
            Notifire::addNotification($notificationName, $notificationClass);
        }

        Notifire::setManager($manager);
    }
567885
protected void init() {
		addPropertyChangeListener(ENABLED_PROPERTY, new PropertyChangeListener() {

			public void propertyChange(PropertyChangeEvent evt) {
				validatingUpdated();
			}

		});
		validationResultsModel.addPropertyChangeListener(ValidationResultsModel.HAS_ERRORS_PROPERTY,
				childStateChangeHandler);
	}
269205
protected function __init()
    {
        $events = $this->event();

        // --- How to resolve requested module --------------------------------\
        // --------------------------------------------------------------------\
        ## resolve to module by looking on ModuleName\Module class
        ## also set options on array modules, like ['module'=>$opts]
        $events->on(
            ModuleManagerEvents\EventModuleResolve::EVENT_NAME
            , new ModuleManager\Events\ModuleResolve\ListenerResolverDefault
            , 100
        );

        $events->on(
            ModuleManagerEvents\EventModuleResolve::EVENT_NAME
            , new ModuleManager\Events\ModuleResolve\ListenerResolverDirectory
            , 90
        );

        // --- Features Call Immanently after resolve module object -----------\
        // --------------------------------------------------------------------\
        $events->on(
            ModuleManagerEvents\EventModuleInitialize::EVENT_NAME
            , new ModuleManager\Events\ModuleInitialize\ListenerInitInitialization
            , 1000
        );

        $events->on(
            ModuleManagerEvents\EventModuleInitialize::EVENT_NAME
            , new ModuleManager\Events\ModuleInitialize\ListenerInitServices
            , 900
        );

        ## register modules services and actions
        $events->on(
            ModuleManagerEvents\EventModuleInitialize::EVENT_NAME
            , new ModuleManager\Events\ModuleInitialize\ListenerInitNestedContainer
        );


        // --- Features Call After Whole Modules Initialized        -----------\
        // --------------------------------------------------------------------\
        // Event Param: $module_manager

        # Register Actions
        #
        // Note: Actions do not access to Initialized Configs...
        //       actions on registration just must register itself and no need any instantiate
        $events->on(
            EventHeapOfModuleManager::EVENT_MODULES_POSTLOAD
            , new ModuleManager\Events\ModulesPostLoad\ListenerRegisterActions
            , -100
        );

        # Instantiate Merged Config instance() services
        $events->on(
            EventHeapOfModuleManager::EVENT_MODULES_POSTLOAD
            , new ModuleManager\Events\ModulesPostLoad\ListenerInstantiateMergedConfig
            , -500
        );

        # Resolve registered services to module
        $events->on(
            EventHeapOfModuleManager::EVENT_MODULES_POSTLOAD
            , new ModuleManager\Events\ModulesPostLoad\ListenerGrabRegisteredServices
            , -1000
        );

        ## attach application events listener
        $events->on(
            EventHeapOfModuleManager::EVENT_MODULES_POSTLOAD
            , new ModuleManager\Events\ModuleInitialize\ListenerInitSapiEvents
            , -10000
        );
    }
893009
private function doBeforeCompileLaziness(): void
	{
		$builder = $this->getContainerBuilder();
		$dispatcher = $builder->getDefinition($this->prefix('dispatcher'));

		$subscribers = $builder->findByType(EventSubscriberInterface::class);
		foreach ($subscribers as $name => $subscriber) {
			$events = call_user_func([$subscriber->getEntity(), 'getSubscribedEvents']);

			/**
			 * ['eventName' => 'methodName']
			 * ['eventName' => ['methodName', $priority]]
			 * ['eventName' => [['methodName1', $priority], ['methodName2']]]
			 */
			foreach ($events as $event => $args) {
				if (is_string($args)) {
					if (!method_exists((string) $subscriber->getType(), $args)) {
						throw new ServiceCreationException(sprintf('Event listener %s does not have callable method %s', $subscriber->getType(), $args));
					}

					$dispatcher->addSetup('addSubscriberLazy', [$event, $name]);
				} elseif (is_string($args[0])) {
					if (!method_exists((string) $subscriber->getType(), $args[0])) {
						throw new ServiceCreationException(sprintf('Event listener %s does not have callable method %s', $subscriber->getType(), $args[0]));
					}

					$dispatcher->addSetup('addSubscriberLazy', [$event, $name]);
				} else {
					foreach ($args as $arg) {
						if (!method_exists((string) $subscriber->getType(), $arg[0])) {
							throw new ServiceCreationException(sprintf('Event listener %s does not have callable method %s', $subscriber->getType(), $arg[0]));
						}

						$dispatcher->addSetup('addSubscriberLazy', [$event, $name]);
					}
				}
			}
		}
	}
327930
protected function listen()
    {
        $events = app('events');
        if (isset($this->listen)) {
            foreach ($this->listen as $event => $listeners) {
                foreach ($listeners as $listener) {
                    $events->listen($event, $listener);
                }
            }
        }
        
        if (isset($this->subscribe)) {
            foreach ($this->subscribe as $subscriber) {
                $events->subscribe($subscriber);
            }
        }
    }
574897
def setup_model_event_subscribers(config, model_cls, schema):
    
    events_map = get_events_map()
    model_events = schema.get('_event_handlers', {})
    event_kwargs = {'model': model_cls}

    for event_tag, subscribers in model_events.items():
        type_, action = event_tag.split('_')
        event_objects = events_map[type_][action]

        if not isinstance(event_objects, list):
            event_objects = [event_objects]

        for sub_name in subscribers:
            sub_func = resolve_to_callable(sub_name)
            config.subscribe_to_events(
                sub_func, event_objects, **event_kwargs)
457347
protected void initialize() {
        super.initialize();
        _serviceProviders = Collections.synchronizedMap(new HashMap<Class, ServiceProvider>());
        _bcsListeners = Collections.synchronizedList(new ArrayList<BeanContextServicesListener>());
    }
1013160
public void registerListener(ConfigurationListener<?> listener) {
    if(!listeners.contains(listener)) {
      listeners.add(listener);
      Set<ConfigurationListener<?>> newListener = new HashSet<ConfigurationListener<?>>();
      newListener.add(listener);
      notifyListeners(newListener, liveConfigParser, log);
    }
  }
188998
public void init(int size, int columns, ColorPickerSwatch.OnColorSelectedListener listener) {
        mNumColumns = columns;
        Resources res = getResources();
        if (size == ColorPickerDialog.SIZE_LARGE) {
            mSwatchLength = res.getDimensionPixelSize(R.dimen.color_swatch_large);
            mMarginSize = res.getDimensionPixelSize(R.dimen.color_swatch_margins_large);
        } else {
            mSwatchLength = res.getDimensionPixelSize(R.dimen.color_swatch_small);
            mMarginSize = res.getDimensionPixelSize(R.dimen.color_swatch_margins_small);
        }
        mOnColorSelectedListener = listener;

        mDescription = res.getString(R.string.color_swatch_description);
        mDescriptionSelected = res.getString(R.string.color_swatch_description_selected);
    }
194195
protected function bindEvents(): void
    {
        $userConfig = $this->app['config'][static::$abstract];

        $handler = new EventHandler($this->app->events, $userConfig);

        $handler->subscribe();

        $handler->subscribeQueueEvents($this->app->queue);

        if (isset($userConfig['send_default_pii']) && $userConfig['send_default_pii'] !== false) {
            $handler->subscribeAuthEvents();
        }
    }
1301737
public void subscribeToEvent(final EventListener eventListener, final Class<? extends AbstractTaskEvent> eventType) {

		synchronized (this.subscriptions) {

			List<EventListener> subscribers = this.subscriptions.get(eventType);
			if (subscribers == null) {
				subscribers = new ArrayList<EventListener>();
				this.subscriptions.put(eventType, subscribers);
			}
			subscribers.add(eventListener);
		}

	}
891338
private void init() {
        // Add this node to parents children
        if (null != parent) { parent.getChildren().add(this); }

        children.addListener((ListChangeListener<TreeNode>) c -> {
            while (c.next()) {
                if (c.wasRemoved()) { c.getRemoved().forEach(removedItem -> removedItem.removeAllTreeNodeEventListeners()); }
            }
            getTreeRoot().fireTreeNodeEvent(CHILDREN_CHANGED);
        });
    }
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);
    }
  }