View Javadoc
1   package org.apache.commons.jcs.auxiliary.remote.http.client;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.commons.jcs.auxiliary.remote.RemoteCacheAttributes;
23  
24  /** Http client specific settings. */
25  public class RemoteHttpCacheAttributes
26      extends RemoteCacheAttributes
27  {
28      /** Don't change. */
29      private static final long serialVersionUID = -5944327125140505212L;
30  
31      /** http verison to use. */
32      private static final String DEFAULT_HTTP_VERSION = "1.1";
33  
34      /** The max connections allowed per host */
35      private int maxConnectionsPerHost = 100;
36  
37      /** The socket timeout. */
38      private int socketTimeoutMillis = 3000;
39  
40      /** The socket connections timeout */
41      private int connectionTimeoutMillis = 5000;
42  
43      /** http verison to use. */
44      private String httpVersion = DEFAULT_HTTP_VERSION;
45  
46      /** The cache name will be included on the parameters */
47      private boolean includeCacheNameAsParameter = true;
48  
49      /** keys and patterns will be included in the parameters */
50      private boolean includeKeysAndPatternsAsParameter = true;
51  
52      /** keys and patterns will be included in the parameters */
53      private boolean includeRequestTypeasAsParameter = true;
54  
55      /** The complete URL to the service. */
56      private String url;
57  
58      /** The default classname for the client.  */
59      public static final String DEFAULT_REMOTE_HTTP_CLIENT_CLASS_NAME = RemoteHttpCacheClient.class.getName();
60  
61      /** This allows users to inject their own client implementation. */
62      private String remoteHttpClientClassName = DEFAULT_REMOTE_HTTP_CLIENT_CLASS_NAME;
63  
64      /**
65       * @param maxConnectionsPerHost the maxConnectionsPerHost to set
66       */
67      public void setMaxConnectionsPerHost( int maxConnectionsPerHost )
68      {
69          this.maxConnectionsPerHost = maxConnectionsPerHost;
70      }
71  
72      /**
73       * @return the maxConnectionsPerHost
74       */
75      public int getMaxConnectionsPerHost()
76      {
77          return maxConnectionsPerHost;
78      }
79  
80      /**
81       * @param socketTimeoutMillis the socketTimeoutMillis to set
82       */
83      public void setSocketTimeoutMillis( int socketTimeoutMillis )
84      {
85          this.socketTimeoutMillis = socketTimeoutMillis;
86      }
87  
88      /**
89       * @return the socketTimeoutMillis
90       */
91      public int getSocketTimeoutMillis()
92      {
93          return socketTimeoutMillis;
94      }
95  
96      /**
97       * @param httpVersion the httpVersion to set
98       */
99      public void setHttpVersion( String httpVersion )
100     {
101         this.httpVersion = httpVersion;
102     }
103 
104     /**
105      * @return the httpVersion
106      */
107     public String getHttpVersion()
108     {
109         return httpVersion;
110     }
111 
112     /**
113      * @param connectionTimeoutMillis the connectionTimeoutMillis to set
114      */
115     public void setConnectionTimeoutMillis( int connectionTimeoutMillis )
116     {
117         this.connectionTimeoutMillis = connectionTimeoutMillis;
118     }
119 
120     /**
121      * @return the connectionTimeoutMillis
122      */
123     public int getConnectionTimeoutMillis()
124     {
125         return connectionTimeoutMillis;
126     }
127 
128     /**
129      * @param includeCacheNameInURL the includeCacheNameInURL to set
130      */
131     public void setIncludeCacheNameAsParameter( boolean includeCacheNameInURL )
132     {
133         this.includeCacheNameAsParameter = includeCacheNameInURL;
134     }
135 
136     /**
137      * @return the includeCacheNameInURL
138      */
139     public boolean isIncludeCacheNameAsParameter()
140     {
141         return includeCacheNameAsParameter;
142     }
143 
144     /**
145      * @param includeKeysAndPatternsInURL the includeKeysAndPatternsInURL to set
146      */
147     public void setIncludeKeysAndPatternsAsParameter( boolean includeKeysAndPatternsInURL )
148     {
149         this.includeKeysAndPatternsAsParameter = includeKeysAndPatternsInURL;
150     }
151 
152     /**
153      * @return the includeKeysAndPatternsInURL
154      */
155     public boolean isIncludeKeysAndPatternsAsParameter()
156     {
157         return includeKeysAndPatternsAsParameter;
158     }
159 
160     /**
161      * @param includeRequestTypeasAsParameter the includeRequestTypeasAsParameter to set
162      */
163     public void setIncludeRequestTypeasAsParameter( boolean includeRequestTypeasAsParameter )
164     {
165         this.includeRequestTypeasAsParameter = includeRequestTypeasAsParameter;
166     }
167 
168     /**
169      * @return the includeRequestTypeasAsParameter
170      */
171     public boolean isIncludeRequestTypeasAsParameter()
172     {
173         return includeRequestTypeasAsParameter;
174     }
175 
176     /**
177      * @param url the url to set
178      */
179     public void setUrl( String url )
180     {
181         this.url = url;
182     }
183 
184     /**
185      * @return the url
186      */
187     public String getUrl()
188     {
189         return url;
190     }
191 
192     /**
193      * @param remoteHttpClientClassName the remoteHttpClientClassName to set
194      */
195     public void setRemoteHttpClientClassName( String remoteHttpClientClassName )
196     {
197         this.remoteHttpClientClassName = remoteHttpClientClassName;
198     }
199 
200     /**
201      * @return the remoteHttpClientClassName
202      */
203     public String getRemoteHttpClientClassName()
204     {
205         return remoteHttpClientClassName;
206     }
207 
208     /**
209      * @return String details
210      */
211     @Override
212     public String toString()
213     {
214         StringBuilder buf = new StringBuilder();
215         buf.append( "\n RemoteHttpCacheAttributes" );
216         buf.append( "\n maxConnectionsPerHost = [" + getMaxConnectionsPerHost() + "]" );
217         buf.append( "\n socketTimeoutMillis = [" + getSocketTimeoutMillis() + "]" );
218         buf.append( "\n httpVersion = [" + getHttpVersion() + "]" );
219         buf.append( "\n connectionTimeoutMillis = [" + getConnectionTimeoutMillis() + "]" );
220         buf.append( "\n includeCacheNameAsParameter = [" + isIncludeCacheNameAsParameter() + "]" );
221         buf.append( "\n includeKeysAndPatternsAsParameter = [" + isIncludeKeysAndPatternsAsParameter() + "]" );
222         buf.append( "\n includeRequestTypeasAsParameter = [" + isIncludeRequestTypeasAsParameter() + "]" );
223         buf.append( "\n url = [" + getUrl() + "]" );
224         buf.append( "\n remoteHttpClientClassName = [" + getRemoteHttpClientClassName() + "]" );
225         buf.append( super.toString() );
226         return buf.toString();
227     }
228 }