Register the listenerJingles, waiting for a Jingle stanza that tries to
establish a new session.
424757
private void initJingleSessionRequestListeners() {
        StanzaFilter initRequestFilter = new StanzaFilter() {
            // Return true if we accept this packet
            @Override
            public boolean accept(Stanza pin) {
                if (pin instanceof IQ) {
                    IQ iq = (IQ) pin;
                    if (iq.getType().equals(IQ.Type.set)) {
                        if (iq instanceof Jingle) {
                            Jingle jin = (Jingle) pin;
                            if (jin.getAction().equals(JingleActionEnum.SESSION_INITIATE)) {
                                return true;
                            }
                        }
                    }
                }
                return false;
            }
        };

        jingleSessionRequestListeners = new ArrayList<>();

        // Start a packet listener for session initiation requests
        connection.addAsyncStanzaListener(new StanzaListener() {
            @Override
            public void processStanza(Stanza packet) {
                triggerSessionRequested((Jingle) packet);
            }
        }, initRequestFilter);
    }
620348
public JingleSession createOutgoingJingleSession(EntityFullJid responder) throws XMPPException {
        JingleSession session = new JingleSession(connection, null, connection.getUser(), responder, jingleMediaManagers);

        triggerSessionCreated(session);

        return session;
    }
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);
				}
			}
		});
	}
}
1144339
function registerListeners() {
  const exit = function exit(signal) {
    console.log(chalk.bgBlack.yellow(`Received ${signal} => Exiting`))
    process.exit()
  }
  const SIGABRT = 'SIGABRT'
  const SIGHUP = 'SIGHUP'
  const SIGINT = 'SIGINT'
  const SIGQUIT = 'SIGQUIT'
  const SIGTERM = 'SIGTERM'

  process.on(SIGABRT, () => exit(SIGABRT))
  process.on(SIGHUP, () => exit(SIGHUP))
  process.on(SIGINT, () => exit(SIGINT))
  process.on(SIGQUIT, () => exit(SIGQUIT))
  process.on(SIGTERM, () => exit(SIGTERM))
}
527134
public synchronized void registerSSLConfigChangeListener(SSLConfigChangeListener listener, SSLConfigChangeEvent event) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.entry(tc, "registerSSLConfigChangeListener", new Object[] { listener, event });

        List<SSLConfigChangeListener> listenerList = sslConfigListenerMap.get(event.getAlias());

        if (listenerList != null) {
            // used to hold sslconfig -> list of listener references
            listenerList.add(listener);
            sslConfigListenerMap.put(event.getAlias(), listenerList);
        } else {
            listenerList = new ArrayList<SSLConfigChangeListener>();
            listenerList.add(listener);
            sslConfigListenerMap.put(event.getAlias(), listenerList);
        }

        // used to hold listener -> listener event references
        sslConfigListenerEventMap.put(listener, event);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.exit(tc, "registerSSLConfigChangeListener");
    }
199268
def on(self):
        
        assert spotifyconnect._session_instance.player.num_listeners(
            spotifyconnect.PlayerEvent.MUSIC_DELIVERY) == 0
        spotifyconnect._session_instance.player.on(
            spotifyconnect.PlayerEvent.MUSIC_DELIVERY, self._on_music_delivery)
532425
protected void triggerMediaReceived(String participant) {
        List<JingleListener> listeners = getListenersList();
        for (JingleListener li : listeners) {
            if (li instanceof JingleSessionListener) {
                JingleSessionListener sli = (JingleSessionListener) li;
                sli.sessionMediaReceived(this, participant);
            }
        }
    }
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;
  }
253689
@Override
    public IQ processJingle(JingleSession session, Jingle jingle, JingleActionEnum action) {
        IQ response;

        response = session.createJingleError(jingle, JingleError.MALFORMED_STANZA);

        return response;
    }
610516
public void addListeners()
    {
        String strUserName = this.getProperty(DBParams.USER_NAME);
        this.getScreenRecord().getField(UserScreenRecord.USER).setString(strUserName);
        
        String strMessage = "Login required";
        if (this.getTask() != null)
            if (this.getTask().getApplication() != null)
        {
            BaseApplication application = (BaseApplication)this.getTask().getApplication();
            strMessage = application.getResources(ResourceConstants.ERROR_RESOURCE, true).getString(strMessage);
            this.getScreenRecord().getField(UserScreenRecord.STATUS_LINE).setString(strMessage);
        }
        
        super.addListeners();
    }
1054464
@Override
    public void start() throws Exception
    {
        try
        {
            reRegisterServices();
        }
        catch ( KeeperException e )
        {
            log.error("Could not register instances - will try again later", e);
        }
        client.getConnectionStateListenable().addListener(connectionStateListener);
    }
1298398
@Override
    public void register(Object listener)
    {
        if (!(listener instanceof EventListener))
        {
            throw new IllegalArgumentException("Listener must implement EventListener");
        }
        listeners.add(((EventListener) listener));
    }
1333500
private void registerListeners() {
    protocol.registerAppendHandler(this::append);
    protocol.registerBackupHandler(this::backup);
    protocol.registerConsumeHandler(this::consume);
    protocol.registerResetConsumer(this::reset, threadContext);
  }
568671
public void notifySipSessionListeners(SipSessionEventType sipSessionEventType) {
		MobicentsSipApplicationSession sipApplicationSession = getSipApplicationSession();
		if(sipApplicationSession != null) {
			SipContext sipContext = sipApplicationSession.getSipContext();
			List<SipSessionListener> sipSessionListeners =
				sipContext.getListeners().getSipSessionListeners();
			if(sipSessionListeners.size() > 0) {
				if(logger.isDebugEnabled()) {
					logger.debug("notifying sip session listeners of context " + sipContext.getApplicationName() + " of following event " +
							sipSessionEventType);
				}
				ClassLoader oldClassLoader = java.lang.Thread.currentThread().getContextClassLoader();
				sipContext.enterSipContext();
				SipSessionEvent sipSessionEvent = new SipSessionEvent(this.getFacade());
				for (SipSessionListener sipSessionListener : sipSessionListeners) {
					try {
						if(logger.isDebugEnabled()) {
							logger.debug("notifying sip session listener " + sipSessionListener.getClass().getName() + " of context " +
									key.getApplicationName() + " of following event " + sipSessionEventType);
						}
						if(SipSessionEventType.CREATION.equals(sipSessionEventType)) {
							sipSessionListener.sessionCreated(sipSessionEvent);
						} else if (SipSessionEventType.DELETION.equals(sipSessionEventType)) {
							sipSessionListener.sessionDestroyed(sipSessionEvent);
						} else if (SipSessionEventType.READYTOINVALIDATE.equals(sipSessionEventType)) {
							sipSessionListener.sessionReadyToInvalidate(sipSessionEvent);
						}
					} catch (Throwable t) {
						logger.error("SipSessionListener threw exception", t);
					}
				}
				sipContext.exitSipContext(oldClassLoader);
			}
		}
	}
101406
def login_listener(app, user):
    
    @after_this_request
    def add_user_session(response):
        """Regenerate current session and add to the SessionActivity table.

        .. note:: `flask.session.regenerate()` actually calls Flask-KVSession's
            `flask_kvsession.KVSession.regenerate`.
        """
        # Regenerate the session to avoid session fixation vulnerabilities.
        session.regenerate()
        # Save the session first so that the sid_s gets generated.
        app.session_interface.save_session(app, session, response)
        add_session(session)
        current_accounts.datastore.commit()
        return response
657765
private void registerListener(final ChangesLogWrapper logWrapper, TransactionableResourceManager txResourceManager)
      throws RepositoryException
   {
      try
      {
         // Why calling the listeners non tx aware has been done like this:
         // 1. If we call them in the commit phase and we use Arjuna with ISPN, we get:
         //       ActionStatus.COMMITTING > is not in a valid state to be invoking cache operations on.
         //       at org.infinispan.interceptors.TxInterceptor.enlist(TxInterceptor.java:195)
         //       at org.infinispan.interceptors.TxInterceptor.enlistReadAndInvokeNext(TxInterceptor.java:167)
         //       at org.infinispan.interceptors.TxInterceptor.visitGetKeyValueCommand(TxInterceptor.java:162)
         //       at org.infinispan.commands.read.GetKeyValueCommand.acceptVisitor(GetKeyValueCommand.java:64)
         //    This is due to the fact that ISPN enlist the cache even for a read access and enlistments are not 
         //    allowed in the commit phase
         // 2. If we call them in the commit phase, we use Arjuna with ISPN and we suspend the current tx,
         //    we get deadlocks because we try to acquire locks on cache entries that have been locked by the main tx.
         // 3. If we call them in the afterComplete, we use JOTM with ISPN and we suspend and resume the current tx, we get:
         //       jotm: resume: Invalid Transaction Status:STATUS_COMMITTED (Current.java, line 743) 
         //       javax.transaction.InvalidTransactionException: Invalid resume org.objectweb.jotm.TransactionImpl
         //       at org.objectweb.jotm.Current.resume(Current.java:744)
         //    This is due to the fact that it is not allowed to resume a tx when its status is STATUS_COMMITED

         txResourceManager.addListener(new TransactionableResourceManagerListener()
         {
            public void onCommit(boolean onePhase) throws Exception
            {
            }

            public void onAfterCompletion(int status) throws Exception
            {
               if (status == Status.STATUS_COMMITTED)
               {
                  // Since the tx is successfully committed we can call components non tx aware

                  // The listeners will need to be executed outside the current tx so we suspend
                  // the current tx we can face enlistment issues on product like ISPN
                  transactionManager.suspend();

                  SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
                  {
                     public Void run()
                     {
                        notifySaveItems(logWrapper.getChangesLog(), false);
                        return null;
                     }
                  });
                  // Since the resume method could cause issue with some TM at this stage, we don't resume the tx
               }
            }

            public void onAbort() throws Exception
            {
            }
         });
      }
      catch (Exception e)
      {
         throw new RepositoryException("The listener for the components not tx aware could not be added", e);
      }
   }
773193
protected void doExecuteListener(Session session, List<Message> messages) throws JMSException {
        if (!isAcceptMessagesWhileStopping() && !isRunning()) {
            if (logger.isWarnEnabled()) {
                logger.warn("Rejecting received messages because of the listener container "
                        + "having been stopped in the meantime: " + messages);
            }
            rollbackIfNecessary(session);
            throw new MessageRejectedWhileStoppingException();
        }

        try {
            for (Message message : messages) {
                invokeListener(session, message);
            }
        } catch (JMSException ex) {
            rollbackOnExceptionIfNecessary(session, ex);
            throw ex;
        } catch (RuntimeException ex) {
            rollbackOnExceptionIfNecessary(session, ex);
            throw ex;
        } catch (Error err) {
            rollbackOnExceptionIfNecessary(session, err);
            throw err;
        }
        commitIfNecessary(session, messages);
    }