/* (non-Javadoc) * @see naru.queuelet.Queuelet#service(java.lang.Object) */ public boolean service(Object req) { HttpContext httpContext = null; if (req instanceof Socket) { Socket socket = (Socket) req; // 指定IPからのリクエストかどうかをチェック if (checkIp(socket) == false) { return false; } httpContext = (HttpContext) context.deque(Config.QUEUE_HTTPCONTEXT_POOL); httpContext.setSocket(socket); } else { // KeepAliveを実装する時はこちら httpContext = (HttpContext) req; } // 処理の起点がaccessLogの中に採られる AccessLog accessLog = (AccessLog) context.deque(Config.QUEUE_ACCESSLOG_POOL); httpContext.setupAccessLog(accessLog); boolean parseHeader = false; try { parseHeader = httpContext.parseRequestHeader(); } catch (IOException e) { // 不当リクエスト logger.error("fail to parse Request.", e); } catch (Throwable t) { // java.nio.channels.ClosedSelectorExceptionが発生したりする logger.error("fail to parse Request.!!", t); } if (!parseHeader) { context.enque(httpContext, Config.QUEUE_CLOSE); return false; } MappingEntry entry = mappingQueue(httpContext); if (entry == null) { logger.warn("fail to mapping.URL:" + httpContext.getRequestUri()); responseDirect(httpContext, "404", "failt to mapping." + httpContext.getRequestUri()); return false; } String queue = entry.getQueue(); // 一連streamの初期化 try { setupTraceLog(httpContext, queue, accessLog); } catch (IOException e) { // streamの初期化に失敗、レスポンスもできない logger.error("fail to setupAccessTrace", e); responseDirect(httpContext, "404", "failt to accesslog." + httpContext.getRequestUri()); return false; } // 以降普通にレスポンスできる // response予約 context.enque(httpContext, Config.QUEUE_RESPONSE); entry = authentication(httpContext, entry); if (entry == null) { return false; } accessLog.setMappingSource(entry.getSourcePath()); accessLog.setMappingDestination(entry.getDestination()); // response作成依頼(認証時にqueueが変更されている可能性がある) context.enque(httpContext, entry.getQueue()); return true; }