-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
static interface
static interface
-
Method Summary
Modifier and TypeMethodDescriptionstatic Page
capturePage
(PageReferrer pageReferrer, CaptureLevel level) Captures a page in the current page context.static Page
capturePage
(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, PageReferrer pageReferrer, CaptureLevel level) Captures a page.static Page
capturePage
(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, PageReferrer pageReferrer, CaptureLevel level, Cache cache) Captures a page.capturePages
(Set<? extends PageReferrer> pageReferrers, CaptureLevel level) Captures multiple pages in the current page context.capturePages
(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, Set<? extends PageReferrer> pageReferrers, CaptureLevel level) Captures multiple pages.static CapturePage
getCaptureContext
(ServletRequest request) Gets the capture context ornull
if none occurring.void
setCapturedPage
(Page capturedPage) static <T> T
traversePagesAnyOrder
(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, Page root, CaptureLevel level, CapturePage.PageHandler<? extends T> pageHandler, CapturePage.TraversalEdges edges, CapturePage.EdgeFilter edgeFilter) Performs potentially concurrent traversal of the pages in any order.static <T> T
traversePagesAnyOrder
(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, PageReferrer rootReferrer, CaptureLevel level, CapturePage.PageHandler<? extends T> pageHandler, CapturePage.TraversalEdges edges, CapturePage.EdgeFilter edgeFilter) static <T> T
traversePagesDepthFirst
(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, Page root, CaptureLevel level, CapturePage.PageDepthHandler<? extends T> preHandler, CapturePage.TraversalEdges edges, CapturePage.EdgeFilter edgeFilter, CapturePage.PageDepthHandler<? extends T> postHandler) Performs a consistent-ordered, potentially concurrent, depth-first traversal of the pages.static <T> T
traversePagesDepthFirst
(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, PageReferrer rootReferrer, CaptureLevel level, CapturePage.PageDepthHandler<? extends T> preHandler, CapturePage.TraversalEdges edges, CapturePage.EdgeFilter edgeFilter, CapturePage.PageDepthHandler<? extends T> postHandler)
-
Method Details
-
getCaptureContext
Gets the capture context ornull
if none occurring. -
capturePage
public static Page capturePage(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, PageReferrer pageReferrer, CaptureLevel level) throws ServletException, IOException Captures a page. The capture is always done with a request method of "GET", even when the enclosing request is a different method. Also validates parent-child and child-parent relationships if the other related pages happened to already be captured and cached.TODO: Within the scope of one request and cache, avoid capturing the same page at the same time (CurrencyLimiter applied to sub requests), is there a reasonable way to catch deadlock conditions?
- Parameters:
level
- The minimum page capture level, note that a higher level might be substituted, such as a META capture in place of a PAGE request.- Throws:
ServletException
IOException
-
capturePage
public static Page capturePage(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, PageReferrer pageReferrer, CaptureLevel level, Cache cache) throws ServletException, IOException Captures a page. The capture is always done with a request method of "GET", even when the enclosing request is a different method. Also validates parent-child and child-parent relationships if the other related pages happened to already be captured and cached.- Parameters:
cache
- SeeCacheFilter.getCache(javax.servlet.ServletRequest)
- Throws:
ServletException
IOException
-
capturePage
public static Page capturePage(PageReferrer pageReferrer, CaptureLevel level) throws ServletException, IOException Captures a page in the current page context. The capture is always done with a request method of "GET", even when the enclosing request is a different method. Also validates parent-child and child-parent relationships if the other related pages happened to already be captured and cached.- Throws:
ServletException
IOException
- See Also:
-
capturePages
public static Map<PageRef,Page> capturePages(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, Set<? extends PageReferrer> pageReferrers, CaptureLevel level) throws ServletException, IOException Captures multiple pages.- Parameters:
pageReferrers
- The pages that should be captured. This set will be iterated only once during this operation.- Returns:
- map from pageRef to page, with iteration order equal to the provided pageRefs parameter.
- Throws:
ServletException
IOException
- See Also:
-
capturePages
public static Map<PageRef,Page> capturePages(Set<? extends PageReferrer> pageReferrers, CaptureLevel level) throws ServletException, IOException Captures multiple pages in the current page context.- Throws:
ServletException
IOException
- See Also:
-
traversePagesAnyOrder
public static <T> T traversePagesAnyOrder(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, PageReferrer rootReferrer, CaptureLevel level, CapturePage.PageHandler<? extends T> pageHandler, CapturePage.TraversalEdges edges, CapturePage.EdgeFilter edgeFilter) throws ServletException, IOException - Throws:
ServletException
IOException
- See Also:
-
traversePagesAnyOrder
public static <T> T traversePagesAnyOrder(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, Page root, CaptureLevel level, CapturePage.PageHandler<? extends T> pageHandler, CapturePage.TraversalEdges edges, CapturePage.EdgeFilter edgeFilter) throws ServletException, IOException Performs potentially concurrent traversal of the pages in any order. Each page is only visited once.
This may at times appear to give results in a predictable order, but this must not be relied upon. For example, with all items already in cache it might end up giving results in a breadth-first order, whereas the same situation on a single-CPU system might end up in a depth-first order. The ordering is not guaranteed in any way and should not be relied upon.
pageHandler, edges, and edgeFilter are all called on the main thread (the thread invoking this method).
Returns when the first pageHandler returns a non-null object. Once a pageHandler returns non-null, no other pageHandler, edges, or edgeFilter will be called.
Due to pageHandlers, edges, and edgeFilter all being called on the main thread, slow implementations of these methods may limit effective concurrency. A future improvement might be to allow for concurrent execution of handlers.
If a page is already in the cache, it is fetched directly instead of passed-off to a separate thread for capture. Thus, if all is cached, this method will not perform with any concurrency.
- Parameters:
level
- The captureLevel. A higher captureLevel may be returned when it is available, such as a META capture in place of a PAGE request.pageHandler
- Optional, null when not needed, called before a page visits it's edges. If returns a non-null object, the traversal is terminated and the provided object is returned.edges
- Provides the set of pages to looked from the given page. Any edge provided that has already been visited will not be visited again.edgeFilter
- Optional, null when not needed and will match all edges.- Throws:
ServletException
IOException
-
traversePagesDepthFirst
public static <T> T traversePagesDepthFirst(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, PageReferrer rootReferrer, CaptureLevel level, CapturePage.PageDepthHandler<? extends T> preHandler, CapturePage.TraversalEdges edges, CapturePage.EdgeFilter edgeFilter, CapturePage.PageDepthHandler<? extends T> postHandler) throws ServletException, IOException - Throws:
ServletException
IOException
- See Also:
-
traversePagesDepthFirst
public static <T> T traversePagesDepthFirst(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, Page root, CaptureLevel level, CapturePage.PageDepthHandler<? extends T> preHandler, CapturePage.TraversalEdges edges, CapturePage.EdgeFilter edgeFilter, CapturePage.PageDepthHandler<? extends T> postHandler) throws ServletException, IOException Performs a consistent-ordered, potentially concurrent, depth-first traversal of the pages. Each page is only visited once.
preHandler, edges, edgeFilter, and postHandler are all called on the main thread (the thread invoking this method).
Returns when the first preHandler or postHandler returns a non-null object. Once a preHandler or postHandler returns non-null, no other preHandler, edges, edgeFilter, or postHandler will be called.
Due to preHandlers, edges, edgeFilter, and postHandler all being called on the main thread, slow implementations of these methods may limit effective concurrency. A future improvement might be to allow for concurrent execution of handlers.
If a page is already in the cache, it is fetched directly instead of passed-off to a separate thread for capture. Thus, if all is cached, this method will not perform with any concurrency.
- Parameters:
level
- The captureLevel. A higher captureLevel may be returned when it is available, such as a META capture in place of a PAGE request.preHandler
- Optional, null when not needed, called before a page visits it's edges. If returns a non-null object, the traversal is terminated and the provided object is returned.edges
- Provides the set of pages to looked from the given page. Any edge provided that has already been visited will not be visited again.edgeFilter
- Optional, null when not needed and will match all edges.postHandler
- Optional, null when not needed, called before a page visits it's edges. If returns a non-null object, the traversal is terminated and the provided object is returned.- Throws:
ServletException
IOException
-
setCapturedPage
-