Package spark.resource
Class AbstractResourceHandler
- java.lang.Object
-
- spark.resource.AbstractResourceHandler
-
- Direct Known Subclasses:
ClassPathResourceHandler
,ExternalResourceHandler
public abstract class AbstractResourceHandler extends java.lang.Object
Abstract class providing functionality for finding resources based on an Http Servlet request. Code snippets copied from Eclipse Jetty source. Modifications made by Per Wendel.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String
SLASH
-
Constructor Summary
Constructors Constructor Description AbstractResourceHandler()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static java.lang.String
addPaths(java.lang.String segment1, java.lang.String segment2)
Add two URI path segments.protected abstract AbstractFileResolvingResource
getResource(java.lang.String path)
Gets resource from pathAbstractFileResolvingResource
getResource(javax.servlet.http.HttpServletRequest request)
Gets a resource from a servlet request
-
-
-
Field Detail
-
SLASH
protected static final java.lang.String SLASH
- See Also:
- Constant Field Values
-
-
Method Detail
-
getResource
public AbstractFileResolvingResource getResource(javax.servlet.http.HttpServletRequest request) throws java.net.MalformedURLException
Gets a resource from a servlet request- Parameters:
request
- the servlet request- Returns:
- the resource or null if not found
- Throws:
java.net.MalformedURLException
- thrown when malformed URL.
-
getResource
protected abstract AbstractFileResolvingResource getResource(java.lang.String path) throws java.net.MalformedURLException
Gets resource from path- Parameters:
path
- the path- Returns:
- the resource or null if resource doesn't exist
- Throws:
java.net.MalformedURLException
- thrown when malformed URL.
-
addPaths
public static java.lang.String addPaths(java.lang.String segment1, java.lang.String segment2)
Add two URI path segments. Handles null and empty paths, path and query params (eg ?a=b or ;JSESSIONID=xxx) and avoids duplicate '/'- Parameters:
segment1
- URI path segment (should be encoded)segment2
- URI path segment (should be encoded)- Returns:
- Legally combined path segments.
-
-