001package org.apache.commons.jcs.auxiliary.remote.http.client; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import org.apache.commons.jcs.auxiliary.remote.RemoteCacheAttributes; 023 024/** Http client specific settings. */ 025public class RemoteHttpCacheAttributes 026 extends RemoteCacheAttributes 027{ 028 /** Don't change. */ 029 private static final long serialVersionUID = -5944327125140505212L; 030 031 /** http verison to use. */ 032 private static final String DEFAULT_HTTP_VERSION = "1.1"; 033 034 /** The max connections allowed per host */ 035 private int maxConnectionsPerHost = 100; 036 037 /** The socket timeout. */ 038 private int socketTimeoutMillis = 3000; 039 040 /** The socket connections timeout */ 041 private int connectionTimeoutMillis = 5000; 042 043 /** http verison to use. */ 044 private String httpVersion = DEFAULT_HTTP_VERSION; 045 046 /** The cache name will be included on the parameters */ 047 private boolean includeCacheNameAsParameter = true; 048 049 /** keys and patterns will be included in the parameters */ 050 private boolean includeKeysAndPatternsAsParameter = true; 051 052 /** keys and patterns will be included in the parameters */ 053 private boolean includeRequestTypeasAsParameter = true; 054 055 /** The complete URL to the service. */ 056 private String url; 057 058 /** The default classname for the client. */ 059 public static final String DEFAULT_REMOTE_HTTP_CLIENT_CLASS_NAME = RemoteHttpCacheClient.class.getName(); 060 061 /** This allows users to inject their own client implementation. */ 062 private String remoteHttpClientClassName = DEFAULT_REMOTE_HTTP_CLIENT_CLASS_NAME; 063 064 /** 065 * @param maxConnectionsPerHost the maxConnectionsPerHost to set 066 */ 067 public void setMaxConnectionsPerHost( int maxConnectionsPerHost ) 068 { 069 this.maxConnectionsPerHost = maxConnectionsPerHost; 070 } 071 072 /** 073 * @return the maxConnectionsPerHost 074 */ 075 public int getMaxConnectionsPerHost() 076 { 077 return maxConnectionsPerHost; 078 } 079 080 /** 081 * @param socketTimeoutMillis the socketTimeoutMillis to set 082 */ 083 public void setSocketTimeoutMillis( int socketTimeoutMillis ) 084 { 085 this.socketTimeoutMillis = socketTimeoutMillis; 086 } 087 088 /** 089 * @return the socketTimeoutMillis 090 */ 091 public int getSocketTimeoutMillis() 092 { 093 return socketTimeoutMillis; 094 } 095 096 /** 097 * @param httpVersion the httpVersion to set 098 */ 099 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}