All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.backendless.BLHeadersManager Maven / Gradle / Ivy

There is a newer version: 7.0-alpha
Show newest version
package com.backendless;

import com.backendless.exceptions.BackendlessException;

import java.util.Hashtable;
import java.util.Map;

class BLHeadersManager implements IHeadersManager
{
  private static BLHeadersManager instance = new BLHeadersManager();

  static BLHeadersManager getInstance()
  {
    return instance;
  }

  private static ThreadLocal threadLocal = new InheritableThreadLocal()
  {
    @Override
    protected AndroidHeadersManager initialValue()
    {
      return new AndroidHeadersManager();
    }
  };

  BLHeadersManager()
  {

  }

  public void cleanHeaders()
  {
    threadLocal.remove();
  }

  @Override
  public void addHeader( HeadersManager.HeadersEnum headersEnum, String value )
  {
    threadLocal.get().addHeader( headersEnum, value );
  }

  @Override
  public void addHeaders( Map headers )
  {
    threadLocal.get().addHeaders( headers );
  }

  @Override
  public void removeHeader( HeadersManager.HeadersEnum headersEnum )
  {
    threadLocal.get().removeHeader( headersEnum );
  }

  @Override
  public Hashtable getHeaders() throws BackendlessException
  {
    return threadLocal.get().getHeaders();
  }

  @Override
  public void setHeaders( Map headers )
  {
    threadLocal.get().setHeaders( headers );
  }

  @Override
  public String getHeader( HeadersManager.HeadersEnum headersEnum ) throws BackendlessException
  {
    return threadLocal.get().getHeader( headersEnum );
  }
}






© 2015 - 2024 Weber Informatics LLC | Privacy Policy