callers: SipApplicationDispatcher.addSipApplications()
347294
@Override
    public boolean notifySipContextListeners(SipContextEvent event) {
        boolean ok = true;
        if (logger.isDebugEnabled()) {
            logger.debug(this.deploymentInfoFacade.getSipServlets().size() + " container to notify of " + event.getEventType());
        }
        if (event.getEventType() == SipContextEventType.SERVLET_INITIALIZED) {
            //fixes https://github.com/RestComm/sip-servlets/issues/165
            //now the SipService is totally ready/started, we prepare 
            //the context again just in case some att was not properly
            //initiated
            try {
                prepareServletContext();
            } catch (Exception e) {
                logger.warn("Couldnt prepare context", e);
            }              
            if (!timerService.isStarted()) {
                timerService.start();
            }
            if (!proxyTimerService.isStarted()) {
                proxyTimerService.start();
            }
            if (!sasTimerService.isStarted()) {
                sasTimerService.start();
            }
        }

        // if(this.available) {
        enterSipApp(null, null, false, true);
        boolean batchStarted = enterSipAppHa(true);
        try {

            for (String servletName : this.deploymentInfoFacade.getSipServlets().keySet()) {
                SipServletImpl managedServlet = (SipServletImpl) this.getChildrenMap().get(servletName);
                if (logger.isDebugEnabled()) {
                    logger.debug("managedServlet " + managedServlet.getServletInfo().getName() + ", class : "
                            + managedServlet.getClass().getName());
                }
                try {
                    final ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();

                    try {
                        final ClassLoader cl = this.getSipContextClassLoader();
                        Thread.currentThread().setContextClassLoader(cl);
                        // http://code.google.com/p/sipservlets/issues/detail?id=135
                        // kakonyii: in SipStandardContext, there was a threadBindingListener which handled thread context switches (to get proper jndi context namespace selector, etc),
                        // in wildfly we use threadSetupAction from the deployment object for that purpose:
                        bindThreadBindingListener();

                        Servlet sipServlet = managedServlet.getServlet().getInstance();
                        if (sipServlet instanceof SipServlet) {
                            // Fix for issue 1086 (http://code.google.com/p/mobicents/issues/detail?id=1086) :
                            // Cannot send a request in SipServletListener.initialize() for servlet-selection applications
                            boolean servletHandlerWasNull = false;
                            if (this.getServletHandler() == null) {
                                this.setServletHandler(managedServlet.getServletInfo().getName());
                                servletHandlerWasNull = true;
                            }

                            switch (event.getEventType()) {
                                case SERVLET_INITIALIZED: {
                                    SipServletContextEvent sipServletContextEvent = new SipServletContextEvent(
                                            getServletContext(), (SipServlet) sipServlet);
                                    List<SipServletListener> sipServletListeners = sipListeners.getSipServletsListeners();
                                    if (logger.isDebugEnabled()) {
                                        logger.debug(sipServletListeners.size()
                                                + " SipServletListener to notify of servlet initialization");
                                    }
                                    for (SipServletListener sipServletListener : sipServletListeners) {
                                        sipServletListener.servletInitialized(sipServletContextEvent);
                                    }
                                    break;
                                }
                                case SIP_CONNECTOR_ADDED: {
                                    // reload the outbound interfaces if they have changed
                                    this.getServletContext().setAttribute(javax.servlet.sip.SipServlet.OUTBOUND_INTERFACES,
                                            sipApplicationDispatcher.getOutboundInterfaces());
                                    // https://code.google.com/p/sipservlets/issues/detail?id=246
                                    this.getServletContext().setAttribute("org.mobicents.servlet.sip.SIP_CONNECTORS",
                                            sipApplicationDispatcher.getSipService().findSipConnectors());

                                    List<SipConnectorListener> sipConnectorListeners = sipListeners.getSipConnectorListeners();
                                    if (logger.isDebugEnabled()) {
                                        logger.debug(sipConnectorListeners.size()
                                                + " SipConnectorListener to notify of sip connector addition");
                                    }
                                    for (SipConnectorListener sipConnectorListener : sipConnectorListeners) {
                                        sipConnectorListener.sipConnectorAdded((SipConnector) event.getEventObject());
                                    }
                                    break;
                                }
                                case SIP_CONNECTOR_REMOVED: {
                                    // reload the outbound interfaces if they have changed
                                    this.getServletContext().setAttribute(javax.servlet.sip.SipServlet.OUTBOUND_INTERFACES,
                                            sipApplicationDispatcher.getOutboundInterfaces());
                                    // https://code.google.com/p/sipservlets/issues/detail?id=246
                                    this.getServletContext().setAttribute("org.mobicents.servlet.sip.SIP_CONNECTORS",
                                            sipApplicationDispatcher.getSipService().findSipConnectors());

                                    List<SipConnectorListener> sipConnectorListeners = sipListeners.getSipConnectorListeners();
                                    if (logger.isDebugEnabled()) {
                                        logger.debug(sipConnectorListeners.size()
                                                + " SipConnectorListener to notify of sip connector removal");
                                    }
                                    for (SipConnectorListener sipConnectorListener : sipConnectorListeners) {
                                        sipConnectorListener.sipConnectorRemoved((SipConnector) event.getEventObject());
                                    }
                                    break;
                                }
                            }
                            if (servletHandlerWasNull) {
                                this.setServletHandler("");
                            }
                        }
                    } finally {
                        // http://code.google.com/p/sipservlets/issues/detail?id=135
                        // kakonyii: in SipStandardContext, there was a threadBindingListener which handled thread context switches (to get proper jndi context namespace selector, etc),
                        // in wildfly we use threadSetupAction from the deployment object for that purpose:
                        unbindThreadBindingListener();
                        Thread.currentThread().setContextClassLoader(oldClassLoader);
                    }
                } catch (ServletException e) {
                    logger.error("Cannot allocate the servlet " + managedServlet.getClass() + " for notifying the listener "
                            + " of the event " + event.getEventType(), e);
                    ok = false;
                } catch (Throwable e) {
                    logger.error("An error occured when notifying the servlet " + managedServlet.getClass() + " of the event "
                            + event.getEventType(), e);
                    ok = false;
                }

                // FIXME: kakonyii: do we need this deallocation in wildfly?
                // try {
                // if(sipServlet != null) {
                // wrapper.deallocate(sipServlet);
                // }
                // } catch (ServletException e) {
                // logger.error("Deallocate exception for servlet" + wrapper.getName(), e);
                // ok = false;
                // } catch (Throwable e) {
                // logger.error("Deallocate exception for servlet" + wrapper.getName(), e);
                // ok = false;
                // }
            }
        } finally {
            exitSipAppHa(null, null, batchStarted);
            exitSipApp(null, null);
        }
        // }
        return ok;
    }
576722
public static void initApplication(Application app){
		
		// Add the Jawr tag handler to the MarkupParserFactory 
		MarkupFactory factory = new MarkupFactory(){
			
			public MarkupParser newMarkupParser(final MarkupResourceStream resource)
		    {
		       MarkupParser parser = new MarkupParser(new XmlPullParser(), resource);
		       parser.add(new JawrWicketLinkTagHandler());
		       return parser;
		    }
		};
		
		app.getMarkupSettings().setMarkupFactory(factory);
		
		// Add the Jawr link resolver
		app.getPageSettings().addComponentResolver(new JawrWicketLinkResolver());
	}
763177
public SipApplicationSession createApplicationSession(boolean managed) {
		MobicentsSipApplicationSession sipApplicationSessionImpl = null; 
		HttpSession httpSession = threadLocalHttpSession.get();
		// make sure we don't create a new sip app session if the http session has already one associated
		if(httpSession != null) {
			ConvergedSession convergedSession = (ConvergedSession) httpSession;
			sipApplicationSessionImpl = convergedSession.getApplicationSession(false);
		}
		if(sipApplicationSessionImpl == null) {
			sipApplicationSessionImpl =
				(MobicentsSipApplicationSession)sipFactoryImpl.createApplicationSessionByAppName(sipContext.getApplicationName(), managed);
			associateHttpSession(sipApplicationSessionImpl);
		}
		return sipApplicationSessionImpl;
	}
736510
public void into(@NonNull RemoteViews remoteViews, @IdRes int viewId, int appWidgetId,
      @Nullable Callback callback) {
    into(remoteViews, viewId, new int[] { appWidgetId }, callback);
  }
484522
public void installApp(Functions.Func callback) {
        if (isPwaSupported()) {
            appInstaller = new AppInstaller(callback);
            appInstaller.prompt();
        }
    }
1241559
public VoiceGrant setOutgoingApplication(
        String outgoingApplicationSid,
        Map<String, Object> outgoingApplicationParams
    ) {
        this.outgoingApplicationSid = outgoingApplicationSid;
        this.outgoingApplicationParams = outgoingApplicationParams;
        return this;
    }
453426
@Override
    public PortletDelegationDispatcher createRequestDispatcher(
            PortletRequest portletRequest, IPortletDefinitionId delegatePortletDefinitionId) {
        final HttpServletRequest request =
                this.portalRequestUtils.getPortletHttpRequest(portletRequest);

        final String windowID = portletRequest.getWindowID();
        final IPortletWindowId parentPortletWindowId =
                this.portletWindowRegistry.getPortletWindowId(request, windowID);

        final IPortletEntity delegatePortletEntity =
                this.portletEntityRegistry.getOrCreateDelegatePortletEntity(
                        request, parentPortletWindowId, delegatePortletDefinitionId);
        final IPortletEntityId delegatePortletEntityId = delegatePortletEntity.getPortletEntityId();

        final IPortletWindow delegatePortletWindow =
                this.portletWindowRegistry.createDelegatePortletWindow(
                        request, delegatePortletEntityId, parentPortletWindowId);

        final IPerson person = this.personManager.getPerson(request);
        final int userId = person.getID();

        return new PortletDelegationDispatcherImpl(
                delegatePortletWindow,
                userId,
                portalRequestUtils,
                personManager,
                portletRenderer,
                portalUrlProvider,
                portletDelegationManager);
    }
36625
def _load_11_6(self, **kwargs):
        """"""
        if self._check_existence_by_collection(self._meta_data['container'], kwargs['name']):
            return super(Protocol_Sip, self)._load(**kwargs)
        msg = 'The application resource named, {}, does not exist on the device.'.format(kwargs['name'])
        resp = Response()
        resp.status_code = 404
        ex = HTTPError(msg, response=resp)
        raise ex
1178558
public MobicentsSipApplicationSession getApplicationSession(boolean create) {		
		
		//First check if the http session has the app session id in its attributes		
		SipApplicationSessionKey key = null;
		// need to check if the session is still valid
		if(httpSession.isValidIntern()) {	
			key = (SipApplicationSessionKey) httpSession.getAttribute(APPLICATION_SESSION_ID_ATTRIBUTE_NAME); 
		}
		SipContext sipContext = (SipContext)sipManager.getContainer();
		if(key != null) {
			MobicentsSipApplicationSession sipAppSession = sipManager.getSipApplicationSession(key, false);
			if (sipAppSession != null) {
				// make sure to acquire this app session and add it to the set of app sessions we monitor in the context of the application
				// to release them all when we exit application code
				sipContext.enterSipApp(sipAppSession, null, true, true);
				return sipAppSession;
			} else {
				if(logger.isDebugEnabled()) {
					logger.debug(key + " found in http session " + httpSession.getId() + " but not present in the manager. already invalidated ? creating new sip application session");
				}
			}
		}
		
		//Otherwise proceed as normally
		
		//the application session if currently associated is returned,
		MobicentsSipApplicationSession sipApplicationSession =
			sipManager.findSipApplicationSession(httpSession);
		if(sipApplicationSession == null && create) {
			//however if no application session is associated it is created, 
			//associated with the HttpSession and returned.
			
			//not needed anymore since the sipappsesionkey is not a callid anymore but a rnadom uuid
//			ExtendedListeningPoint listeningPoint = 
//				sipNetworkInterfaceManager.getExtendedListeningPoints().next();						
			SipApplicationSessionKey sipApplicationSessionKey = SessionManagerUtil.getSipApplicationSessionKey(
					sipContext.getApplicationName(), 
					null,
					null);
			
			sipApplicationSession = 
				sipManager.getSipApplicationSession(sipApplicationSessionKey, true);
			
			// Store the App Session ID in the HTTP sessions to recover it from there when it's transfered to a new node.
			httpSession.setAttribute(APPLICATION_SESSION_ID_ATTRIBUTE_NAME, 
					sipApplicationSession.getKey());
			sipApplicationSession.addHttpSession(httpSession);			
		}
		if(sipApplicationSession != null) {
			// make sure to acquire this app session and add it to the set of app sessions we monitor in the context of the application
			// to release them all when we exit application code
			sipContext.enterSipApp(sipApplicationSession, null, true, true);
			return sipApplicationSession.getFacade();
		} else {
			return null;
		}
//		return sipApplicationSession;
	}
908640
public static void removeSipFactory(Context envCtx, String appName, SipFactory sipFactory) {
		if(envCtx != null) {
			try {
				javax.naming.Context sipContext = (javax.naming.Context)envCtx.lookup(SIP_SUBCONTEXT + "/" + appName);
				sipContext.unbind(SIP_FACTORY_JNDI_NAME);
			} catch (NamingException e) {
				logger.error(sm.getString("naming.unbindFailed", e));
			}
		}
	}
1265356
protected <T extends InvocationMarshaller<?>> T addDispatcher (InvocationDispatcher<T> disp)
    {
        T marsh = _invmgr.registerDispatcher(disp);
        _marshallers.add(marsh);
        return marsh;
    }
547014
public MobicentsSipApplicationSession removeSipApplicationSession(final MobicentsSipApplicationSessionKey key) {
		if(logger.isDebugEnabled()) {
			logger.debug("Removing a sip application session with the key : " + key);
		}
		MobicentsSipApplicationSession sipApplicationSession  = sipApplicationSessions.remove(key);
		if(sipApplicationSession != null) {
			final String appGeneratedKey = sipApplicationSession.getKey().getAppGeneratedKey();
			if(appGeneratedKey != null) {
				sipApplicationSessionsByAppGeneratedKey.remove(appGeneratedKey);
			}
		}
		return sipApplicationSession;
	}
1201835
private void addCP() throws DependencyResolutionRequiredException, MalformedURLException, InvocationTargetException, NoSuchMethodException, IllegalAccessException {
        List runtimeClasspathElements = project.getRuntimeClasspathElements();

        for (Object runtimeClasspathElement : runtimeClasspathElements) {
            String element = (String) runtimeClasspathElement;
            addUrl(new File(element).toURI().toURL());
        }
    }
802930
@Override
	public void addSipConnector(String ipAddress, int port, String transport) throws LifecycleException
	{
		SipConnector sipConnector = mssContainer.createSipConnector(ipAddress, port, transport);
		mssContainer.addSipConnector(sipConnector);
	}
1150524
public void addDerivedSipSessions(MobicentsSipSession derivedSession) {
		if(derivedSipSessions == null) {
			this.derivedSipSessions = new ConcurrentHashMap<String, MobicentsSipSession>();
		}
		derivedSipSessions.putIfAbsent(derivedSession.getKey().getToTag(), derivedSession);
	}
404438
public void setOutboundInterface(SipURI outboundInterface) {
		if(outboundInterface == null) {
			throw new NullPointerException("outbound Interface param shouldn't be null");
		}
		List<SipURI> list = this.sipFactoryImpl.getSipNetworkInterfaceManager().getOutboundInterfaces();
		SipURI networkInterface = null;
		for(SipURI networkInterfaceURI : list) {
			if(networkInterfaceURI.equals(outboundInterface)) {
				networkInterface = networkInterfaceURI;
				break;
			}
		}
		
		if(networkInterface == null) throw new IllegalArgumentException("Network interface for " +
				outboundInterface + " not found");		
		
		this.outboundInterface = networkInterface;
	}
611578
private void addInfoForRoutingBackToContainer(SipApplicationRouterInfo routerInfo, String applicationSessionId, String applicationName) throws ParseException, SipException {
		final Request request = (Request) super.message;
		final javax.sip.address.SipURI sipURI = JainSipUtils.createRecordRouteURI(
				sipFactoryImpl.getSipNetworkInterfaceManager(),
				request);
		sipURI.setLrParam();
		sipURI.setParameter(MessageDispatcher.ROUTE_PARAM_DIRECTIVE,
				routingDirective.toString());
		if(getSipSession().getRegionInternal() != null) {
			sipURI.setParameter(MessageDispatcher.ROUTE_PARAM_REGION_LABEL,
					getSipSession().getRegionInternal().getLabel());
			sipURI.setParameter(MessageDispatcher.ROUTE_PARAM_REGION_TYPE,
					getSipSession().getRegionInternal().getType().toString());
		}
		sipURI.setParameter(MessageDispatcher.ROUTE_PARAM_PREV_APPLICATION_NAME,
				applicationName);
		sipURI.setParameter(MessageDispatcher.ROUTE_PARAM_PREV_APP_ID,
				applicationSessionId);
		final javax.sip.address.Address routeAddress =
			SipFactoryImpl.addressFactory.createAddress(sipURI);
		final RouteHeader routeHeader =
			SipFactoryImpl.headerFactory.createRouteHeader(routeAddress);
		request.addFirst(routeHeader);
		// adding the application router info to avoid calling the AppRouter twice
		// See Issue 791 : http://code.google.com/p/mobicents/issues/detail?id=791
		final MobicentsSipSession session = getSipSession();
		session.setNextSipApplicationRouterInfo(routerInfo);
	}