/** * This method wrapps the HTTP-Request and Response and executes the netlets * of a running web application or throws an error if the request does not * fit to any application. */ public function process(\blaze\netlet\http\HttpNetletRequest $request, \blaze\netlet\http\HttpNetletResponse $response) { try { $cacheProvider = new \blaze\cache\LocalCacheProvider(); $cache = $cacheProvider->buildCache(null); $cacheMgr = \blaze\cache\CacheManager::getInstance('blazeContainer', $cache); $appName = NetletApplication::getApplicationName($request); $app = null; if ($appName == null) { $response->sendError(\blaze\netlet\http\HttpNetletResponse::SC_NOT_FOUND, 'There was no application for the request found.'); return; } $app = $cacheMgr->get($appName); if ($app == null) { $app = NetletApplication::getApplicationByName($appName); //$cacheMgr->put($appName, $app); } if ($app == null) { $response->sendError(\blaze\netlet\http\HttpNetletResponse::SC_NOT_FOUND, 'There was no application for the request found.'); return; } $context = $app->getNetletContext(); $chain = new FilterChainImpl($context, $this->getRequestedFilters($request, $context)); // The netlet gets called after the last filter passed the chain. $chain->doFilter($request, $response); if (!$response->isCommited()) { $sess = $request->getSession(); if ($sess != null) { $cookie = null; $sessHand = $request->getSessionHandler(); if (!$sess->isValid()) { $cookie = new http\HttpCookieImpl('BLAZESESSION', ''); $cookie->setExpire(0); $sessHand->removeSession(); } else { $sessHand->saveSession(); $cookie = new http\HttpCookieImpl('BLAZESESSION', $sess->getId()); $cookie->setHttponly(true); $cookie->setPath($app->getUrlPrefix()); //$cookie->setDomain($request->getServerName()); } if ($cookie != null) { $response->addCookie($cookie); } } } } catch (Exception $e) { // Error in the netlet which was not caught $response->sendError(\blaze\netlet\http\HttpNetletResponse::SC_NOT_FOUND); } }