Package org.apache.abdera.protocol.client.cache

Examples of org.apache.abdera.protocol.client.cache.CachedResponse


        Cache cache = getCache();
        CacheDisposition disp =
          (useCache(method,options)) ?
            cache.getDisposition(uri, options) :
            CacheDisposition.TRANSPARENT;
        CachedResponse cached_response = cache.get(uri, options);
        disp = (!disp.equals(CacheDisposition.TRANSPARENT) &&
                mustRevalidate(options, cached_response)) ?
                  CacheDisposition.STALE :
                  disp;
        switch(disp) {
          case FRESH:                                                            // CACHE HIT: FRESH
            if (cached_response != null)
              return cached_response;
          case STALE:                                                            // CACHE HIT: STALE
            // revalidate the cached entry
            if (cached_response != null && cached_response.getEntityTag() != null) {
              options.setIfModifiedSince(cached_response.getLastModified());
              options.setIfNoneMatch(cached_response.getEntityTag().toString());
            } else {
              disp = CacheDisposition.TRANSPARENT;
            }
          default:                                                               // CACHE MISS
            HttpMethod httpMethod =
View Full Code Here


      boolean usecache = useCache(method,options);
      options = options != null ? options : getDefaultRequestOptions();
      HttpMethod httpMethod = null;
      try {
        Cache cache = getCache();
        CachedResponse cached_response = cache.get(uri);
        switch(
          getCacheDisposition(
            usecache,
            uri,
            options,
            cached_response)) {
          case FRESH:                                                            // CACHE HIT: FRESH
            if (cached_response != null)
              return checkRequestException(
                cached_response,options);
          case STALE:                                                            // CACHE HIT: STALE
            // revalidate the cached entry
            if (cached_response != null) {
              if (cached_response.getEntityTag() != null)
                options.setIfNoneMatch(cached_response.getEntityTag().toString());
              else if (cached_response.getLastModified() != null)
                options.setIfModifiedSince(cached_response.getLastModified());
              else options.setNoCache(true);
            }
          default:                                                               // CACHE MISS
            httpMethod =
              MethodHelper.createMethod(
View Full Code Here

    RequestOptions options) {
      boolean usecache = useCache(method,options);
      options = options != null ? options : getDefaultRequestOptions();
      try {
        Cache cache = getCache();
        CachedResponse cached_response = cache.get(uri);
        switch(
          getCacheDisposition(
            usecache,
            uri,
            options,
            cached_response)) {
          case FRESH:                                                            // CACHE HIT: FRESH
            if (cached_response != null)
              return checkRequestException(
                cached_response,options);
          case STALE:                                                            // CACHE HIT: STALE
            // revalidate the cached entry
            if (cached_response != null) {
              if (cached_response.getEntityTag() != null)
                options.setIfNoneMatch(cached_response.getEntityTag().toString());
              else if (cached_response.getLastModified() != null)
                options.setIfModifiedSince(cached_response.getLastModified());
              else options.setNoCache(true);
            }
          default:                                                               // CACHE MISS
            HttpMethod httpMethod =
              MethodHelper.createMethod(
View Full Code Here

    public ClientResponse execute(String method, String uri, RequestEntity entity, RequestOptions options) {
        boolean usecache = useCache(method, options);
        options = options != null ? options : getDefaultRequestOptions();
        try {
            Cache cache = getCache();
            CachedResponse cached_response = cache.get(uri);
            switch (getCacheDisposition(usecache, uri, options, cached_response)) {
                case FRESH: // CACHE HIT: FRESH
                    if (cached_response != null)
                        return checkRequestException(cached_response, options);
                case STALE: // CACHE HIT: STALE
                    // revalidate the cached entry
                    if (cached_response != null) {
                        if (cached_response.getEntityTag() != null)
                            options.setIfNoneMatch(cached_response.getEntityTag().toString());
                        else if (cached_response.getLastModified() != null)
                            options.setIfModifiedSince(cached_response.getLastModified());
                        else
                            options.setNoCache(true);
                    }
                default: // CACHE MISS
                    HttpMethod httpMethod = MethodHelper.createMethod(method, uri, entity, options);
View Full Code Here

    RequestOptions options) {
      boolean usecache = useCache(method,options);
      options = options != null ? options : getDefaultRequestOptions();
      try {
        Cache cache = getCache();
        CachedResponse cached_response = cache.get(uri);
        switch(
          getCacheDisposition(
            usecache,
            uri,
            options,
            cached_response)) {
          case FRESH:                                                            // CACHE HIT: FRESH
            if (cached_response != null)
              return checkRequestException(
                cached_response,options);
          case STALE:                                                            // CACHE HIT: STALE
            // revalidate the cached entry
            if (cached_response != null) {
              if (cached_response.getEntityTag() != null)
                options.setIfNoneMatch(cached_response.getEntityTag().toString());
              else if (cached_response.getLastModified() != null)
                options.setIfModifiedSince(cached_response.getLastModified());
              else options.setNoCache(true);
            }
          default:                                                               // CACHE MISS
            HttpMethod httpMethod =
              MethodHelper.createMethod(
View Full Code Here

    RequestOptions options) {
      boolean usecache = useCache(method,options);
      options = options != null ? options : getDefaultRequestOptions();
      try {
        Cache cache = getCache();
        CachedResponse cached_response = cache.get(uri, options);
        CacheDisposition disp = getCacheDisposition(
          usecache, uri, options, cached_response);
        switch(disp) {
          case FRESH:                                                            // CACHE HIT: FRESH
            if (cached_response != null) {
              checkRequestException(cached_response,options);
              return cached_response;
            }
          case STALE:                                                            // CACHE HIT: STALE
            // revalidate the cached entry
            if (cached_response != null) {
              if (cached_response.getEntityTag() != null)
                options.setIfNoneMatch(cached_response.getEntityTag().toString());
              else if (cached_response.getLastModified() != null)
                options.setIfModifiedSince(cached_response.getLastModified());
              else options.setNoCache(true);
            } else {
              disp = CacheDisposition.TRANSPARENT;
            }
          default:                                                               // CACHE MISS
View Full Code Here

TOP

Related Classes of org.apache.abdera.protocol.client.cache.CachedResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.