Java Code Examples for org.eclipse.jetty.servlet.ServletContextHandler#Context
The following examples show how to use
org.eclipse.jetty.servlet.ServletContextHandler#Context .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HttpServer2.java From hadoop-ozone with Apache License 2.0 | 5 votes |
/** * Infer the mime type for the response based on the extension of the * request * URI. Returns null if unknown. */ private String inferMimeType(ServletRequest request) { String path = ((HttpServletRequest) request).getRequestURI(); ServletContextHandler.Context sContext = (ServletContextHandler.Context) config.getServletContext(); String mime = sContext.getMimeType(path); return (mime == null) ? null : mime; }
Example 2
Source File: AssetServlet.java From onedev with MIT License | 5 votes |
@Override public final Resource getResource(String pathInContext) { ServletContextHandler.Context context = (ServletContextHandler.Context) getServletContext(); ServletContextHandler contextHandler = (ServletContextHandler) context.getContextHandler(); for (ServletMapping mapping: contextHandler.getServletHandler().getServletMappings()) { if (mapping.getServletName().equals(getServletName())) { for (String pathSpec: mapping.getPathSpecs()) { String relativePath = null; if (pathSpec.endsWith("/*")) { pathSpec = StringUtils.substringBeforeLast(pathSpec, "/*"); if (pathInContext.startsWith(pathSpec + "/")) relativePath = pathInContext.substring(pathSpec.length()); } else if (pathSpec.startsWith("*.")) { pathSpec = StringUtils.stripStart(pathSpec, "*"); if (pathInContext.endsWith(pathSpec)) relativePath = pathInContext; } else if (pathSpec.equals(pathInContext)) { relativePath = pathInContext; } if (relativePath != null) { relativePath = StringUtils.stripStart(relativePath, "/"); Resource resource = Resource.newResource(loadResource(relativePath)); if (resource != null && resource.exists()) return resource; } } } } return null; }
Example 3
Source File: JettyPlusIT.java From uavstack with Apache License 2.0 | 5 votes |
/** * onWrapServletContext Jetty的场景下需要采用一些Wrapper来替代Proxy,因为不全是接口 * * @param args */ public ContextHandler.Context onWrapServletContext(Object... args) { ServletContextHandler.Context oContext = (ServletContextHandler.Context) args[0]; ServletContextHandlerWrapper.JettyContextWrapper ctx = new ServletContextHandlerWrapper().new JettyContextWrapper( oContext); return ctx; }
Example 4
Source File: HttpServer2.java From lucene-solr with Apache License 2.0 | 5 votes |
/** * Infer the mime type for the response based on the extension of the request * URI. Returns null if unknown. */ private String inferMimeType(ServletRequest request) { String path = ((HttpServletRequest)request).getRequestURI(); ServletContextHandler.Context sContext = (ServletContextHandler.Context)config.getServletContext(); String mime = sContext.getMimeType(path); return (mime == null) ? null : mime; }
Example 5
Source File: HttpServer2.java From knox with Apache License 2.0 | 5 votes |
/** * Infer the mime type for the response based on the extension of the request * URI. Returns null if unknown. */ private String inferMimeType(ServletRequest request) { String path = ((HttpServletRequest)request).getRequestURI(); ServletContextHandler.Context sContext = (ServletContextHandler.Context)config.getServletContext(); String mime = sContext.getMimeType(path); return (mime == null) ? null : mime; }
Example 6
Source File: HttpServer2.java From knox with Apache License 2.0 | 5 votes |
/** * Infer the mime type for the response based on the extension of the request * URI. Returns null if unknown. */ private String inferMimeType(ServletRequest request) { String path = ((HttpServletRequest)request).getRequestURI(); ServletContextHandler.Context sContext = (ServletContextHandler.Context)config.getServletContext(); String mime = sContext.getMimeType(path); return (mime == null) ? null : mime; }
Example 7
Source File: ServletContextHandlerWrapper.java From uavstack with Apache License 2.0 | 2 votes |
public JettyContextWrapper(ServletContextHandler.Context context) { proc = new DynamicServletContextProcessor(); this.context = context; }