@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); } };
public ManagedFilter addFilter(final FilterInfo filterInfo) { ManagedFilter managedFilter = new ManagedFilter(filterInfo, deployment.getServletContext()); managedFilterMap.put(filterInfo.getName(),managedFilter); deployment.addLifecycleObjects(managedFilter); servletPathMatches.invalidate(); return managedFilter; }
MatchData targetServletMatch = resolveServletForPath(path, pathServlets, extensionServlets, defaultServlet); if (targetServletMatch.handler != null) { if (filterMapping.getMapping().equals(targetServletMatch.handler.getManagedServlet().getServletInfo().getName()) || filterMapping.getMapping().equals("*")) { addToListMap(noExtension, filterMapping.getDispatcher(), filter); addToListMap(extension.get(entry.getKey()), filterMapping.getDispatcher(), filter); if (isFilterApplicable(path, filterMapping.getMapping())) { addToListMap(noExtension, filterMapping.getDispatcher(), filter); for (Map<DispatcherType, List<ManagedFilter>> l : extension.values()) { addToListMap(l, filterMapping.getDispatcher(), filter); addToListMap(extension.get(filterMapping.getMapping().substring(2)), filterMapping.getDispatcher(), filter); builder.addPrefixMatch(prefix, createHandler(deploymentInfo, targetServletMatch.handler, noExtension, targetServletMatch.matchedPath, targetServletMatch.defaultServlet, targetServletMatch.mappingMatch, targetServletMatch.userPath), targetServletMatch.defaultServlet || targetServletMatch.handler.getManagedServlet().getServletInfo().isRequireWelcomeFileMapping()); builder.addExtensionMatch(prefix, entry.getKey(), servletChain(handler, pathServlet.getManagedServlet(), entry.getValue(), pathMatch, deploymentInfo, defaultServletMatch, defaultServletMatch ? MappingMatch.DEFAULT : MappingMatch.EXTENSION, defaultServletMatch ? "/" : "*." + entry.getKey())); builder.addExactMatch("/", createHandler(deploymentInfo, targetServletMatch.handler, noExtension, targetServletMatch.matchedPath, targetServletMatch.defaultServlet, targetServletMatch.mappingMatch, targetServletMatch.userPath)); } else { if (extension.containsKey(ext)) { Map<DispatcherType, List<ManagedFilter>> extMap = extension.get(ext); builder.addExactMatch(path, createHandler(deploymentInfo, targetServletMatch.handler, extMap, targetServletMatch.matchedPath, targetServletMatch.defaultServlet, targetServletMatch.mappingMatch, targetServletMatch.userPath)); } else { builder.addExactMatch(path, createHandler(deploymentInfo, targetServletMatch.handler, noExtension, targetServletMatch.matchedPath, targetServletMatch.defaultServlet, targetServletMatch.mappingMatch, targetServletMatch.userPath)); builder.addExactMatch(path, createHandler(deploymentInfo, targetServletMatch.handler, noExtension, targetServletMatch.matchedPath, targetServletMatch.defaultServlet, targetServletMatch.mappingMatch, targetServletMatch.userPath));
deployment.getServletPaths().setWelcomePages(deploymentInfo.getWelcomePages()); deployment.getServletPaths().invalidate(); //make sure we have a fresh set of servlet paths ((ConvergedServletContextImpl) servletContext).initDone(); } catch (Exception e) {
deployment.setThreadSetupActions(setup); deployment.getServletPaths().setWelcomePages(deploymentInfo.getWelcomePages()); deployment.getServletPaths().initData(); for(ServletContextListener listener : deploymentInfo.getDeploymentCompleteListeners()) { listener.contextInitialized(new ServletContextEvent(servletContext));
public DeploymentImpl(DeploymentManager deploymentManager, final DeploymentInfo deploymentInfo, ServletContainer servletContainer) { this.deploymentManager = deploymentManager; this.deploymentInfo = deploymentInfo; this.servletContainer = servletContainer; servletPaths = new ServletPathMatches(this); servlets = new ManagedServlets(this, servletPaths); filters = new ManagedFilters(this, servletPaths); }
@Override public Set<String> tryAddServletMappings(ServletInfo servletInfo, String... urlPatterns) { final Set<String> ret = new HashSet<>(); if(existingUrlPatterns == null) { existingUrlPatterns = new HashSet<>(); for (ServletInfo s : deploymentInfo.getServlets().values()) { if (!s.getName().equals(servletInfo.getName())) { existingUrlPatterns.addAll(s.getMappings()); } } } for (String pattern : urlPatterns) { if (existingUrlPatterns.contains(pattern)) { ret.add(pattern); } } //only update if no changes have been made if (ret.isEmpty()) { for (String pattern : urlPatterns) { existingUrlPatterns.add(pattern); if (!servletInfo.getMappings().contains(pattern)) { servletInfo.addMapping(pattern); } } } getServletPaths().invalidate(); return ret; }
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 ServletHandler addServlet(final ServletInfo servletInfo) { SipServletImpl managedServlet = new SipServletImpl(servletInfo, ((ConvergedDeploymentImpl) deployment).getConvergedServletContext()); ServletHandler servletHandler = new ServletHandler(managedServlet); managedServletMap.put(servletInfo.getName(), servletHandler); deployment.addLifecycleObjects(managedServlet); this.servletPaths.invalidate(); return servletHandler; }
@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); } };
public ServletHandler addServlet(final ServletInfo servletInfo) { ManagedServlet managedServlet = new ManagedServlet(servletInfo, deployment.getServletContext()); ServletHandler servletHandler = new ServletHandler(managedServlet); managedServletMap.put(servletInfo.getName(), servletHandler); deployment.addLifecycleObjects(managedServlet); this.servletPaths.invalidate(); return servletHandler; }
@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 ServletHandler addServlet(final ServletInfo servletInfo) { SipServletImpl managedServlet = new SipServletImpl(servletInfo, ((ConvergedDeploymentImpl) deployment).getConvergedServletContext()); ServletHandler servletHandler = new ServletHandler(managedServlet); managedServletMap.put(servletInfo.getName(), servletHandler); deployment.addLifecycleObjects(managedServlet); this.servletPaths.invalidate(); return servletHandler; }
final ServletPathMatch info = paths.getServletHandlerByPath(request.getServletPath()); final HttpServletResponseImpl oResponse = new HttpServletResponseImpl(exchange, convergedServletContext.getDelegatedContext()); final HttpServletRequestImpl oRequest = new HttpServletRequestImpl(exchange, convergedServletContext.getDelegatedContext());
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(); }
final ServletPathMatch info = paths.getServletHandlerByPath(request.getServletPath()); final HttpServletResponseImpl oResponse = new HttpServletResponseImpl(exchange, convergedServletContext.getDelegatedContext()); final HttpServletRequestImpl oRequest = new HttpServletRequestImpl(exchange, convergedServletContext.getDelegatedContext());
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);
deployment.getServletPaths().invalidate(); //make sure we have a fresh set of servlet paths ((ConvergedServletContextImpl) servletContext).initDone(); } catch (Exception e) {
final ServletPathMatch info = paths.getServletHandlerByPath(request.getServletPath()); final HttpServletResponseImpl oResponse = new HttpServletResponseImpl(exchange, servletContext); final HttpServletRequestImpl oRequest = new HttpServletRequestImpl(exchange, servletContext);