@Override public void handleRequest(HttpServerExchange exchange) throws Exception { String old = exchange.getAttachment(OLD_RELATIVE_PATH); if(!old.equals(exchange.getRelativePath())) { ServletRequestContext src = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); ServletPathMatch info = src.getDeployment().getServletPaths().getServletHandlerByPath(exchange.getRelativePath()); src.setCurrentServlet(info.getServletChain()); src.setServletPathMatch(info); } handler.handleRequest(exchange); } };
@Override public RequestDispatcher getNamedDispatcher(final String name) { ServletChain chain = deployment.getServletPaths().getServletHandlerByName(name); if (chain != null) { return new RequestDispatcherImpl(chain, this); } else { return null; } }
public RequestDispatcherImpl(final String path, final ServletContextImpl servletContext) { this.path = path; this.servletContext = servletContext; String basePath = path; int qPos = basePath.indexOf("?"); if (qPos != -1) { basePath = basePath.substring(0, qPos); } int mPos = basePath.indexOf(";"); if(mPos != -1) { basePath = basePath.substring(0, mPos); } this.pathMatch = servletContext.getDeployment().getServletPaths().getServletHandlerByPath(basePath); this.chain = pathMatch.getServletChain(); this.named = false; }
@Override public Servlet getServlet(final String name) throws ServletException { return deployment.getServletPaths().getServletHandlerByName(name).getManagedServlet().getServlet().getInstance(); }
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { String old = exchange.getAttachment(OLD_RELATIVE_PATH); if(!old.equals(exchange.getRelativePath())) { ServletRequestContext src = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); ServletPathMatch info = src.getDeployment().getServletPaths().getServletHandlerByPath(exchange.getRelativePath()); src.setCurrentServlet(info.getServletChain()); src.setServletPathMatch(info); } handler.handleRequest(exchange); } };
void addMappingForUrlPatterns(FilterInfo filterInfo, final EnumSet<DispatcherType> dispatcherTypes, final boolean isMatchAfter, final String... urlPatterns) { DeploymentInfo deploymentInfo = deployment.getDeploymentInfo(); for (final String url : urlPatterns) { if (isMatchAfter) { if (dispatcherTypes == null || dispatcherTypes.isEmpty()) { deploymentInfo.addFilterUrlMapping(filterInfo.getName(), url, DispatcherType.REQUEST); } else { for (final DispatcherType dispatcher : dispatcherTypes) { deploymentInfo.addFilterUrlMapping(filterInfo.getName(), url, dispatcher); } } } else { if (dispatcherTypes == null || dispatcherTypes.isEmpty()) { deploymentInfo.insertFilterUrlMapping(filterMappingUrlPatternInsertPosition++, filterInfo.getName(), url, DispatcherType.REQUEST); } else { for (final DispatcherType dispatcher : dispatcherTypes) { deploymentInfo.insertFilterUrlMapping(filterMappingUrlPatternInsertPosition++, filterInfo.getName(), url, dispatcher); } } } } deployment.getServletPaths().invalidate(); }
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { String old = exchange.getAttachment(OLD_RELATIVE_PATH); if(!old.equals(exchange.getRelativePath())) { ServletRequestContext src = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); ServletPathMatch info = src.getDeployment().getServletPaths().getServletHandlerByPath(exchange.getRelativePath()); src.setCurrentServlet(info.getServletChain()); src.setServletPathMatch(info); } handler.handleRequest(exchange); } };
void addMappingForServletNames(FilterInfo filterInfo, final EnumSet<DispatcherType> dispatcherTypes, final boolean isMatchAfter, final String... servletNames) { DeploymentInfo deploymentInfo = deployment.getDeploymentInfo(); for (final String servlet : servletNames) { if (isMatchAfter) { if (dispatcherTypes == null || dispatcherTypes.isEmpty()) { deploymentInfo.addFilterServletNameMapping(filterInfo.getName(), servlet, DispatcherType.REQUEST); } else { for (final DispatcherType dispatcher : dispatcherTypes) { deploymentInfo.addFilterServletNameMapping(filterInfo.getName(), servlet, dispatcher); } } } else { if (dispatcherTypes == null || dispatcherTypes.isEmpty()) { deploymentInfo.insertFilterServletNameMapping(filterMappingServletNameInsertPosition++, filterInfo.getName(), servlet, DispatcherType.REQUEST); } else { for (final DispatcherType dispatcher : dispatcherTypes) { deploymentInfo.insertFilterServletNameMapping(filterMappingServletNameInsertPosition++, filterInfo.getName(), servlet, dispatcher); } } } } deployment.getServletPaths().invalidate(); }
ServletPathMatch info = deployment.getServletPaths().getServletHandlerByPath(newServletPath); requestImpl.getExchange().getAttachment(ServletRequestContext.ATTACHMENT_KEY).setServletPathMatch(info);