Add a servlet timer to this application session
@param servletTimer the servlet timer to add
500162
public void addServletTimer(ServletTimer servletTimer){
		if(servletTimers == null) {
			servletTimers = new ConcurrentHashMap<String, ServletTimer>(1);
		}
		servletTimers.putIfAbsent(servletTimer.getId(), servletTimer);
	}
880664
@SuppressWarnings("javadoc")
    protected void firePacketSendingListeners(final TopLevelStreamElement sendTopLevelStreamElement) {
        if (debugger != null) {
            debugger.onOutgoingStreamElement(sendTopLevelStreamElement);
        }

        if (!(sendTopLevelStreamElement instanceof Stanza)) {
            return;
        }
        Stanza packet = (Stanza) sendTopLevelStreamElement;

        final List<StanzaListener> listenersToNotify = new LinkedList<>();
        synchronized (sendListeners) {
            for (ListenerWrapper listenerWrapper : sendListeners.values()) {
                if (listenerWrapper.filterMatches(packet)) {
                    listenersToNotify.add(listenerWrapper.getListener());
                }
            }
        }
        if (listenersToNotify.isEmpty()) {
            return;
        }
        // Notify in a new thread, because we can
        asyncGo(new Runnable() {
            @Override
            public void run() {
                for (StanzaListener listener : listenersToNotify) {
                    try {
                        listener.processStanza(packet);
                    }
                    catch (Exception e) {
                        LOGGER.log(Level.WARNING, "Sending listener threw exception", e);
                        continue;
                    }
                }
            }
        });
    }
355128
public B timerWithDate(String timerDate) {
    TimeDate timeDate = createInstance(TimeDate.class);
    timeDate.setTextContent(timerDate);

    TimerEventDefinition timerEventDefinition = createInstance(TimerEventDefinition.class);
    timerEventDefinition.setTimeDate(timeDate);

    element.getEventDefinitions().add(timerEventDefinition);

    return myself;
  }
1135868
public void addInvitationListener(WorkgroupInvitationListener invitationListener) {
        synchronized (invitationListeners) {
            if (!invitationListeners.contains(invitationListener)) {
                invitationListeners.add(invitationListener);
            }
        }
    }
1210414
private void startAppendTimer() {
    // Set a timer that will be used to periodically synchronize with other nodes
    // in the cluster. This timer acts as a heartbeat to ensure this node remains
    // the leader.
    log.trace("Starting append timer");
    appendTimer = raft.getThreadContext().schedule(Duration.ZERO, raft.getHeartbeatInterval(), this::appendMembers);
  }
1362750
@Override
    public void onStartup(Set<Class<?>> clazzes, ServletContext servletContext) throws ServletException {

        try {
            WsocHandlerImpl wsocServletHandler = new WsocHandlerImpl();
            ((WebApp31) servletContext).registerWebSocketHandler(wsocServletHandler);

            ServerContainerExt serverContainer = new ServerContainerExt();

            servletContext.setAttribute(WebSocketContainerManager.SERVER_CONTAINER_ATTRIBUTE, serverContainer);

            WsocServletContextListener wscl = new WsocServletContextListener();
            wscl.initialize(serverContainer.getEndpointManager());
            servletContext.addListener(wscl);

            WsocHttpSessionListener listener = new WsocHttpSessionListener();
            listener.initialize(serverContainer.getEndpointManager());
            servletContext.addListener(listener);

            if (clazzes != null) {
                String endPointContext = servletContext.getContextPath();
                Set<EndpointHelper> annotatedEndpoints = getAnnotatedServerEndpointClasses(clazzes, endPointContext, serverContainer);
                Set<EndpointHelper> programmaticEndpoints = getServerEndpointClasses(clazzes, endPointContext);
                Set<Class<? extends ServerApplicationConfig>> serverAppConfigs = getServerApplicationConfigClasses(clazzes);

                Set<EndpointHelper> helpers = determineEndpoints(annotatedEndpoints, programmaticEndpoints, serverAppConfigs);

                for (EndpointHelper helper : helpers) {
                    serverContainer.addEndpoint(helper);
                }
            }
            //  findbugs wanted runtime exception first...
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception f) {
            // allow instrumented FFDC to be used here

            //DeploymentException needs to stop the application from starting
            if (f instanceof DeploymentException) {
                throw new RuntimeException(f);
            }
        }
    }
617905
public void addMasterListeners()
    {
        super.addMasterListeners();
        this.addListener(new CalcTimeoutTimeHandler(null));
        this.addListener(new NotifyTimeoutProcessHandler(null));
        this.addListener(new NoDeleteModifyHandler(true, false));   // Can't delete these
    }
1156579
private void addDispatcherServlet() {
        ServletHolder servletHolder = new ServletHolder(new CitrusMessageDispatcherServlet(this));
        servletHolder.setName(getServletName());
        servletHolder.setInitParameter("contextConfigLocation", contextConfigLocation);

        servletHandler.addServlet(servletHolder);

        ServletMapping servletMapping = new ServletMapping();
        servletMapping.setServletName(getServletName());
        servletMapping.setPathSpec(servletMappingPath);

        servletHandler.addServletMapping(servletMapping);
    }
871055
public synchronized void addEventListener(EventListener listener)
        throws IllegalArgumentException
    {
        if ((listener instanceof HttpSessionActivationListener)
            || (listener instanceof HttpSessionAttributeListener)
            || (listener instanceof HttpSessionBindingListener)
            || (listener instanceof HttpSessionListener))
        {
            if (_sessionManager != null)
                _sessionManager.addEventListener(listener);
            _sessionListeners= LazyList.add(_sessionListeners, listener);
        }

        if (listener instanceof ServletRequestListener)
        {
            _requestListeners= LazyList.add(_requestListeners, listener);
        }

        if (listener instanceof ServletRequestAttributeListener)
        {
             _requestAttributeListeners= LazyList.add(_requestAttributeListeners, listener);
        }

        if (listener instanceof ServletContextAttributeListener)
        {            
            _contextAttributeListeners= LazyList.add(_contextAttributeListeners, listener);
        }
        
        super.addEventListener(listener);
    }
1251767
public void setHandler(String name) throws ServletException {
		if(!isValid()) {
			throw new IllegalStateException("the session has already been invalidated, no handler can be set on it anymore !");
		}
		if(name != null && name.equals(handlerServlet)) {
			return ;
		}
		SipContext sipContext = getSipApplicationSession().getSipContext();
		MobicentsSipServlet container = sipContext.findSipServletByName(name);

		if(container == null && sipContext.getSipRubyController() == null) {
			throw new ServletException("the sip servlet with the name "+ name +
					" doesn't exist in the sip application " + sipContext.getApplicationName());
		}
		this.handlerServlet = name;
		getSipApplicationSession().setCurrentRequestHandler(handlerServlet);
		if(logger.isDebugEnabled()) {
			if(name !=null) {
				logger.debug("Session Handler for application " + getKey().getApplicationName() + " set to " + handlerServlet + " on sip session " + key);
			} else {
				logger.debug("Session Handler for application " + getKey().getApplicationName() + " set to " + sipContext.getSipRubyController() + " on sip session " + key);
			}
		}
	}
243786
@Override
  public void onTimer(String timerName) {
    if (timerName.equals(IDLE_SESSION_TIMER_NAME)) {
      checkIdleAppSession();
    }
    else if (timerName.equals(TIMER_NAME_INTERIM)) {
      if (context != null) {
        try {
          Request interimRecord = createInterimRecord();
          context.interimIntervalElapses(this, interimRecord);
          sendAndStateLock.lock();
          session.send(interimRecord, ClientRfSessionImpl.this);
          setState(PENDING_INTERIM);
          sessionData.setTsTimerId(null);
        }
        catch (Exception e) {
          logger.debug("Can not process Interim Interval AVP", e);
        }
        finally {
          sendAndStateLock.unlock();
        }
      }
    }
    else {
      logger.warn("Received an unknown timer '{}' for Session-ID '{}'", timerName, getSessionId());
    }
  }
50745
public void addChangingSimons() {
		timer.schedule(new TimerTask() {
			final Stopwatch tlStopwatch = SimonManager.getStopwatch("TL");

			@Override
			public void run() {
				try {
					lock.lock();
					System.out.println("TL " + addStopwatchSplit(tlStopwatch));
				} finally {
					lock.unlock();
				}
			}
		}, 0, 10000L);
	}
1200100
@Override
  public void onTimer(String timerName) {
    if (timerName.equals(IDLE_SESSION_TIMER_NAME)) {
      checkIdleAppSession();
    }
    else if (timerName.equals(TIMER_NAME_TS)) {
      try {
        sendAndStateLock.lock();
        sessionData.setTsTimerId(null);
        handleEvent(new Event(TIMEOUT_EXPIRES, null));
      }
      catch (Exception e) {
        logger.debug("Can not handle event", e);
      }
      finally {
        sendAndStateLock.unlock();
      }
    }
    else {
      logger.warn("Received an unknown timer '{}' for Session-ID '{}'", timerName, getSessionId());
    }
  }
240977
public void setSessionHandler(SessionHandler sessionHandler) {
        handler.setSessionsEnabled(sessionHandler != null);
        handler.setSessionHandler(sessionHandler);
    }
477379
@Override
    public void addEventListener(EventListener listener) {
        if (listener instanceof SessionListener) {
            sessionListeners.add((SessionListener)listener);
        }
        if (listener instanceof SessionAttributeListener) {
            sessionAttributeListeners.add((SessionAttributeListener)listener);
        }
    }
264359
public void timeout(ServletTimer timer) {
		SipApplicationSession sipApplicationSession = timer.getApplicationSession();
		Map<String, Object> attributes = (Map<String, Object>)timer.getInfo();
		try {			
			String callerAddress = (String)attributes.get("caller");
			String callerDomain = (String)attributes.get("callerDomain");
			SipURI fromURI = sipFactory.createSipURI(callerAddress, callerDomain);
			Address fromAddress = sipFactory.createAddress(fromURI);
			String customerName = (String) attributes.get("customerName");
			BigDecimal amount = (BigDecimal) attributes.get("amountOrder");
			String customerPhone = (String) attributes.get("customerPhone");
			String customerContact = (String) attributes.get("customerContact");
			Address toAddress = sipFactory.createAddress(customerPhone);									
			logger.info("preparing to call : "+ toAddress);
			SipServletRequest sipServletRequest = 
				sipFactory.createRequest(sipApplicationSession, "INVITE", fromAddress, toAddress);
			if(attributes.get("adminApproval") != null) {
				logger.info("preparing speech for admin approval");
				customerContact = (String) attributes.get("adminContactAddress");
				//TTS file creation		
				StringBuffer stringBuffer = new StringBuffer();
				stringBuffer.append(customerName);
				stringBuffer.append(" has placed an order of $");
				stringBuffer.append(amount);
				stringBuffer.append(". Press 1 to approve and 2 to reject.");				
				sipServletRequest.getSession().setAttribute("speechUri",
						java.net.URI.create("data:" + URLEncoder.encode("ts("+ stringBuffer +")", "UTF-8")));
				
			}			
			

			URI requestURI = sipFactory.createURI(customerContact);			
			sipServletRequest.setRequestURI(requestURI);
							
			//copying the attributes in the sip session since the media listener depends on it
			Iterator<Entry<String,Object>> attrIterator = attributes.entrySet().iterator();
			while (attrIterator.hasNext()) {
				Map.Entry<java.lang.String, java.lang.Object> entry = (Map.Entry<java.lang.String, java.lang.Object>) attrIterator
						.next();
				sipServletRequest.getSession().setAttribute(entry.getKey(), entry.getValue());
			}
			SipSession sipSession = sipServletRequest.getSession();
			
			if (sipSession.getAttribute("deliveryDate") != null) {			
				String announcementFile = MMSUtil.audioFilePath + "/OrderDeliveryDate.wav";
				sipServletRequest.getSession().setAttribute("speechUri",
				java.net.URI.create(announcementFile));
				logger.info("Preparing to play Delivery Date Announcement : " + announcementFile);
			} 
			
			//Media Server Control Creation
			MediaSession mediaSession = MMSUtil.getMsControl().createMediaSession();
			NetworkConnection conn = mediaSession
			.createNetworkConnection(NetworkConnection.BASIC);

			SdpPortManager sdpManag = conn.getSdpPortManager();
			
			sdpManag.generateSdpOffer();
			
			byte[] sdpOffer = null;
			int numTimes = 0;
			while(sdpOffer == null && numTimes<10) {
				sdpOffer = sdpManag.getMediaServerSessionDescription();
				Thread.sleep(500);
				numTimes++;
			}
			MediaGroup mg = mediaSession.createMediaGroup(MediaGroup.PLAYER_SIGNALDETECTOR);
			sipServletRequest.getSession().setAttribute("mediaGroup", mg);
			sipServletRequest.getSession().setAttribute("mediaSession", mediaSession);
			sipServletRequest.setContentLength(sdpOffer.length);
			sipServletRequest.setContent(sdpOffer, "application/sdp");	
			MediaConnectionListener listener = new MediaConnectionListener();
			listener.setInviteRequest(sipServletRequest);
//			provider.addConnectionListener(listener);
			sipServletRequest.getSession().setAttribute("connection", conn);
			sipServletRequest.send();
			mg.getSignalDetector().addListener(new DTMFListener(mg, sipServletRequest.getSession(), MMSUtil.audioFilePath));
			conn.join(Direction.DUPLEX, mg);
			logger.info("waiting to get the SDP from Media Server before sending the INVITE to " + callerAddress + "@" + callerDomain);
		} catch (Exception e) {
			logger.error("An unexpected exception occured while creating the request for delivery date", e);
		}
	}
397148
@Override
    public HandlerRegistration addMapZoomEndHandler(final Runnable zoomHandler){
        return mapWidget.addZoomChangeHandler(zoomChangeMapEvent -> zoomHandler.run());
    }