| 1 | package fr.sii.ogham.sms.builder.cloudhopper; | |
| 2 | ||
| 3 | import java.util.concurrent.Executors; | |
| 4 | import java.util.concurrent.ScheduledExecutorService; | |
| 5 | import java.util.concurrent.ThreadFactory; | |
| 6 | import java.util.concurrent.atomic.AtomicInteger; | |
| 7 | import java.util.function.Supplier; | |
| 8 | ||
| 9 | import com.cloudhopper.smpp.pdu.EnquireLink; | |
| 10 | ||
| 11 | import fr.sii.ogham.core.builder.Builder; | |
| 12 | import fr.sii.ogham.core.builder.configuration.ConfigurationValueBuilder; | |
| 13 | import fr.sii.ogham.core.builder.configuration.ConfigurationValueBuilderHelper; | |
| 14 | import fr.sii.ogham.core.builder.configurer.Configurer; | |
| 15 | import fr.sii.ogham.core.builder.context.BuildContext; | |
| 16 | import fr.sii.ogham.core.fluent.AbstractParent; | |
| 17 | import fr.sii.ogham.sms.sender.impl.cloudhopper.KeepAliveOptions; | |
| 18 | ||
| 19 | /** | |
| 20 | * Builder to configure how keep alive session management should behave. | |
| 21 | * | |
| 22 | * <p> | |
| 23 | * Keep alive actively maintains the session opened by sending regularly | |
| 24 | * {@link EnquireLink} messages. | |
| 25 | * | |
| 26 | * This builder let you configure: | |
| 27 | * <ul> | |
| 28 | * <li>Enable/disable active keep alive management</li> | |
| 29 | * <li>The time to wait between two {@link EnquireLink} messages</li> | |
| 30 | * <li>The maximum time to wait for a response from the server for | |
| 31 | * {@link EnquireLink} request</li> | |
| 32 | * </ul> | |
| 33 | * | |
| 34 | * @author Aurélien Baudet | |
| 35 | * | |
| 36 | */ | |
| 37 | public class KeepAliveBuilder extends AbstractParent<SessionBuilder> implements Builder<KeepAliveOptions> { | |
| 38 | private static final AtomicInteger enquireLinkThreadCounter = new AtomicInteger(); | |
| 39 | ||
| 40 | private final ConfigurationValueBuilderHelper<KeepAliveBuilder, Boolean> enableValueBuilder; | |
| 41 | private final ConfigurationValueBuilderHelper<KeepAliveBuilder, Long> enquireLinkIntervalValueBuilder; | |
| 42 | private final ConfigurationValueBuilderHelper<KeepAliveBuilder, Long> enquireLinkTimeoutValueBuilder; | |
| 43 | private final ConfigurationValueBuilderHelper<KeepAliveBuilder, Boolean> connectAtStartupValueBuilder; | |
| 44 | private final ConfigurationValueBuilderHelper<KeepAliveBuilder, Integer> maxConsecutiveTimeoutsValueBuilder; | |
| 45 | private Supplier<ScheduledExecutorService> executorFactory; | |
| 46 | ||
| 47 | public KeepAliveBuilder(SessionBuilder parent, BuildContext buildContext) { | |
| 48 | super(parent); | |
| 49 | this.enableValueBuilder = buildContext.newConfigurationValueBuilder(this, Boolean.class); | |
| 50 | this.enquireLinkIntervalValueBuilder = buildContext.newConfigurationValueBuilder(this, Long.class); | |
| 51 | this.enquireLinkTimeoutValueBuilder = buildContext.newConfigurationValueBuilder(this, Long.class); | |
| 52 | this.connectAtStartupValueBuilder = buildContext.newConfigurationValueBuilder(this, Boolean.class); | |
| 53 | this.maxConsecutiveTimeoutsValueBuilder = buildContext.newConfigurationValueBuilder(this, Integer.class); | |
| 54 | } | |
| 55 | ||
| 56 | /** | |
| 57 | * Enable or disable sending of {@link EnquireLink} messages to keep the | |
| 58 | * session alive. | |
| 59 | * | |
| 60 | * <p> | |
| 61 | * The value set using this method takes precedence over any property and | |
| 62 | * default value configured using {@link #enable()}. | |
| 63 | * | |
| 64 | * <pre> | |
| 65 | * .enable(true) | |
| 66 | * .enable() | |
| 67 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
| 68 | * .defaultValue(false) | |
| 69 | * </pre> | |
| 70 | * | |
| 71 | * <pre> | |
| 72 | * .enable(true) | |
| 73 | * .enable() | |
| 74 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
| 75 | * .defaultValue(false) | |
| 76 | * </pre> | |
| 77 | * | |
| 78 | * In both cases, {@code enable(true)} is used. | |
| 79 | * | |
| 80 | * <p> | |
| 81 | * If this method is called several times, only the last value is used. | |
| 82 | * | |
| 83 | * <p> | |
| 84 | * If {@code null} value is set, it is like not setting a value at all. The | |
| 85 | * property/default value configuration is applied. | |
| 86 | * | |
| 87 | * @param enable | |
| 88 | * true to enable sending requests to keep the session alive | |
| 89 | * @return this instance for fluent chaining | |
| 90 | */ | |
| 91 | public KeepAliveBuilder enable(Boolean enable) { | |
| 92 |
2
1. enable : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → NO_COVERAGE 2. enable : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → TIMED_OUT |
enableValueBuilder.setValue(enable); |
| 93 |
2
1. enable : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::enable → NO_COVERAGE 2. enable : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::enable → KILLED |
return this; |
| 94 | } | |
| 95 | ||
| 96 | /** | |
| 97 | * Enable or disable sending of {@link EnquireLink} messages to keep the | |
| 98 | * session alive. | |
| 99 | * | |
| 100 | * <p> | |
| 101 | * This method is mainly used by {@link Configurer}s to register some | |
| 102 | * property keys and/or a default value. The aim is to let developer be able | |
| 103 | * to externalize its configuration (using system properties, configuration | |
| 104 | * file or anything else). If the developer doesn't configure any value for | |
| 105 | * the registered properties, the default value is used (if set). | |
| 106 | * | |
| 107 | * <pre> | |
| 108 | * .enable() | |
| 109 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
| 110 | * .defaultValue(false) | |
| 111 | * </pre> | |
| 112 | * | |
| 113 | * <p> | |
| 114 | * Non-null value set using {@link #enable(Boolean)} takes precedence over | |
| 115 | * property values and default value. | |
| 116 | * | |
| 117 | * <pre> | |
| 118 | * .enable(true) | |
| 119 | * .enable() | |
| 120 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
| 121 | * .defaultValue(false) | |
| 122 | * </pre> | |
| 123 | * | |
| 124 | * The value {@code true} is used regardless of the value of the properties | |
| 125 | * and default value. | |
| 126 | * | |
| 127 | * <p> | |
| 128 | * See {@link ConfigurationValueBuilder} for more information. | |
| 129 | * | |
| 130 | * | |
| 131 | * @return the builder to configure property keys/default value | |
| 132 | */ | |
| 133 | public ConfigurationValueBuilder<KeepAliveBuilder, Boolean> enable() { | |
| 134 |
5
1. enable : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::enable → KILLED 2. enable : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::enable → KILLED 3. enable : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::enable → KILLED 4. enable : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::enable → KILLED 5. enable : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::enable → KILLED |
return enableValueBuilder; |
| 135 | } | |
| 136 | ||
| 137 | /** | |
| 138 | * The fixed delay (in milliseconds) between two {@link EnquireLink} | |
| 139 | * messages. | |
| 140 | * | |
| 141 | * <p> | |
| 142 | * The value set using this method takes precedence over any property and | |
| 143 | * default value configured using {@link #interval()}. | |
| 144 | * | |
| 145 | * <pre> | |
| 146 | * .interval(60000L) | |
| 147 | * .interval() | |
| 148 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
| 149 | * .defaultValue(30000L) | |
| 150 | * </pre> | |
| 151 | * | |
| 152 | * <pre> | |
| 153 | * .interval(60000L) | |
| 154 | * .interval() | |
| 155 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
| 156 | * .defaultValue(30000L) | |
| 157 | * </pre> | |
| 158 | * | |
| 159 | * In both cases, {@code interval(60000L)} is used. | |
| 160 | * | |
| 161 | * <p> | |
| 162 | * If this method is called several times, only the last value is used. | |
| 163 | * | |
| 164 | * <p> | |
| 165 | * If {@code null} value is set, it is like not setting a value at all. The | |
| 166 | * property/default value configuration is applied. | |
| 167 | * | |
| 168 | * @param delay | |
| 169 | * the amount of time to wait between two {@link EnquireLink} | |
| 170 | * messages | |
| 171 | * @return this instance for fluent chaining | |
| 172 | */ | |
| 173 | public KeepAliveBuilder interval(Long delay) { | |
| 174 |
2
1. interval : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → NO_COVERAGE 2. interval : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → KILLED |
enquireLinkIntervalValueBuilder.setValue(delay); |
| 175 |
2
1. interval : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::interval → NO_COVERAGE 2. interval : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::interval → KILLED |
return this; |
| 176 | } | |
| 177 | ||
| 178 | /** | |
| 179 | * The fixed delay (in milliseconds) between two {@link EnquireLink} | |
| 180 | * messages. | |
| 181 | * | |
| 182 | * <p> | |
| 183 | * This method is mainly used by {@link Configurer}s to register some | |
| 184 | * property keys and/or a default value. The aim is to let developer be able | |
| 185 | * to externalize its configuration (using system properties, configuration | |
| 186 | * file or anything else). If the developer doesn't configure any value for | |
| 187 | * the registered properties, the default value is used (if set). | |
| 188 | * | |
| 189 | * <pre> | |
| 190 | * .interval() | |
| 191 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
| 192 | * .defaultValue(30000L) | |
| 193 | * </pre> | |
| 194 | * | |
| 195 | * <p> | |
| 196 | * Non-null value set using {@link #interval(Long)} takes precedence over | |
| 197 | * property values and default value. | |
| 198 | * | |
| 199 | * <pre> | |
| 200 | * .interval(60000L) | |
| 201 | * .interval() | |
| 202 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
| 203 | * .defaultValue(30000L) | |
| 204 | * </pre> | |
| 205 | * | |
| 206 | * The value {@code 60000L} is used regardless of the value of the | |
| 207 | * properties and default value. | |
| 208 | * | |
| 209 | * <p> | |
| 210 | * See {@link ConfigurationValueBuilder} for more information. | |
| 211 | * | |
| 212 | * | |
| 213 | * @return the builder to configure property keys/default value | |
| 214 | */ | |
| 215 | public ConfigurationValueBuilder<KeepAliveBuilder, Long> interval() { | |
| 216 |
5
1. interval : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::interval → KILLED 2. interval : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::interval → KILLED 3. interval : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::interval → KILLED 4. interval : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::interval → KILLED 5. interval : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::interval → KILLED |
return enquireLinkIntervalValueBuilder; |
| 217 | } | |
| 218 | ||
| 219 | /** | |
| 220 | * The maximum amount of time (in milliseconds) to wait for receiving a | |
| 221 | * response from the server to an {@link EnquireLink} request. | |
| 222 | * | |
| 223 | * <p> | |
| 224 | * The value set using this method takes precedence over any property and | |
| 225 | * default value configured using {@link #responseTimeout()}. | |
| 226 | * | |
| 227 | * <pre> | |
| 228 | * .responseTimeout(5000L) | |
| 229 | * .responseTimeout() | |
| 230 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
| 231 | * .defaultValue(10000L) | |
| 232 | * </pre> | |
| 233 | * | |
| 234 | * <pre> | |
| 235 | * .responseTimeout(5000L) | |
| 236 | * .responseTimeout() | |
| 237 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
| 238 | * .defaultValue(10000L) | |
| 239 | * </pre> | |
| 240 | * | |
| 241 | * In both cases, {@code responseTimeout(5000L)} is used. | |
| 242 | * | |
| 243 | * <p> | |
| 244 | * If this method is called several times, only the last value is used. | |
| 245 | * | |
| 246 | * <p> | |
| 247 | * If {@code null} value is set, it is like not setting a value at all. The | |
| 248 | * property/default value configuration is applied. | |
| 249 | * | |
| 250 | * @param timeout | |
| 251 | * the maximum amount of time to wait for the response | |
| 252 | * @return this instance for fluent chaining | |
| 253 | */ | |
| 254 | public KeepAliveBuilder responseTimeout(Long timeout) { | |
| 255 |
2
1. responseTimeout : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → NO_COVERAGE 2. responseTimeout : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → KILLED |
enquireLinkTimeoutValueBuilder.setValue(timeout); |
| 256 |
2
1. responseTimeout : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::responseTimeout → NO_COVERAGE 2. responseTimeout : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::responseTimeout → KILLED |
return this; |
| 257 | } | |
| 258 | ||
| 259 | /** | |
| 260 | * The maximum amount of time (in milliseconds) to wait for receiving a | |
| 261 | * response from the server to an {@link EnquireLink} request. | |
| 262 | * | |
| 263 | * <p> | |
| 264 | * This method is mainly used by {@link Configurer}s to register some | |
| 265 | * property keys and/or a default value. The aim is to let developer be able | |
| 266 | * to externalize its configuration (using system properties, configuration | |
| 267 | * file or anything else). If the developer doesn't configure any value for | |
| 268 | * the registered properties, the default value is used (if set). | |
| 269 | * | |
| 270 | * <pre> | |
| 271 | * .responseTimeout() | |
| 272 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
| 273 | * .defaultValue(10000L) | |
| 274 | * </pre> | |
| 275 | * | |
| 276 | * <p> | |
| 277 | * Non-null value set using {@link #responseTimeout(Long)} takes precedence | |
| 278 | * over property values and default value. | |
| 279 | * | |
| 280 | * <pre> | |
| 281 | * .responseTimeout(5000L) | |
| 282 | * .responseTimeout() | |
| 283 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
| 284 | * .defaultValue(10000L) | |
| 285 | * </pre> | |
| 286 | * | |
| 287 | * The value {@code 5000L} is used regardless of the value of the properties | |
| 288 | * and default value. | |
| 289 | * | |
| 290 | * <p> | |
| 291 | * See {@link ConfigurationValueBuilder} for more information. | |
| 292 | * | |
| 293 | * | |
| 294 | * @return the builder to configure property keys/default value | |
| 295 | */ | |
| 296 | public ConfigurationValueBuilder<KeepAliveBuilder, Long> responseTimeout() { | |
| 297 |
5
1. responseTimeout : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::responseTimeout → KILLED 2. responseTimeout : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::responseTimeout → KILLED 3. responseTimeout : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::responseTimeout → KILLED 4. responseTimeout : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::responseTimeout → KILLED 5. responseTimeout : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::responseTimeout → KILLED |
return enquireLinkTimeoutValueBuilder; |
| 298 | } | |
| 299 | ||
| 300 | /** | |
| 301 | * Connect to the server directly when the client is ready (if true). | |
| 302 | * Otherwise, the connection is done when the first message is sent. | |
| 303 | * | |
| 304 | * This may be useful to avoid a latency for the first message. | |
| 305 | * | |
| 306 | * If connection fails at startup, then a new attempt is done when first | |
| 307 | * message is sent. | |
| 308 | * | |
| 309 | * <p> | |
| 310 | * The value set using this method takes precedence over any property and | |
| 311 | * default value configured using {@link #connectAtStartup()}. | |
| 312 | * | |
| 313 | * <pre> | |
| 314 | * .connectAtStartup(true) | |
| 315 | * .connectAtStartup() | |
| 316 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
| 317 | * .defaultValue(false) | |
| 318 | * </pre> | |
| 319 | * | |
| 320 | * <pre> | |
| 321 | * .connectAtStartup(true) | |
| 322 | * .connectAtStartup() | |
| 323 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
| 324 | * .defaultValue(false) | |
| 325 | * </pre> | |
| 326 | * | |
| 327 | * In both cases, {@code connectAtStartup(true)} is used. | |
| 328 | * | |
| 329 | * <p> | |
| 330 | * If this method is called several times, only the last value is used. | |
| 331 | * | |
| 332 | * <p> | |
| 333 | * If {@code null} value is set, it is like not setting a value at all. The | |
| 334 | * property/default value configuration is applied. | |
| 335 | * | |
| 336 | * @param connectAtStartup | |
| 337 | * try to connect when client is ready | |
| 338 | * @return this instance for fluent chaining | |
| 339 | */ | |
| 340 | public KeepAliveBuilder connectAtStartup(Boolean connectAtStartup) { | |
| 341 |
2
1. connectAtStartup : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → NO_COVERAGE 2. connectAtStartup : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → KILLED |
connectAtStartupValueBuilder.setValue(connectAtStartup); |
| 342 |
2
1. connectAtStartup : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::connectAtStartup → NO_COVERAGE 2. connectAtStartup : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::connectAtStartup → KILLED |
return this; |
| 343 | } | |
| 344 | ||
| 345 | /** | |
| 346 | * Connect to the server directly when the client is ready (if true). | |
| 347 | * Otherwise, the connection is done when the first message is sent. | |
| 348 | * | |
| 349 | * This may be useful to avoid a latency for the first message. | |
| 350 | * | |
| 351 | * If connection fails at startup, then a new attempt is done when first | |
| 352 | * message is sent. | |
| 353 | * | |
| 354 | * <p> | |
| 355 | * This method is mainly used by {@link Configurer}s to register some | |
| 356 | * property keys and/or a default value. The aim is to let developer be able | |
| 357 | * to externalize its configuration (using system properties, configuration | |
| 358 | * file or anything else). If the developer doesn't configure any value for | |
| 359 | * the registered properties, the default value is used (if set). | |
| 360 | * | |
| 361 | * <pre> | |
| 362 | * .connectAtStartup() | |
| 363 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
| 364 | * .defaultValue(false) | |
| 365 | * </pre> | |
| 366 | * | |
| 367 | * <p> | |
| 368 | * Non-null value set using {@link #connectAtStartup(Boolean)} takes | |
| 369 | * precedence over property values and default value. | |
| 370 | * | |
| 371 | * <pre> | |
| 372 | * .connectAtStartup(true) | |
| 373 | * .connectAtStartup() | |
| 374 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
| 375 | * .defaultValue(false) | |
| 376 | * </pre> | |
| 377 | * | |
| 378 | * The value {@code true} is used regardless of the value of the properties | |
| 379 | * and default value. | |
| 380 | * | |
| 381 | * <p> | |
| 382 | * See {@link ConfigurationValueBuilder} for more information. | |
| 383 | * | |
| 384 | * | |
| 385 | * @return the builder to configure property keys/default value | |
| 386 | */ | |
| 387 | public ConfigurationValueBuilder<KeepAliveBuilder, Boolean> connectAtStartup() { | |
| 388 |
5
1. connectAtStartup : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::connectAtStartup → KILLED 2. connectAtStartup : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::connectAtStartup → KILLED 3. connectAtStartup : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::connectAtStartup → KILLED 4. connectAtStartup : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::connectAtStartup → KILLED 5. connectAtStartup : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::connectAtStartup → KILLED |
return connectAtStartupValueBuilder; |
| 389 | } | |
| 390 | ||
| 391 | /** | |
| 392 | * Provides a factory that creates an {@link ScheduledExecutorService}. The | |
| 393 | * created executor is then used to schedule the task that sends | |
| 394 | * {@link EnquireLink} requests. | |
| 395 | * | |
| 396 | * The factory should use one of: | |
| 397 | * <ul> | |
| 398 | * <li>{@link Executors#newSingleThreadScheduledExecutor()}</li> | |
| 399 | * <li>{@link Executors#newSingleThreadScheduledExecutor(java.util.concurrent.ThreadFactory)}</li> | |
| 400 | * <li>{@link Executors#newScheduledThreadPool(int)}</li> | |
| 401 | * <li>{@link Executors#newScheduledThreadPool(int, java.util.concurrent.ThreadFactory)}</li> | |
| 402 | * </ul> | |
| 403 | * | |
| 404 | * <p> | |
| 405 | * If this method is called several times, only the last value is used. | |
| 406 | * | |
| 407 | * @param executorFactory | |
| 408 | * the factory that creates an executor to use | |
| 409 | * @return this instance for fluent chaining | |
| 410 | */ | |
| 411 | public KeepAliveBuilder executor(Supplier<ScheduledExecutorService> executorFactory) { | |
| 412 | this.executorFactory = executorFactory; | |
| 413 |
2
1. executor : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::executor → NO_COVERAGE 2. executor : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::executor → KILLED |
return this; |
| 414 | } | |
| 415 | ||
| 416 | /** | |
| 417 | * Provides an {@link ScheduledExecutorService}. The executor is then used | |
| 418 | * to schedule the task that sends {@link EnquireLink} requests. | |
| 419 | * | |
| 420 | * <p> | |
| 421 | * This method is a shortcut to {@code executor(() -> executor)}. | |
| 422 | * | |
| 423 | * <p> | |
| 424 | * If this method is called several times, only the last value is used. | |
| 425 | * | |
| 426 | * @param executor | |
| 427 | * the executor to use | |
| 428 | * @return this instance for fluent chaining | |
| 429 | */ | |
| 430 | public KeepAliveBuilder executor(ScheduledExecutorService executor) { | |
| 431 |
2
1. executor : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::executor → NO_COVERAGE 2. lambda$executor$0 : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::lambda$executor$0 → NO_COVERAGE |
return executor(() -> executor); |
| 432 | } | |
| 433 | ||
| 434 | /** | |
| 435 | * The maximum number of consecutive timeouts to {@link EnquireLink} | |
| 436 | * requests to consider that a new session is required. | |
| 437 | * | |
| 438 | * <p> | |
| 439 | * The value set using this method takes precedence over any property and | |
| 440 | * default value configured using {@link #maxConsecutiveTimeouts()}. | |
| 441 | * | |
| 442 | * <pre> | |
| 443 | * .maxConsecutiveTimeouts(5) | |
| 444 | * .maxConsecutiveTimeouts() | |
| 445 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
| 446 | * .defaultValue(3) | |
| 447 | * </pre> | |
| 448 | * | |
| 449 | * <pre> | |
| 450 | * .maxConsecutiveTimeouts(5) | |
| 451 | * .maxConsecutiveTimeouts() | |
| 452 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
| 453 | * .defaultValue(3) | |
| 454 | * </pre> | |
| 455 | * | |
| 456 | * In both cases, {@code maxConsecutiveTimeouts(5)} is used. | |
| 457 | * | |
| 458 | * <p> | |
| 459 | * If this method is called several times, only the last value is used. | |
| 460 | * | |
| 461 | * <p> | |
| 462 | * If {@code null} value is set, it is like not setting a value at all. The | |
| 463 | * property/default value configuration is applied. | |
| 464 | * | |
| 465 | * @param max | |
| 466 | * the maximum consecutive timeouts | |
| 467 | * @return this instance for fluent chaining | |
| 468 | */ | |
| 469 | public KeepAliveBuilder maxConsecutiveTimeouts(Integer max) { | |
| 470 |
2
1. maxConsecutiveTimeouts : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → NO_COVERAGE 2. maxConsecutiveTimeouts : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → KILLED |
maxConsecutiveTimeoutsValueBuilder.setValue(max); |
| 471 |
2
1. maxConsecutiveTimeouts : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::maxConsecutiveTimeouts → NO_COVERAGE 2. maxConsecutiveTimeouts : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::maxConsecutiveTimeouts → KILLED |
return this; |
| 472 | } | |
| 473 | ||
| 474 | /** | |
| 475 | * The maximum number of consecutive timeouts to {@link EnquireLink} | |
| 476 | * requests to consider that a new session is required. | |
| 477 | * | |
| 478 | * <p> | |
| 479 | * This method is mainly used by {@link Configurer}s to register some | |
| 480 | * property keys and/or a default value. The aim is to let developer be able | |
| 481 | * to externalize its configuration (using system properties, configuration | |
| 482 | * file or anything else). If the developer doesn't configure any value for | |
| 483 | * the registered properties, the default value is used (if set). | |
| 484 | * | |
| 485 | * <pre> | |
| 486 | * .maxConsecutiveTimeouts() | |
| 487 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
| 488 | * .defaultValue(3) | |
| 489 | * </pre> | |
| 490 | * | |
| 491 | * <p> | |
| 492 | * Non-null value set using {@link #maxConsecutiveTimeouts(Integer)} takes | |
| 493 | * precedence over property values and default value. | |
| 494 | * | |
| 495 | * <pre> | |
| 496 | * .maxConsecutiveTimeouts(5) | |
| 497 | * .maxConsecutiveTimeouts() | |
| 498 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
| 499 | * .defaultValue(3) | |
| 500 | * </pre> | |
| 501 | * | |
| 502 | * The value {@code 5} is used regardless of the value of the properties and | |
| 503 | * default value. | |
| 504 | * | |
| 505 | * <p> | |
| 506 | * See {@link ConfigurationValueBuilder} for more information. | |
| 507 | * | |
| 508 | * | |
| 509 | * @return the builder to configure property keys/default value | |
| 510 | */ | |
| 511 | public ConfigurationValueBuilder<KeepAliveBuilder, Integer> maxConsecutiveTimeouts() { | |
| 512 |
5
1. maxConsecutiveTimeouts : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::maxConsecutiveTimeouts → KILLED 2. maxConsecutiveTimeouts : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::maxConsecutiveTimeouts → KILLED 3. maxConsecutiveTimeouts : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::maxConsecutiveTimeouts → KILLED 4. maxConsecutiveTimeouts : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::maxConsecutiveTimeouts → KILLED 5. maxConsecutiveTimeouts : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::maxConsecutiveTimeouts → KILLED |
return maxConsecutiveTimeoutsValueBuilder; |
| 513 | } | |
| 514 | ||
| 515 | @Override | |
| 516 | public KeepAliveOptions build() { | |
| 517 | KeepAliveOptions keepAliveOptions = new KeepAliveOptions(); | |
| 518 |
2
1. build : removed call to fr/sii/ogham/sms/sender/impl/cloudhopper/KeepAliveOptions::setEnable → SURVIVED 2. build : removed call to fr/sii/ogham/sms/sender/impl/cloudhopper/KeepAliveOptions::setEnable → TIMED_OUT |
keepAliveOptions.setEnable(enableValueBuilder.getValue()); |
| 519 |
2
1. build : removed call to fr/sii/ogham/sms/sender/impl/cloudhopper/KeepAliveOptions::setEnquireLinkInterval → SURVIVED 2. build : removed call to fr/sii/ogham/sms/sender/impl/cloudhopper/KeepAliveOptions::setEnquireLinkInterval → KILLED |
keepAliveOptions.setEnquireLinkInterval(enquireLinkIntervalValueBuilder.getValue()); |
| 520 |
2
1. build : removed call to fr/sii/ogham/sms/sender/impl/cloudhopper/KeepAliveOptions::setEnquireLinkTimeout → SURVIVED 2. build : removed call to fr/sii/ogham/sms/sender/impl/cloudhopper/KeepAliveOptions::setEnquireLinkTimeout → KILLED |
keepAliveOptions.setEnquireLinkTimeout(enquireLinkTimeoutValueBuilder.getValue()); |
| 521 |
2
1. build : removed call to fr/sii/ogham/sms/sender/impl/cloudhopper/KeepAliveOptions::setConnectAtStartup → SURVIVED 2. build : removed call to fr/sii/ogham/sms/sender/impl/cloudhopper/KeepAliveOptions::setConnectAtStartup → KILLED |
keepAliveOptions.setConnectAtStartup(connectAtStartupValueBuilder.getValue()); |
| 522 |
4
1. build : negated conditional → SURVIVED 2. build : removed call to fr/sii/ogham/sms/sender/impl/cloudhopper/KeepAliveOptions::setExecutor → SURVIVED 3. build : negated conditional → KILLED 4. build : removed call to fr/sii/ogham/sms/sender/impl/cloudhopper/KeepAliveOptions::setExecutor → KILLED |
keepAliveOptions.setExecutor(executorFactory != null ? executorFactory : defaultEnquireLinkTimerFactory()); |
| 523 |
2
1. build : removed call to fr/sii/ogham/sms/sender/impl/cloudhopper/KeepAliveOptions::setMaxConsecutiveTimeouts → SURVIVED 2. build : removed call to fr/sii/ogham/sms/sender/impl/cloudhopper/KeepAliveOptions::setMaxConsecutiveTimeouts → KILLED |
keepAliveOptions.setMaxConsecutiveTimeouts(maxConsecutiveTimeoutsValueBuilder.getValue()); |
| 524 |
2
1. build : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::build → SURVIVED 2. build : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::build → TIMED_OUT |
return keepAliveOptions; |
| 525 | } | |
| 526 | ||
| 527 | /** | |
| 528 | * Default factory that provides a {@link ScheduledExecutorService} | |
| 529 | * executor. As only one thread is needed (only one task) to regularly send | |
| 530 | * {@link EnquireLink}s, it uses | |
| 531 | * {@link Executors#newSingleThreadScheduledExecutor(ThreadFactory)}. | |
| 532 | * | |
| 533 | * <p> | |
| 534 | * The thread is named {@code EnquireLink-<generated number>}. | |
| 535 | * | |
| 536 | * @return the factory | |
| 537 | */ | |
| 538 | public static Supplier<ScheduledExecutorService> defaultEnquireLinkTimerFactory() { | |
| 539 |
2
1. defaultEnquireLinkTimerFactory : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::defaultEnquireLinkTimerFactory → SURVIVED 2. lambda$defaultEnquireLinkTimerFactory$1 : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::lambda$defaultEnquireLinkTimerFactory$1 → NO_COVERAGE |
return () -> Executors.newSingleThreadScheduledExecutor(KeepAliveBuilder::newThread); |
| 540 | } | |
| 541 | ||
| 542 | private static Thread newThread(Runnable runnable) { | |
| 543 | Thread thread = new Thread(runnable); | |
| 544 |
1
1. newThread : removed call to java/lang/Thread::setName → NO_COVERAGE |
thread.setName("EnquireLink-" + enquireLinkThreadCounter.incrementAndGet()); |
| 545 |
1
1. newThread : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/KeepAliveBuilder::newThread → NO_COVERAGE |
return thread; |
| 546 | } | |
| 547 | } | |
Mutations | ||
| 92 |
1.1 2.2 |
|
| 93 |
1.1 2.2 |
|
| 134 |
1.1 2.2 3.3 4.4 5.5 |
|
| 174 |
1.1 2.2 |
|
| 175 |
1.1 2.2 |
|
| 216 |
1.1 2.2 3.3 4.4 5.5 |
|
| 255 |
1.1 2.2 |
|
| 256 |
1.1 2.2 |
|
| 297 |
1.1 2.2 3.3 4.4 5.5 |
|
| 341 |
1.1 2.2 |
|
| 342 |
1.1 2.2 |
|
| 388 |
1.1 2.2 3.3 4.4 5.5 |
|
| 413 |
1.1 2.2 |
|
| 431 |
1.1 2.2 |
|
| 470 |
1.1 2.2 |
|
| 471 |
1.1 2.2 |
|
| 512 |
1.1 2.2 3.3 4.4 5.5 |
|
| 518 |
1.1 2.2 |
|
| 519 |
1.1 2.2 |
|
| 520 |
1.1 2.2 |
|
| 521 |
1.1 2.2 |
|
| 522 |
1.1 2.2 3.3 4.4 |
|
| 523 |
1.1 2.2 |
|
| 524 |
1.1 2.2 |
|
| 539 |
1.1 2.2 |
|
| 544 |
1.1 |
|
| 545 |
1.1 |