public function run()
    {

        try {
            // register the default autoloader
            require SERVER_AUTOLOADER;

            // register shutdown handler
            set_error_handler(array(&$this, 'errorHandler'));
            register_shutdown_function(array(&$this, 'shutdown'));

            // initialize the array for the errors
            $this->errors = array();

            // synchronize the application instance and register the class loaders
            $application = $this->application;
            $application->registerClassLoaders();

            // register the applications annotation registries
            $application->registerAnnotationRegistries();

            // synchronize the valves, servlet request/response
            $valves = $this->valves;
            $servletRequest = $this->servletRequest;
            $servletResponse = $this->servletResponse;

            // load the session and the authentication manager
            $sessionManager = $application->search(SessionManagerInterface::IDENTIFIER);
            $authenticationManager = $application->search(AuthenticationManagerInterface::IDENTIFIER);

            // inject the sapplication and servlet response
            $servletRequest->injectContext($application);
            $servletRequest->injectResponse($servletResponse);
            $servletRequest->injectSessionManager($sessionManager);
            $servletRequest->injectAuthenticationManager($authenticationManager);

            // prepare the request instance
            $servletRequest->prepare();

            // initialize static request and application context
            RequestHandler::$requestContext = $servletRequest;
            RequestHandler::$applicationContext = $application;

            // add the application instance to the environment
            Environment::singleton()->setAttribute(EnvironmentKeys::APPLICATION, $application);

            // create a simulated request/session ID whereas session equals request ID (as long as session has NOT been started)
            Environment::singleton()->setAttribute(EnvironmentKeys::REQUEST_ID, $requestId = SessionUtils::generateRandomString());
            Environment::singleton()->setAttribute(EnvironmentKeys::SESSION_ID, $requestId);

            // process the valves
            foreach ($valves as $valve) {
                $valve->invoke($servletRequest, $servletResponse);
                if ($servletRequest->isDispatched() === true) {
                    break;
                }
            }

            // flush the session manager
            $sessionManager->flush();

            // profile the request if the profile logger is available
            if ($profileLogger = $application->getInitialContext()->getLogger(LoggerUtils::PROFILE)) {
                $profileLogger->appendThreadContext('request-handler');
                $profileLogger->debug($servletRequest->getUri());
            }

        } catch (\Exception $e) {
            $this->addError(ErrorUtil::singleton()->fromException($e));
        }

        // re-attach request and response instances
        $this->servletRequest = $servletRequest;
        $this->servletResponse = $servletResponse;
    }
public function run()
    {

        try {
            // register the default autoloader
            require SERVER_AUTOLOADER;

            // register shutdown handler
            set_error_handler(array(&$this, 'errorHandler'));
            register_shutdown_function(array(&$this, 'shutdown'));

            // initialize the array for the errors
            $this->errors = array();

            // synchronize the application instance and register the class loaders
            $application = $this->application;
            $application->registerClassLoaders();

            // register the applications annotation registries
            $application->registerAnnotationRegistries();

            // synchronize the valves, servlet request/response
            $valves = $this->valves;
            $servletRequest = $this->servletRequest;
            $servletResponse = $this->servletResponse;

            // load the session and the authentication manager
            $sessionManager = $application->search(SessionManagerInterface::IDENTIFIER);
            $authenticationManager = $application->search(AuthenticationManagerInterface::IDENTIFIER);

            // inject the sapplication and servlet response
            $servletRequest->injectContext($application);
            $servletRequest->injectResponse($servletResponse);
            $servletRequest->injectSessionManager($sessionManager);
            $servletRequest->injectAuthenticationManager($authenticationManager);

            // prepare the request instance
            $servletRequest->prepare();

            // initialize static request and application context
            RequestHandler::$requestContext = $servletRequest;
            RequestHandler::$applicationContext = $application;

            // add the application instance to the environment
            Environment::singleton()->setAttribute(EnvironmentKeys::APPLICATION, $application);

            // create a simulated request/session ID whereas session equals request ID (as long as session has NOT been started)
            Environment::singleton()->setAttribute(EnvironmentKeys::REQUEST_ID, $requestId = SessionUtils::generateRandomString());
            Environment::singleton()->setAttribute(EnvironmentKeys::SESSION_ID, $requestId);

            // process the valves
            foreach ($valves as $valve) {
                $valve->invoke($servletRequest, $servletResponse);
                if ($servletRequest->isDispatched() === true) {
                    break;
                }
            }

            // flush the session manager
            $sessionManager->flush();

            // profile the request if the profile logger is available
            if ($profileLogger = $application->getInitialContext()->getLogger(LoggerUtils::PROFILE)) {
                $profileLogger->appendThreadContext('request-handler');
                $profileLogger->debug($servletRequest->getUri());
            }

        } catch (\Exception $e) {
            $this->addError(ErrorUtil::singleton()->fromException($e));
        }

        // re-attach request and response instances
        $this->servletRequest = $servletRequest;
        $this->servletResponse = $servletResponse;
    }
public function run ( ) { try { // register the default autoloader require SERVER_AUTOLOADER ; // register shutdown handler set_error_handler ( array ( & $ this , 'errorHandler' ) ) ; register_shutdown_function ( array ( & $ this , 'shutdown' ) ) ; // initialize the array for the errors $ this -> errors = array ( ) ; // synchronize the application instance and register the class loaders $ application = $ this -> application ; $ application -> registerClassLoaders ( ) ; // register the applications annotation registries $ application -> registerAnnotationRegistries ( ) ; // synchronize the valves, servlet request/response $ valves = $ this -> valves ; $ servletRequest = $ this -> servletRequest ; $ servletResponse = $ this -> servletResponse ; // load the session and the authentication manager $ sessionManager = $ application -> search ( SessionManagerInterface :: IDENTIFIER ) ; $ authenticationManager = $ application -> search ( AuthenticationManagerInterface :: IDENTIFIER ) ; // inject the sapplication and servlet response $ servletRequest -> injectContext ( $ application ) ; $ servletRequest -> injectResponse ( $ servletResponse ) ; $ servletRequest -> injectSessionManager ( $ sessionManager ) ; $ servletRequest -> injectAuthenticationManager ( $ authenticationManager ) ; // prepare the request instance $ servletRequest -> prepare ( ) ; // initialize static request and application context RequestHandler :: $ requestContext = $ servletRequest ; RequestHandler :: $ applicationContext = $ application ; // add the application instance to the environment Environment :: singleton ( ) -> setAttribute ( EnvironmentKeys :: APPLICATION , $ application ) ; // create a simulated request/session ID whereas session equals request ID (as long as session has NOT been started) Environment :: singleton ( ) -> setAttribute ( EnvironmentKeys :: REQUEST_ID , $ requestId = SessionUtils :: generateRandomString ( ) ) ; Environment :: singleton ( ) -> setAttribute ( EnvironmentKeys :: SESSION_ID , $ requestId ) ; // process the valves foreach ( $ valves as $ valve ) { $ valve -> invoke ( $ servletRequest , $ servletResponse ) ; if ( $ servletRequest -> isDispatched ( ) === true ) { break ; } } // flush the session manager $ sessionManager -> flush ( ) ; // profile the request if the profile logger is available if ( $ profileLogger = $ application -> getInitialContext ( ) -> getLogger ( LoggerUtils :: PROFILE ) ) { $ profileLogger -> appendThreadContext ( 'request-handler' ) ; $ profileLogger -> debug ( $ servletRequest -> getUri ( ) ) ; } } catch ( \ Exception $ e ) { $ this -> addError ( ErrorUtil :: singleton ( ) -> fromException ( $ e ) ) ; } // re-attach request and response instances $ this -> servletRequest = $ servletRequest ; $ this -> servletResponse = $ servletResponse ; }
The main method that handles the thread in a separate context.

@return void
The main method that handles the thread in a separate context .