/** * Tries to locate the resource related with the request. * * @param \AppserverIo\Psr\Servlet\ServletContextInterface $servletContext The servlet context that handles the servlets * @param string $servletPath The servlet path to return the servlet for * * @return \AppserverIo\Psr\Servlet\ServletInterface The requested servlet * @see \AppserverIo\Appserver\ServletEngine\ResourceLocator::locate() * @throws \AppserverIo\Appserver\ServletEngine\ServletNotFoundException Is thrown if no servlet can be found for the passed request */ public function locate(ServletContextInterface $servletContext, $servletPath) { // iterate over all servlets and return the matching one foreach ($servletContext->getServletMappings() as $urlPattern => $servletName) { if (fnmatch($urlPattern, $servletPath)) { return $servletContext->getServlet($servletName); } } // throw an exception if no servlet matches the servlet path throw new ServletNotFoundException(sprintf("Can't find servlet for requested path %s", $servletPath)); }
/** * Merges the values of the passed settings into this instance and overwrites the one of this instance. * * @param \AppserverIo\Psr\Servlet\ServletContextInterface $context The context we want to merge the session settings from * * @return void */ public function mergeServletContext(ServletContextInterface $context) { // check if the context has his own session parameters if ($context->hasSessionParameters() === true) { if (($garbageCollectionProbability = $context->getSessionParameter(ServletSessionInterface::GARBAGE_COLLECTION_PROBABILITY)) != null) { $this->setGarbageCollectionProbability((double) $garbageCollectionProbability); } if (($sessionName = $context->getSessionParameter(ServletSessionInterface::SESSION_NAME)) != null) { $this->setSessionName($sessionName); } if (($sessionFilePrefix = $context->getSessionParameter(ServletSessionInterface::SESSION_FILE_PREFIX)) != null) { $this->setSessionFilePrefix($sessionFilePrefix); } if (($sessionSavePath = $context->getSessionParameter(ServletSessionInterface::SESSION_SAVE_PATH)) != null) { $this->setSessionSavePath($sessionSavePath); } if (($sessionMaximumAge = $context->getSessionParameter(ServletSessionInterface::SESSION_MAXIMUM_AGE)) != null) { $this->setSessionMaximumAge((int) $sessionMaximumAge); } if (($sessionInactivityTimeout = $context->getSessionParameter(ServletSessionInterface::SESSION_INACTIVITY_TIMEOUT)) != null) { $this->setInactivityTimeout((int) $sessionInactivityTimeout); } if (($sessionCookieLifetime = $context->getSessionParameter(ServletSessionInterface::SESSION_COOKIE_LIFETIME)) != null) { $this->setSessionCookieLifetime((int) $sessionCookieLifetime); } if (($sessionCookieDomain = $context->getSessionParameter(ServletSessionInterface::SESSION_COOKIE_DOMAIN)) != null) { $this->setSessionCookieDomain($sessionCookieDomain); } if (($sessionCookiePath = $context->getSessionParameter(ServletSessionInterface::SESSION_COOKIE_PATH)) != null) { $this->setSessionCookiePath($sessionCookiePath); } if (($sessionCookieSecure = $context->getSessionParameter(ServletSessionInterface::SESSION_COOKIE_SECURE)) != null) { $this->setSessionCookieSecure((bool) $sessionCookieSecure); } if (($sessionCookieHttpOnly = $context->getSessionParameter(ServletSessionInterface::SESSION_COOKIE_HTTP_ONLY)) != null) { $this->setSessionCookieHttpOnly((bool) $sessionCookieHttpOnly); } } }