Parameters.java

  1. /*
  2.  * Licensed under the Apache License, Version 2.0 (the "License");
  3.  * you may not use this file except in compliance with the License.
  4.  * You may obtain a copy of the License at
  5.  *
  6.  * http://www.apache.org/licenses/LICENSE-2.0
  7.  *
  8.  * Unless required by applicable law or agreed to in writing, software
  9.  * distributed under the License is distributed on an "AS IS" BASIS,
  10.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11.  * See the License for the specific language governing permissions and
  12.  * limitations under the License.
  13.  *
  14.  */

  15. package org.esigate;

  16. import org.esigate.authentication.RemoteUserAuthenticationHandler;
  17. import org.esigate.cache.BasicCacheStorage;
  18. import org.esigate.cookie.DefaultCookieManager;
  19. import org.esigate.extension.ConfigReloadOnChange;
  20. import org.esigate.extension.Esi;
  21. import org.esigate.extension.FetchLogging;
  22. import org.esigate.extension.FragmentLogging;
  23. import org.esigate.extension.ResourceFixup;
  24. import org.esigate.extension.XPoweredBy;
  25. import org.esigate.extension.surrogate.Surrogate;
  26. import org.esigate.util.Parameter;
  27. import org.esigate.util.ParameterArray;
  28. import org.esigate.util.ParameterBoolean;
  29. import org.esigate.util.ParameterCollection;
  30. import org.esigate.util.ParameterFloat;
  31. import org.esigate.util.ParameterInteger;
  32. import org.esigate.util.ParameterString;

  33. import java.util.Collection;

  34. /**
  35.  * Configuration properties names and default values.
  36.  *
  37.  * @author Francois-Xavier Bonnet
  38.  *
  39.  */
  40. public final class Parameters {

  41.     // Core parameters
  42.     public static final Parameter<String[]> REMOTE_URL_BASE = new ParameterArray("remoteUrlBase");
  43.     public static final Parameter<Collection<String>> MAPPINGS = new ParameterCollection("mappings");
  44.     public static final Parameter<Boolean> STRIP_MAPPING_PATH = new ParameterBoolean("stripMappingPath", false);
  45.     public static final Parameter<String> URI_ENCODING = new ParameterString("uriEncoding", "ISO-8859-1");
  46.     public static final Parameter<Collection<String>> PARSABLE_CONTENT_TYPES = new ParameterCollection(
  47.             "parsableContentTypes", "text/html", "application/xhtml+xml");
  48.     // Network settings
  49.     public static final Parameter<Integer> MAX_CONNECTIONS_PER_HOST = new ParameterInteger("maxConnectionsPerHost", 20);
  50.     public static final Parameter<Integer> CONNECT_TIMEOUT = new ParameterInteger("connectTimeout", 1000);
  51.     public static final Parameter<Integer> SOCKET_TIMEOUT = new ParameterInteger("socketTimeout", 10000);
  52.     // Proxy settings
  53.     public static final Parameter<String> PROXY_HOST = new ParameterString("proxyHost");
  54.     public static final Parameter<Integer> PROXY_PORT = new ParameterInteger("proxyPort", 0);
  55.     public static final Parameter<String> PROXY_USER = new ParameterString("proxyUser");
  56.     public static final Parameter<String> PROXY_PASSWORD = new ParameterString("proxyPassword");
  57.     // Http headers
  58.     public static final Parameter<Boolean> PRESERVE_HOST = new ParameterBoolean("preserveHost", true);
  59.     // Cookies
  60.     public static final Parameter<String> COOKIE_MANAGER = new ParameterString("cookieManager",
  61.             DefaultCookieManager.class.getName());
  62.     public static final Parameter<Collection<String>> DISCARD_COOKIES = new ParameterCollection("discardCookies");
  63.     public static final Parameter<Collection<String>> STORE_COOKIES_IN_SESSION = new ParameterCollection(
  64.             "storeCookiesInSession");
  65.     public static final Parameter<String> VISIBLE_URL_BASE = new ParameterString("visibleUrlBase");
  66.     // Possible values for remoteUrlBaseStrategy
  67.     public static final String STICKYSESSION = "stickysession";
  68.     public static final String IPHASH = "iphash";
  69.     public static final String ROUNDROBIN = "roundrobin";
  70.     // Load-balancing
  71.     public static final Parameter<String> REMOTE_URL_BASE_STRATEGY = new ParameterString("remoteUrlBaseStrategy",
  72.             Parameters.ROUNDROBIN);
  73.     // Extensions
  74.     public static final Parameter<Collection<String>> EXTENSIONS = new ParameterCollection("extensions",
  75.             FragmentLogging.class.getName(), FetchLogging.class.getName(),
  76.             RemoteUserAuthenticationHandler.class.getName(), Esi.class.getName(), ResourceFixup.class.getName(),
  77.             XPoweredBy.class.getName(), Surrogate.class.getName(), ConfigReloadOnChange.class.getName());
  78.     // Cache settings
  79.     public static final Parameter<Boolean> USE_CACHE = new ParameterBoolean("useCache", true);
  80.     public static final Parameter<Integer> MAX_CACHE_ENTRIES = new ParameterInteger("maxCacheEntries", 1000);
  81.     public static final Parameter<Integer> MAX_OBJECT_SIZE = new ParameterInteger("maxObjectSize", 1000000);
  82.     public static final Parameter<String> CACHE_STORAGE = new ParameterString("cacheStorage",
  83.             BasicCacheStorage.class.getName());
  84.     public static final Parameter<Boolean> X_CACHE_HEADER = new ParameterBoolean("xCacheHeader", false);
  85.     public static final Parameter<Boolean> VIA_HEADER = new ParameterBoolean("viaHeader", true);
  86.     // Forced caching
  87.     public static final Parameter<Integer> TTL = new ParameterInteger("ttl", 0);
  88.     // Heuristic caching
  89.     public static final Parameter<Boolean> HEURISTIC_CACHING_ENABLED = new ParameterBoolean("heuristicCachingEnabled",
  90.             true);
  91.     // default value defined in
  92.     // http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.2.4
  93.     public static final Parameter<Float> HEURISTIC_COEFFICIENT = new ParameterFloat("heuristicCoefficient", 0.1f);
  94.     // when no cache directive at all, nothing is cached by default
  95.     public static final Parameter<Integer> HEURISTIC_DEFAULT_LIFETIME_SECS = new ParameterInteger(
  96.             "heuristicDefaultLifetimeSecs", 0);
  97.     // Background revalidation
  98.     public static final Parameter<Integer> STALE_WHILE_REVALIDATE = new ParameterInteger("staleWhileRevalidate", 0);
  99.     public static final Parameter<Integer> STALE_IF_ERROR = new ParameterInteger("staleIfError", 0);
  100.     public static final Parameter<Integer> MIN_ASYNCHRONOUS_WORKERS = new ParameterInteger("minAsynchronousWorkers", 0);
  101.     public static final Parameter<Integer> MAX_ASYNCHRONOUS_WORKERS = new ParameterInteger("maxAsynchronousWorkers", 0);
  102.     public static final Parameter<Integer> ASYNCHRONOUS_WORKER_IDLE_LIFETIME_SECS = new ParameterInteger(
  103.             "asynchronousWorkerIdleLifetimeSecs", 60);
  104.     public static final Parameter<Integer> MAX_UPDATE_RETRIES = new ParameterInteger("maxUpdateRetries", 1);
  105.     public static final Parameter<Integer> REVALIDATION_QUEUE_SIZE = new ParameterInteger("revalidationQueueSize", 100);
  106.     // EhCache
  107.     public static final Parameter<String> EHCACHE_CACHE_NAME_PROPERTY = new ParameterString("ehcache.cacheName",
  108.             "esigate");
  109.     public static final Parameter<String> EHCACHE_CONFIGURATION_FILE_PROPERTY = new ParameterString(
  110.             "ehcache.configurationFile");
  111.     // MemCached
  112.     public static final Parameter<Collection<String>> MEMCACHED_SERVERS_PROPERTY = new ParameterCollection(
  113.             "memcached.servers");
  114.     // Default size for String or byte buffers used to manipulate html page contents
  115.     public static final int DEFAULT_BUFFER_SIZE = 1024;
  116.     // Default size for String or byte buffers used to manipulate small things like tags, cookie, log lines
  117.     public static final int SMALL_BUFFER_SIZE = 256;

  118.     private Parameters() {

  119.     }
  120. }