protected void initInternalApplicationComponents() throws LifecycleException {
        if (sipApplicationDispatcher == null) {
            setApplicationDispatcher();
        }
        if (sipFactoryFacade == null) {
            sipFactoryFacade = new SipFactoryFacade((SipFactoryImpl) sipApplicationDispatcher.getSipFactory(), this);
        }
        if (sipSessionsUtil == null) {
            sipSessionsUtil = new SipSessionsUtilImpl(this);
        }

        // needed when restarting applications through the tomcat manager
        this.getServletContext().setAttribute(javax.servlet.sip.SipServlet.SIP_FACTORY, sipFactoryFacade);
        this.getServletContext().setAttribute(javax.servlet.sip.SipServlet.TIMER_SERVICE, timerService);
        this.getServletContext().setAttribute(javax.servlet.sip.SipServlet.SUPPORTED,
                Arrays.asList(sipApplicationDispatcher.getExtensionsSupported()));
        this.getServletContext().setAttribute("javax.servlet.sip.100rel", Boolean.TRUE);
        this.getServletContext().setAttribute(javax.servlet.sip.SipServlet.SUPPORTED_RFCs,
                Arrays.asList(sipApplicationDispatcher.getRfcSupported()));
        this.getServletContext().setAttribute(javax.servlet.sip.SipServlet.SIP_SESSIONS_UTIL, sipSessionsUtil);
        this.getServletContext().setAttribute(javax.servlet.sip.SipServlet.OUTBOUND_INTERFACES,
                sipApplicationDispatcher.getOutboundInterfaces());
        this.getServletContext().setAttribute("org.mobicents.servlet.sip.SIP_CONNECTORS",
                sipApplicationDispatcher.getSipService().findSipConnectors());
        this.getServletContext().setAttribute("org.mobicents.servlet.sip.DNS_RESOLVER",
                sipApplicationDispatcher.getDNSResolver());

        if (timerService == null || !timerService.isStarted()) {
            // Distributable
            if (logger.isDebugEnabled()) {
                logger.debug("prepareServletContext - timerService is null" + getName());
                logger.debug("prepareServletContext - getDistributable: " + getDistributable() + ", hasDistributableManager: " + hasDistributableManager);
            }

// FIXME: distributable not supported
//          if(getDistributable() && hasDistributableManager) {
//              if(logger.isInfoEnabled()) {
//                  logger.info("Using the Fault Tolerant Timer Service to schedule fault tolerant timers in a distributed environment");
//              }
//              timerService = new FaultTolerantTimerServiceImpl((DistributableSipManager)getSipManager());
//          } else {
//              timerService = new TimerServiceImpl();
//          }
                timerService = new TimerServiceImpl(sipApplicationDispatcher.getSipService(), applicationName);
        }
        this.getServletContext().setAttribute(javax.servlet.sip.SipServlet.TIMER_SERVICE, timerService);

        if (sasTimerService == null || !sasTimerService.isStarted()) {
            // FIXME: distributable not supported
            // distributable if(getDistributable() && hasDistributableManager) {
            // sasTimerService = new
            // FaultTolerantSasTimerService((DistributableSipManager)getSipManager(),
            // 4);
            // } else {
            // sasTimerService = new
            // StandardSipApplicationSessionTimerService();
            // }
            String sasTimerServiceType = sipApplicationDispatcher.getSipService()
                    .getSasTimerServiceImplementationType();
            if (sasTimerServiceType != null && sasTimerServiceType.equalsIgnoreCase("Standard")) {
                sasTimerService = new StandardSipApplicationSessionTimerService(applicationName);
            } else if (sasTimerServiceType != null && sasTimerServiceType.equalsIgnoreCase("Default")) {
                sasTimerService = new DefaultSipApplicationSessionTimerService(applicationName);
            } else {
                sasTimerService = new StandardSipApplicationSessionTimerService(applicationName);
            }
        }

        if (proxyTimerService == null) {
            String proxyTimerServiceType = sipApplicationDispatcher.getSipService().getProxyTimerServiceImplementationType();
            if (proxyTimerServiceType != null && proxyTimerServiceType.equalsIgnoreCase("Standard")) {
                proxyTimerService = new ProxyTimerServiceImpl(applicationName);
            } else if (proxyTimerServiceType != null && proxyTimerServiceType.equalsIgnoreCase("Default")) {
                String strCorePoolSize = this.getServletContext().getInitParameter(TIMER_SERVICE_POOL_SIZE);
                if (strCorePoolSize != null && !strCorePoolSize.isEmpty()) {
                    try {
                        int CorePoolSize = Integer.parseInt(strCorePoolSize);
                        proxyTimerService = new DefaultProxyTimerService(applicationName, CorePoolSize);
                    } catch (NumberFormatException ex) {
                        logger.warn("Failed to parse timer service pool size with string value [" + strCorePoolSize + "], use default value.");
                        proxyTimerService = new DefaultProxyTimerService(applicationName);
                    }
                } else {
                    proxyTimerService = new DefaultProxyTimerService(applicationName);
                }
            } else {
                proxyTimerService = new ProxyTimerServiceImpl(applicationName);
            }
        }
    }
protected void initInternalApplicationComponents ( ) throws LifecycleException { if ( sipApplicationDispatcher == null ) { setApplicationDispatcher ( ) ; } if ( sipFactoryFacade == null ) { sipFactoryFacade = new SipFactoryFacade ( ( SipFactoryImpl ) sipApplicationDispatcher . getSipFactory ( ) , this ) ; } if ( sipSessionsUtil == null ) { sipSessionsUtil = new SipSessionsUtilImpl ( this ) ; } this . getServletContext ( ) . setAttribute ( javax . servlet . sip . SipServlet . SIP_FACTORY , sipFactoryFacade ) ; this . getServletContext ( ) . setAttribute ( javax . servlet . sip . SipServlet . TIMER_SERVICE , timerService ) ; this . getServletContext ( ) . setAttribute ( javax . servlet . sip . SipServlet . SUPPORTED , Arrays . asList ( sipApplicationDispatcher . getExtensionsSupported ( ) ) ) ; this . getServletContext ( ) . setAttribute ( "javax.servlet.sip.100rel" , Boolean . TRUE ) ; this . getServletContext ( ) . setAttribute ( javax . servlet . sip . SipServlet . SUPPORTED_RFCs , Arrays . asList ( sipApplicationDispatcher . getRfcSupported ( ) ) ) ; this . getServletContext ( ) . setAttribute ( javax . servlet . sip . SipServlet . SIP_SESSIONS_UTIL , sipSessionsUtil ) ; this . getServletContext ( ) . setAttribute ( javax . servlet . sip . SipServlet . OUTBOUND_INTERFACES , sipApplicationDispatcher . getOutboundInterfaces ( ) ) ; this . getServletContext ( ) . setAttribute ( "org.mobicents.servlet.sip.SIP_CONNECTORS" , sipApplicationDispatcher . getSipService ( ) . findSipConnectors ( ) ) ; this . getServletContext ( ) . setAttribute ( "org.mobicents.servlet.sip.DNS_RESOLVER" , sipApplicationDispatcher . getDNSResolver ( ) ) ; if ( timerService == null || ! timerService . isStarted ( ) ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "prepareServletContext - timerService is null" + getName ( ) ) ; logger . debug ( "prepareServletContext - getDistributable: " + getDistributable ( ) + ", hasDistributableManager: " + hasDistributableManager ) ; } timerService = new TimerServiceImpl ( sipApplicationDispatcher . getSipService ( ) , applicationName ) ; } this . getServletContext ( ) . setAttribute ( javax . servlet . sip . SipServlet . TIMER_SERVICE , timerService ) ; if ( sasTimerService == null || ! sasTimerService . isStarted ( ) ) { String sasTimerServiceType = sipApplicationDispatcher . getSipService ( ) . getSasTimerServiceImplementationType ( ) ; if ( sasTimerServiceType != null && sasTimerServiceType . equalsIgnoreCase ( "Standard" ) ) { sasTimerService = new StandardSipApplicationSessionTimerService ( applicationName ) ; } else if ( sasTimerServiceType != null && sasTimerServiceType . equalsIgnoreCase ( "Default" ) ) { sasTimerService = new DefaultSipApplicationSessionTimerService ( applicationName ) ; } else { sasTimerService = new StandardSipApplicationSessionTimerService ( applicationName ) ; } } if ( proxyTimerService == null ) { String proxyTimerServiceType = sipApplicationDispatcher . getSipService ( ) . getProxyTimerServiceImplementationType ( ) ; if ( proxyTimerServiceType != null && proxyTimerServiceType . equalsIgnoreCase ( "Standard" ) ) { proxyTimerService = new ProxyTimerServiceImpl ( applicationName ) ; } else if ( proxyTimerServiceType != null && proxyTimerServiceType . equalsIgnoreCase ( "Default" ) ) { String strCorePoolSize = this . getServletContext ( ) . getInitParameter ( TIMER_SERVICE_POOL_SIZE ) ; if ( strCorePoolSize != null && ! strCorePoolSize . isEmpty ( ) ) { try { int CorePoolSize = Integer . parseInt ( strCorePoolSize ) ; proxyTimerService = new DefaultProxyTimerService ( applicationName , CorePoolSize ) ; } catch ( NumberFormatException ex ) { logger . warn ( "Failed to parse timer service pool size with string value [" + strCorePoolSize + "], use default value." ) ; proxyTimerService = new DefaultProxyTimerService ( applicationName ) ; } } else { proxyTimerService = new DefaultProxyTimerService ( applicationName ) ; } } else { proxyTimerService = new ProxyTimerServiceImpl ( applicationName ) ; } } }
This function is to prepare basic servlet context attributes before the underlying
context is really ready.

The method is designed to be idempotent, so we may call it as many times as
required to actually initiate all possible structures/atts.

@throws LifecycleException