Java 8 ResponseCache - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 ResponseCache class.

This code example shows how to use the following methods:get
    this.responseCache = responseCache;
  } 
 
  @Override public CacheResponse get(URI uri, String requestMethod,
      Map<String, List<String>> requestHeaders) throws IOException {
    return responseCache.get(uri, requestMethod, requestHeaders);
  } 
 
  @Override public CacheRequest put(URI uri, URLConnection urlConnection) throws IOException {
    return responseCache.put(uri, urlConnection);
  } 
 
  @Override public void maybeRemove(String requestMethod, URI uri) throws IOException {
  } 
 
  @Override public void update(CacheResponse conditionalCacheHit, HttpURLConnection connection)
      throws IOException {
  } 
 
  @Override public void trackConditionalCacheHit() { 
5
CodeRank
This code example shows how to use the following methods:get
  } 
 
  @Override 
  public CacheResponse get(final URI uri, final String requestMethod, final Map<String, List<String>> requestHeaders) throws IOException {
    if (delegate == null) { return null; }
    return delegate.get(uri, requestMethod, requestHeaders);
  } 
 
  @Override 
  public CacheResponse get(final URI uri, final URLConnection connection) throws IOException {
    if (delegate == null) { return null; }
    if (delegate instanceof EnhancedResponseCache) {
      return ((EnhancedResponseCache) delegate).get(uri, connection);
    } 
    final URLConnection coreConnection = UrlConnectionWrapper.unwrap(connection);
    return delegate.get(uri, ((HttpURLConnection)coreConnection).getRequestMethod(), coreConnection.getHeaderFields());
  } 
 
  @Override 
  public CacheRequest put(final URI uri, final URLConnection connection) throws IOException {
5
CodeRank
This code example shows how to use the following methods:get
      return ((EnhancedResponseCache) core).get(uri, connection);
    } 
    final URLConnection coreConnection = UrlConnectionWrapper.unwrap(connection);
    if (coreConnection instanceof HttpURLConnection) {
      final HttpURLConnection http = (HttpURLConnection) coreConnection;
      return core.get(uri, http.getRequestMethod(), http.getRequestProperties());
    } 
    return null; 
  } 
 
  @Override 
  public boolean deleteGetEntry(final String url) throws IOException {
    if (core instanceof EnhancedResponseCache) {
      return ((EnhancedResponseCache) core).deleteGetEntry(url);
    } 
    return false; 
  } 
 
  @Override 
  public boolean contains(final String url) {
4
CodeRank
This code example shows how to use the following methods:get
    this.responseCache = responseCache;
  } 
 
  @Override public CacheResponse get(URI uri, String requestMethod,
      Map<String, List<String>> requestHeaders) throws IOException {
    return responseCache.get(uri, requestMethod, requestHeaders);
  } 
 
  @Override public CacheRequest put(URI uri, URLConnection urlConnection) throws IOException {
    return responseCache.put(uri, urlConnection);
  } 
 
  @Override public void update(CacheResponse conditionalCacheHit, HttpURLConnection connection)
      throws IOException {
  } 
 
  @Override public void trackConditionalCacheHit() { 
  } 
 
  @Override public void trackResponse(ResponseSource source) {
4
CodeRank
This code example shows how to use the following methods:setDefault
	@Override 
	public void onCreate() { 
		super.onCreate(); 
		 
		// Setting up caching 
		ResponseCache.setDefault(new CEResponseCache());
		 
		this.prefs = PreferenceManager.getDefaultSharedPreferences(this);
		this.challengeData = new ChallengeData(this);
		this.activityData = new ActivityData(this);
		 
		// Prepare Intent for UpdaterService 
		updaterServiceIntent = new Intent(this, UpdateService.class);
		updaterPendingIntent = PendingIntent.getService(this, -1, updaterServiceIntent, PendingIntent.FLAG_UPDATE_CURRENT);
	} 
	 
	public SharedPreferences getPreferences() {
		return this.prefs;
	} 
	 
4
CodeRank
This code example shows how to use the following methods:get
    this.responseCache = responseCache;
  } 
 
  @Override public CacheResponse get(URI uri, String requestMethod,
      Map<String, List<String>> requestHeaders) throws IOException {
    return responseCache.get(uri, requestMethod, requestHeaders);
  } 
 
  @Override public CacheRequest put(URI uri, URLConnection urlConnection) throws IOException {
    return responseCache.put(uri, urlConnection);
  } 
 
  @Override public void maybeRemove(String requestMethod, URI uri) throws IOException {
  } 
 
  @Override public void update(CacheResponse conditionalCacheHit, HttpURLConnection connection)
      throws IOException {
  } 
 
  @Override public void trackConditionalCacheHit() { 
4
CodeRank
This code example shows how to use the following methods:setDefault
		ResponseCache responseCache = ResponseCache.getDefault();
		if (responseCache instanceof OhmageCache) {
			Log.v(TAG, "Cache has already been installed.");
		} else if (responseCache == null) {
			OhmageCache dropCache = new OhmageCache(context);
			ResponseCache.setDefault(dropCache);
		} else { 
			Class<? extends ResponseCache> type = responseCache.getClass();
			Log.e(TAG, "Another ResponseCache has already been installed: " + type);
		} 
	} 
 
	public static boolean isResponseImageRequest(URI uri) {
		if(uri == null || uri.getHost() == null || uri.getPath() == null)
			return false; 
		URI responseUri = URI.create(ConfigHelper.serverUrl() + OhmageApi.IMAGE_READ_PATH);
		return uri.getHost().equals(responseUri.getHost()) && uri.getPath().startsWith(responseUri.getPath());
	} 
 
	public static File getCachedFile(Context context, URI uri) {
4
CodeRank
This code example shows how to use the following methods:setDefault
    } 
     
    private void installHttpHandler(long httpCacheSize, File httpCacheDir ){
        try{ 
            HttpResponseCache result = new HttpResponseCache(httpCacheDir, httpCacheSize);
            ResponseCache.setDefault(result);
            URL.setURLStreamHandlerFactory(new OkHttpURLStreamHandlerFactory(new OkHttpClient()));
        }catch(Exception e){
        	Ln.e(e, "Failed to set up okhttp");
        } 
    } 
 
	public boolean isDebugMode() { 
		// check if android:debuggable is set to true 
		if (getApplicationInfo() == null) {
			// getApplicationInfo() returns null in unit tests 
			return true; 
		} else { 
			int applicationFlags = getApplicationInfo().flags;
			return ((applicationFlags & ApplicationInfo.FLAG_DEBUGGABLE) != 0);
4
CodeRank
This code example shows how to use the following methods:get
    this.responseCache = responseCache;
  } 
 
  @Override public CacheResponse get(URI uri, String requestMethod,
      Map<String, List<String>> requestHeaders) throws IOException {
    return responseCache.get(uri, requestMethod, requestHeaders);
  } 
 
  @Override public CacheRequest put(URI uri, URLConnection urlConnection) throws IOException {
    return responseCache.put(uri, urlConnection);
  } 
 
  @Override public void update(CacheResponse conditionalCacheHit, HttpURLConnection connection)
      throws IOException { 
  } 
 
  @Override public void trackConditionalCacheHit() { 
  } 
 
  @Override public void trackResponse(ResponseSource source) {
4
CodeRank
This code example shows how to use the following methods:get
        if (!useCaches || responseCache == null || hasTriedCache) { 
            return (hasTriedCache && socketIn != null); 
        } 
 
        hasTriedCache = true; 
        cacheResponse = responseCache.get(uri, method, requestHeader.getFieldMap()); 
        if (cacheResponse == null) { 
            return socketIn != null; // TODO: if this is non-null, why are we calling getFromCache? 
        } 
        Map<String, List<String>> headersMap = cacheResponse.getHeaders(); 
        if (headersMap != null) { 
            responseHeader = new Header(headersMap); 
        } 
        socketIn = responseBodyIn = cacheResponse.getBody(); 
        return socketIn != null; 
    } 
 
    private void maybeCache() throws IOException { 
        // Are we caching at all? 
        if (!useCaches || responseCache == null) { 
2
CodeRank
See Code Examples for Java 8 ResponseCache Methods: