@Override public void loadObjects(ObjectRegistry<Indexed> registry) throws Throwable { // Obtain the HTTP request this.connection = (ServerHttpConnection) registry.getObject(this.serverHttpConnectionIndex); HttpRequest request = this.connection.getRequest(); // Ensure have the HTTP session Id generator if (this.httpSessionIdGenerator == null) { this.httpSessionIdGenerator = (HttpSessionIdGenerator) registry.getObject(this.httpSessionIdGeneratorIndex); } // Ensure have the HTTP session store if (this.httpSessionStore == null) { this.httpSessionStore = (HttpSessionStore) registry.getObject(this.httpSessionStoreIndex); } // Obtain the Session Id from the Session cookie HttpRequestCookie sessionIdCookie = request.getCookies().getCookie(this.sessionIdCookieName); String sessionId = (sessionIdCookie == null ? null : sessionIdCookie.getValue()); // Handle based on Session Id being available if ((sessionId == null) || (sessionId.trim().length() == 0)) { // No established session so create a new session this.generateSessionId(); } else { // Retrieve the existing session this.loadSessionId(sessionId, false); } }
@Override public Object execute(ManagedFunctionContext<HttpRouteDependencies, Indexed> context) { // Obtain the server HTTP connection ServerHttpConnection connection = (ServerHttpConnection) context .getObject(HttpRouteDependencies.SERVER_HTTP_CONNECTION); // Load the escalation handler if (this.escalationHandler != null) { connection.getResponse().setEscalationHandler(this.escalationHandler); } // Determine if potentially redirect HttpRequestCookie cookie = connection.getRequest().getCookies() .getCookie(HttpRedirectFunction.REDIRECT_COOKIE_NAME); if (cookie != null) { // Redirect, so trigger flow to import previous state context.doFlow(this.handleRedirectFlowIndex, cookie, null); return null; // serviced by redirect } // No redirect, so route the request return this.router.route(connection, context); }