Module methanol

Class CacheInterceptor

  • All Implemented Interfaces:
    Methanol.Interceptor

    public final class CacheInterceptor
    extends java.lang.Object
    implements Methanol.Interceptor
    An Methanol.Interceptor that serves incoming requests from cache, network, both (in case of successful/failed revalidation), or none (in case of unsatisfiable requests). The interceptor also updates, populates and invalidates cache entries as necessary.
    • Constructor Summary

      Constructors 
      Constructor Description
      CacheInterceptor​(LocalCache.Factory cacheFactory, HttpCache.Listener listener, java.util.concurrent.Executor handlerExecutor, java.time.Clock clock, boolean synchronizeWrites, java.util.function.Predicate<java.lang.String> implicitHeaderPredicate)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean canReplaceStoredHeader​(java.lang.String name)  
      <T> java.net.http.HttpResponse<T> intercept​(java.net.http.HttpRequest request, Methanol.Interceptor.Chain<T> chain)
      Intercepts given request and returns the resulting response, usually by forwarding to the given chain.
      <T> java.util.concurrent.CompletableFuture<java.net.http.HttpResponse<T>> interceptAsync​(java.net.http.HttpRequest request, Methanol.Interceptor.Chain<T> chain)
      Intercepts the given request and returns a CompletableFuture for the resulting response, usually by forwarding to the given chain.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CacheInterceptor

        public CacheInterceptor​(LocalCache.Factory cacheFactory,
                                HttpCache.Listener listener,
                                java.util.concurrent.Executor handlerExecutor,
                                java.time.Clock clock,
                                boolean synchronizeWrites,
                                java.util.function.Predicate<java.lang.String> implicitHeaderPredicate)
    • Method Detail

      • intercept

        public <T> java.net.http.HttpResponse<T> intercept​(java.net.http.HttpRequest request,
                                                           Methanol.Interceptor.Chain<T> chain)
                                                    throws java.io.IOException,
                                                           java.lang.InterruptedException
        Description copied from interface: Methanol.Interceptor
        Intercepts given request and returns the resulting response, usually by forwarding to the given chain.
        Specified by:
        intercept in interface Methanol.Interceptor
        Throws:
        java.io.IOException
        java.lang.InterruptedException
      • interceptAsync

        public <T> java.util.concurrent.CompletableFuture<java.net.http.HttpResponse<T>> interceptAsync​(java.net.http.HttpRequest request,
                                                                                                        Methanol.Interceptor.Chain<T> chain)
        Description copied from interface: Methanol.Interceptor
        Intercepts the given request and returns a CompletableFuture for the resulting response, usually by forwarding to the given chain.
        Specified by:
        interceptAsync in interface Methanol.Interceptor
      • canReplaceStoredHeader

        public static boolean canReplaceStoredHeader​(java.lang.String name)