Advertisement
danikula

Simple HttpProxyCacheServer factory

Oct 23rd, 2015
4,660
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * <strong>Not thread-safe</strong> {@link HttpProxyCacheServer} factory that returns single instance of proxy.
  3.  *
  4.  * @author Alexey Danilov (danikula@gmail.com).
  5.  */
  6. public class ProxyFactory {
  7.  
  8.     private static HttpProxyCacheServer sharedProxy;
  9.  
  10.     private ProxyFactory() {
  11.     }
  12.  
  13.     public static HttpProxyCacheServer getProxy(Context context) {
  14.         return sharedProxy == null ? (sharedProxy = newProxy(context)) : sharedProxy;
  15.     }
  16.  
  17.     private static HttpProxyCacheServer newProxy(Context context) {
  18.         return new HttpProxyCacheServer(context);
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement