package org.chenyang.http.impl.cookie;

import org.chenyang.http.annotation.Contract;
import org.chenyang.http.annotation.Obsolete;
import org.chenyang.http.annotation.ThreadingBehavior;
import org.chenyang.http.cookie.CookieSpec;
import org.chenyang.http.cookie.CookieSpecProvider;
import org.chenyang.http.protocol.HttpContext;

@Obsolete
@Contract(
   threading = ThreadingBehavior.IMMUTABLE
)
public class NetscapeDraftSpecProvider implements CookieSpecProvider {
   private final String[] datepatterns;
   private volatile CookieSpec cookieSpec;

   public NetscapeDraftSpecProvider(String[] datepatterns) {
      this.datepatterns = datepatterns;
   }

   public NetscapeDraftSpecProvider() {
      this((String[])null);
   }

   public CookieSpec create(HttpContext context) {
      if (this.cookieSpec == null) {
         synchronized(this) {
            if (this.cookieSpec == null) {
               this.cookieSpec = new NetscapeDraftSpec(this.datepatterns);
            }
         }
      }

      return this.cookieSpec;
   }
}
