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