private SocketResponseChannel newSocketResponseChannel(Socket socket, HttpRequestBuffer request) { Encoding rspEncoding = this.selectResponseEncoding(request); ResponseCoordinator rc; synchronized (socketResponseCoordinators) { rc = socketResponseCoordinators.get(socket); if (rc == null) { socketResponseCoordinators.put(socket, rc = this.newResponseCoordinator(socket)); } } return new SocketResponseChannel(rc, request, rspEncoding); }
private RequestHandler registerHandler( String uriPath, String method, RequestHandler handler, MethodCallUnmarshallerAid aid) { // I anticipate a common mistake when using the ProxyingRequestHandler // will be to forget to pass it in as the aid, so let's // cater for that. if (aid == null && handler instanceof MethodCallUnmarshallerAid) { aid = (MethodCallUnmarshallerAid) handler; } synchronized (this.uriHandlers) { if (uriPath != null) { uriPath = Utils.normalizeURIPath(uriPath); } Map patternMap = (Map) this.uriHandlers.get(uriPath); if (patternMap == null) { patternMap = new LinkedHashMap(); this.uriHandlers.put(uriPath, patternMap); } Pattern pattern = (Pattern) this.globalPatternMap.get(method); if (pattern == null) { pattern = Pattern.compile(method); this.globalPatternMap.put(method, pattern); } RequestHandler prevHandler = (RequestHandler) patternMap.put(method, handler); synchronized (this.handlerUnmarshallerAids) { if (prevHandler != null) { this.handlerUnmarshallerAids.remove(prevHandler); } if (aid != null) { this.handlerUnmarshallerAids.put(handler, aid); } } return prevHandler; } }