001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.config.store; 014 015import static org.apache.juneau.config.store.ConfigFileStore.*; 016 017import java.io.*; 018import java.lang.reflect.*; 019import java.nio.charset.*; 020import java.util.*; 021 022import org.apache.juneau.*; 023import org.apache.juneau.http.*; 024import org.apache.juneau.reflect.*; 025import org.apache.juneau.svl.*; 026 027/** 028 * Builder for {@link ConfigFileStore} objects. 029 */ 030public class ConfigFileStoreBuilder extends ConfigStoreBuilder { 031 032 /** 033 * Constructor, default settings. 034 */ 035 public ConfigFileStoreBuilder() { 036 super(); 037 } 038 039 /** 040 * Constructor. 041 * 042 * @param ps The initial configuration settings for this builder. 043 */ 044 public ConfigFileStoreBuilder(PropertyStore ps) { 045 super(ps); 046 } 047 048 @Override /* ContextBuilder */ 049 public ConfigFileStore build() { 050 return new ConfigFileStore(getPropertyStore()); 051 } 052 053 //----------------------------------------------------------------------------------------------------------------- 054 // Properties 055 //----------------------------------------------------------------------------------------------------------------- 056 057 /** 058 * Configuration property: Local file system directory. 059 * 060 * <p> 061 * Identifies the path of the directory containing the configuration files. 062 * 063 * <ul class='seealso'> 064 * <li class='jf'>{@link ConfigFileStore#FILESTORE_directory} 065 * </ul> 066 * 067 * @param value 068 * The new value for this property. 069 * <br>The default is <js>"."</js>. 070 * @return This object (for method chaining). 071 */ 072 public ConfigFileStoreBuilder directory(String value) { 073 super.set(FILESTORE_directory, value); 074 return this; 075 } 076 077 /** 078 * Configuration property: Local file system directory. 079 * 080 * <p> 081 * Identifies the path of the directory containing the configuration files. 082 * 083 * <ul class='seealso'> 084 * <li class='jf'>{@link ConfigFileStore#FILESTORE_directory} 085 * </ul> 086 * 087 * @param value 088 * The new value for this property. 089 * <br>The default is <js>"."</js>. 090 * @return This object (for method chaining). 091 */ 092 public ConfigFileStoreBuilder directory(File value) { 093 super.set(FILESTORE_directory, value); 094 return this; 095 } 096 097 /** 098 * Configuration property: Charset. 099 * 100 * <p> 101 * Identifies the charset of external files. 102 * 103 * <ul class='seealso'> 104 * <li class='jf'>{@link ConfigFileStore#FILESTORE_charset} 105 * </ul> 106 * 107 * @param value 108 * The new value for this property. 109 * <br>The default is <js>"."</js>. 110 * @return This object (for method chaining). 111 */ 112 public ConfigFileStoreBuilder charset(String value) { 113 super.set(FILESTORE_charset, value); 114 return this; 115 } 116 117 /** 118 * Configuration property: Charset. 119 * 120 * <p> 121 * Identifies the charset of external files. 122 * 123 * <ul class='seealso'> 124 * <li class='jf'>{@link ConfigFileStore#FILESTORE_charset} 125 * </ul> 126 * 127 * @param value 128 * The new value for this property. 129 * <br>The default is <js>"."</js>. 130 * @return This object (for method chaining). 131 */ 132 public ConfigFileStoreBuilder charset(Charset value) { 133 super.set(FILESTORE_charset, value); 134 return this; 135 } 136 137 /** 138 * Configuration property: Use watcher. 139 * 140 * <p> 141 * Shortcut for calling <code>useWatcher(<jk>true</jk>)</code>. 142 * 143 * <ul class='seealso'> 144 * <li class='jf'>{@link ConfigFileStore#FILESTORE_useWatcher} 145 * </ul> 146 * 147 * @return This object (for method chaining). 148 */ 149 public ConfigFileStoreBuilder useWatcher() { 150 super.set(FILESTORE_useWatcher, true); 151 return this; 152 } 153 154 /** 155 * Configuration property: Watcher sensitivity. 156 * 157 * <p> 158 * Determines how frequently the file system is polled for updates. 159 * 160 * <ul class='seealso'> 161 * <li class='jf'>{@link ConfigFileStore#FILESTORE_watcherSensitivity} 162 * </ul> 163 * 164 * @param value 165 * The new value for this property. 166 * <br>The default is {@link WatcherSensitivity#MEDIUM} 167 * @return This object (for method chaining). 168 */ 169 public ConfigFileStoreBuilder watcherSensitivity(WatcherSensitivity value) { 170 super.set(FILESTORE_watcherSensitivity, value); 171 return this; 172 } 173 174 /** 175 * Configuration property: Update-on-write. 176 * 177 * <p> 178 * Shortcut for calling <code>useWatcher(<jk>true</jk>)</code>. 179 * 180 * <ul class='seealso'> 181 * <li class='jf'>{@link ConfigFileStore#FILESTORE_updateOnWrite} 182 * </ul> 183 * 184 * @return This object (for method chaining). 185 */ 186 public ConfigFileStoreBuilder updateOnWrite() { 187 super.set(FILESTORE_updateOnWrite, true); 188 return this; 189 } 190 191 /** 192 * Configuration property: Watcher sensitivity. 193 * 194 * <p> 195 * Determines how frequently the file system is polled for updates. 196 * 197 * <ul class='seealso'> 198 * <li class='jf'>{@link ConfigFileStore#FILESTORE_watcherSensitivity} 199 * </ul> 200 * 201 * @param value 202 * The new value for this property. 203 * <br>The default is {@link WatcherSensitivity#MEDIUM} 204 * @return This object (for method chaining). 205 */ 206 public ConfigFileStoreBuilder watcherSensitivity(String value) { 207 super.set(FILESTORE_watcherSensitivity, value); 208 return this; 209 } 210 211 /** 212 * Configuration property: File extensions. 213 * 214 * <p> 215 * Defines what file extensions to search for when the config name does not have an extension. 216 * 217 * @param value 218 * The new value for this property. 219 * <br>The default is <js>"cfg"</js>. 220 * @return This object (for method chaining). 221 */ 222 public ConfigFileStoreBuilder extensions(String value) { 223 super.set(FILESTORE_extensions, value); 224 return this; 225 } 226 227 // <FluentSetters> 228 229 @Override /* GENERATED - ContextBuilder */ 230 public ConfigFileStoreBuilder add(Map<String,Object> properties) { 231 super.add(properties); 232 return this; 233 } 234 235 @Override /* GENERATED - ContextBuilder */ 236 public ConfigFileStoreBuilder addTo(String name, Object value) { 237 super.addTo(name, value); 238 return this; 239 } 240 241 @Override /* GENERATED - ContextBuilder */ 242 public ConfigFileStoreBuilder appendTo(String name, Object value) { 243 super.appendTo(name, value); 244 return this; 245 } 246 247 @Override /* GENERATED - ContextBuilder */ 248 public ConfigFileStoreBuilder apply(PropertyStore copyFrom) { 249 super.apply(copyFrom); 250 return this; 251 } 252 253 @Override /* GENERATED - ContextBuilder */ 254 public ConfigFileStoreBuilder applyAnnotations(java.lang.Class<?>...fromClasses) { 255 super.applyAnnotations(fromClasses); 256 return this; 257 } 258 259 @Override /* GENERATED - ContextBuilder */ 260 public ConfigFileStoreBuilder applyAnnotations(Method...fromMethods) { 261 super.applyAnnotations(fromMethods); 262 return this; 263 } 264 265 @Override /* GENERATED - ContextBuilder */ 266 public ConfigFileStoreBuilder applyAnnotations(AnnotationList al, VarResolverSession r) { 267 super.applyAnnotations(al, r); 268 return this; 269 } 270 271 @Override /* GENERATED - ContextBuilder */ 272 public ConfigFileStoreBuilder debug() { 273 super.debug(); 274 return this; 275 } 276 277 @Override /* GENERATED - ContextBuilder */ 278 public ConfigFileStoreBuilder locale(Locale value) { 279 super.locale(value); 280 return this; 281 } 282 283 @Override /* GENERATED - ContextBuilder */ 284 public ConfigFileStoreBuilder mediaType(MediaType value) { 285 super.mediaType(value); 286 return this; 287 } 288 289 @Override /* GENERATED - ContextBuilder */ 290 public ConfigFileStoreBuilder prependTo(String name, Object value) { 291 super.prependTo(name, value); 292 return this; 293 } 294 295 @Override /* GENERATED - ContextBuilder */ 296 public ConfigFileStoreBuilder putAllTo(String name, Object value) { 297 super.putAllTo(name, value); 298 return this; 299 } 300 301 @Override /* GENERATED - ContextBuilder */ 302 public ConfigFileStoreBuilder putTo(String name, String key, Object value) { 303 super.putTo(name, key, value); 304 return this; 305 } 306 307 @Override /* GENERATED - ContextBuilder */ 308 public ConfigFileStoreBuilder removeFrom(String name, Object value) { 309 super.removeFrom(name, value); 310 return this; 311 } 312 313 @Override /* GENERATED - ContextBuilder */ 314 public ConfigFileStoreBuilder set(Map<String,Object> properties) { 315 super.set(properties); 316 return this; 317 } 318 319 @Override /* GENERATED - ContextBuilder */ 320 public ConfigFileStoreBuilder set(String name, Object value) { 321 super.set(name, value); 322 return this; 323 } 324 325 @Override /* GENERATED - ContextBuilder */ 326 public ConfigFileStoreBuilder timeZone(TimeZone value) { 327 super.timeZone(value); 328 return this; 329 } 330 331 // </FluentSetters> 332}