1 | package fr.sii.ogham.core.builder; | |
2 | ||
3 | import static java.util.Arrays.asList; | |
4 | ||
5 | import java.io.InputStream; | |
6 | import java.nio.file.Files; | |
7 | import java.util.ArrayList; | |
8 | import java.util.EnumMap; | |
9 | import java.util.List; | |
10 | import java.util.Map; | |
11 | import java.util.Properties; | |
12 | import java.util.Set; | |
13 | import java.util.function.Supplier; | |
14 | ||
15 | import javax.activation.MimetypesFileTypeMap; | |
16 | ||
17 | import org.reflections.Reflections; | |
18 | import org.reflections.scanners.SubTypesScanner; | |
19 | import org.slf4j.Logger; | |
20 | import org.slf4j.LoggerFactory; | |
21 | ||
22 | import fr.sii.ogham.core.builder.configuration.ConfigurationValueBuilder; | |
23 | import fr.sii.ogham.core.builder.configuration.ConfigurationValueBuilderHelper; | |
24 | import fr.sii.ogham.core.builder.configurer.ConfigurationPhase; | |
25 | import fr.sii.ogham.core.builder.configurer.Configurer; | |
26 | import fr.sii.ogham.core.builder.configurer.ConfigurerFor; | |
27 | import fr.sii.ogham.core.builder.configurer.MessagingConfigurer; | |
28 | import fr.sii.ogham.core.builder.context.BuildContext; | |
29 | import fr.sii.ogham.core.builder.context.EnvBuilderBasedContext; | |
30 | import fr.sii.ogham.core.builder.env.EnvironmentBuilder; | |
31 | import fr.sii.ogham.core.builder.env.SimpleEnvironmentBuilder; | |
32 | import fr.sii.ogham.core.builder.mimetype.MimetypeDetectionBuilder; | |
33 | import fr.sii.ogham.core.builder.mimetype.SimpleMimetypeDetectionBuilder; | |
34 | import fr.sii.ogham.core.builder.registry.CleanableRegistry; | |
35 | import fr.sii.ogham.core.builder.registry.Registry; | |
36 | import fr.sii.ogham.core.builder.resolution.ResourceResolutionBuilder; | |
37 | import fr.sii.ogham.core.builder.resolution.StandaloneResourceResolutionBuilder; | |
38 | import fr.sii.ogham.core.clean.Cleanable; | |
39 | import fr.sii.ogham.core.exception.MessagingException; | |
40 | import fr.sii.ogham.core.exception.builder.BuildException; | |
41 | import fr.sii.ogham.core.sender.ConditionalSender; | |
42 | import fr.sii.ogham.core.service.CleanableMessagingService; | |
43 | import fr.sii.ogham.core.service.EverySupportingMessagingService; | |
44 | import fr.sii.ogham.core.service.MessagingService; | |
45 | import fr.sii.ogham.core.service.WrapExceptionMessagingService; | |
46 | import fr.sii.ogham.core.util.PriorizedList; | |
47 | import fr.sii.ogham.email.builder.EmailBuilder; | |
48 | import fr.sii.ogham.email.message.Email; | |
49 | import fr.sii.ogham.sms.builder.SmsBuilder; | |
50 | import fr.sii.ogham.sms.message.Sms; | |
51 | ||
52 | /** | |
53 | * Ogham provides many useful behaviors to focus on the message content and not | |
54 | * the need of understanding and implementing complex protocols. Sending emails | |
55 | * seems to be easy but the RFCs | |
56 | * (<a href="https://tools.ietf.org/html/rfc5321">RFC5321</a>, | |
57 | * <a href="https://tools.ietf.org/html/rfc821">RFC821</a>, ...) are long and | |
58 | * complex. If you don't know those RFCs, some email clients won't be able to | |
59 | * read your emails. This is the same with the | |
60 | * <a href="http://opensmpp.org/specs/smppv50.pdf">SMPP protocol</a> used for | |
61 | * sending SMS. | |
62 | * | |
63 | * The builder is a helper to instantiate and configure a | |
64 | * {@link MessagingService}. The {@link MessagingService} is used to send: | |
65 | * <ul> | |
66 | * <li>{@link Email} messages</li> | |
67 | * <li>{@link Sms} messages</li> | |
68 | * </ul> | |
69 | * | |
70 | * Content of the messages can be provided by templates. Templates are parsed by | |
71 | * template engines. Several template engines are supported: | |
72 | * <ul> | |
73 | * <li>Thymeleaf</li> | |
74 | * <li>Freemaker</li> | |
75 | * </ul> | |
76 | * | |
77 | * Ogham allows to send {@link Email} and {@link Sms} using several | |
78 | * implementations: | |
79 | * <ul> | |
80 | * <li>JavaMail (STMP) or SendGrid (HTTP) for sending {@link Email}</li> | |
81 | * <li>Cloudhopper (SMPP) or OVH (HTTP) for sending {@link Sms}</li> | |
82 | * </ul> | |
83 | * The aim is to provide an abstraction to construct a portable message ( | |
84 | * {@link Email} or {@link Sms}) and to be able to change infrastructure (SMTP | |
85 | * server to online HTTP service for example) without changing your code. | |
86 | * | |
87 | * <p> | |
88 | * Here is an example of standard configuration that provides a default behavior | |
89 | * that fits 95% of usages: | |
90 | * | |
91 | * <pre> | |
92 | * <code> | |
93 | * // Instantiate the messaging service | |
94 | * MessagingService service = MessagingBuilder.standard() | |
95 | * .build(); | |
96 | * // send the email | |
97 | * service.send(new Email() | |
98 | * .body().template("email/sample", new SampleBean("foo", 42)) | |
99 | * .to("Foo Bar <foo.bar@sii.fr>")) | |
100 | * .attach().file("file:/data/reports/report1.pdf"); | |
101 | * </code> | |
102 | * </pre> | |
103 | * | |
104 | * This sample shows that: | |
105 | * <ul> | |
106 | * <li>System properties are used to configure "mail.host" and "mail.port"</li> | |
107 | * <li>As properties "mail.host" and "mail.port" are defined and | |
108 | * "ogham-email-javamail" is used, the email is sent using JavaMail | |
109 | * implementation</li> | |
110 | * <li>An email is sent to "foo.bar@sii.fr"</li> | |
111 | * <li>The email provides a main content (HTML) and a fallback content (text) | |
112 | * <ul> | |
113 | * <li>The HTML content comes from a template located in the classpath | |
114 | * (email/sample.html) and variables that are present in the template are | |
115 | * replaced by values provided by a simple bean object (no conversion is | |
116 | * needed). As "ogham-template-thymeleaf" is used and the template is a | |
117 | * Thymeleaf template (Thymeleaf directive on <html> tag), this template | |
118 | * is parsed by Thymeleaf</li> | |
119 | * <li>The text content comes from a template located in the classpath | |
120 | * (email/sample.txt.ftl) and variables that are present in the template are | |
121 | * replaced by values provided by a simple bean object (no conversion is | |
122 | * needed). As "ogham-template-freemarker" is used and the template is a | |
123 | * Freemarker template (".ftl" extension), this template is parsed by | |
124 | * Freemarker</li> | |
125 | * </ul> | |
126 | * </li> | |
127 | * <li>The HTML template has CSS styles that are inlined (CSS are forbidden by | |
128 | * many email clients but inlined styles attributes are allowed)</li> | |
129 | * <li>The HTML template references images (using <img>) that are | |
130 | * automatically attached to the sent email (mimetype of each image has been | |
131 | * detected and indicated to the sent message)</li> | |
132 | * <li>A file located on the filesystem is attached to the email, its mimetype | |
133 | * has been automatically detected and indicated to the sent message</li> | |
134 | * <li>The subject is provided by the <title> tag of the HTML</li> | |
135 | * <li>The sender email address is provided by the system property | |
136 | * "ogham.email.from.default-value"</li> | |
137 | * </ul> | |
138 | * | |
139 | * <p> | |
140 | * Here is an example of minimal configuration that provides same default | |
141 | * behavior as previous exemple but no sender implementation is registered. You | |
142 | * then have to enable implementation(s) and configure them: | |
143 | * | |
144 | * <pre> | |
145 | * <code> | |
146 | * // Instantiate the messaging service | |
147 | * MessagingService service = MessagingBuilder.minimal() | |
148 | * .email() | |
149 | * .sender(JavaMailBuilder.class) | |
150 | * .host().properties("${mail.host}").and() | |
151 | * .port().properties("${mail.port}").and() | |
152 | * .charset().properties("${ogham.email.javamail.body.charset}").defaultValue("UTF-8").and() | |
153 | * .mimetype() | |
154 | * .tika() | |
155 | * .failIfOctetStream(false) | |
156 | * .and() | |
157 | * .and() | |
158 | * .and() | |
159 | * .and() | |
160 | * .build(); | |
161 | * // send the email | |
162 | * service.send(new Email() | |
163 | * .body().template("email/sample", new SampleBean("foo", 42)) | |
164 | * .to("Foo Bar <foo.bar@sii.fr>")) | |
165 | * .attach().file("file:/data/reports/report1.pdf"); | |
166 | * </code> | |
167 | * </pre> | |
168 | * | |
169 | * This sample has the same effect as the previous one (for this case, some | |
170 | * options of JavaMail implementation are not enabled). Moreover, if you want to | |
171 | * send a {@link Sms}, you will also need to register and configure at least one | |
172 | * SMS sender implementation. | |
173 | * | |
174 | * To benefit of all advantages but keeping control on which implementations are | |
175 | * use, you can register implementation configurers: | |
176 | * | |
177 | * <pre> | |
178 | * <code> | |
179 | * // Instantiate the messaging service | |
180 | * MessagingService service = MessagingBuilder.minimal() | |
181 | * .register(new DefaultJavaMailConfigurer(), 50000) // enable sending Email through SMTP | |
182 | * .register(new DefaultSendGridConfigurer(), 30000) // enable sending Email through HTTP (using an online service) | |
183 | * .register(new DefaultCloudHopperConfigurer(), 40000) // enable sending SMS through SMPP | |
184 | * .register(new DefaultOvhSmsConfigurer(), 20000) // enable sending SMS through HTTP (using an online service) | |
185 | * .build(); | |
186 | * // send the email | |
187 | * service.send(new Email() | |
188 | * .body().template("email/sample", new SampleBean("foo", 42)) | |
189 | * .to("Foo Bar <foo.bar@sii.fr>")) | |
190 | * .attach().file("file:/data/reports/report1.pdf"); | |
191 | * </code> | |
192 | * </pre> | |
193 | * | |
194 | * This sample has the same effect as using {@link #standard()}. | |
195 | * | |
196 | * You can create your own configurer for any sender implementation and register | |
197 | * it too. You can then mutualize and externalize reusable configuration. | |
198 | * | |
199 | * <p> | |
200 | * The predefined behaviors are brought by static factory methods | |
201 | * {@link #standard()} and {@link #minimal()}. If you don't want to use | |
202 | * predefined behaviors, you can use directly {@code new MessagingBuilder()} or | |
203 | * {@link #empty()} static factory. | |
204 | * | |
205 | * Those factory methods rely on {@link MessagingConfigurer}s to provide | |
206 | * predefined behaviors. | |
207 | * | |
208 | * <p> | |
209 | * The default behaviors can be used and customized: | |
210 | * | |
211 | * <pre> | |
212 | * <code> | |
213 | * // Instantiate the messaging service | |
214 | * MessagingService service = MessagingBuilder.standard() | |
215 | * .environment() | |
216 | * .properties() | |
217 | * .set("mail.host", "localhost") | |
218 | * .set("mail.port", "25") | |
219 | * .and() | |
220 | * .and() | |
221 | * .mimetype() | |
222 | * .defaultMimetype("application/octet-stream") | |
223 | * .and() | |
224 | * .build(); | |
225 | * // send the email | |
226 | * service.send(new Email() | |
227 | * .body().template("email/sample", new SampleBean("foo", 42)) | |
228 | * .to("Foo Bar <foo.bar@sii.fr>")) | |
229 | * .attach().file("file:/data/reports/report1.pdf"); | |
230 | * </code> | |
231 | * </pre> | |
232 | * | |
233 | * The previous sample shows how to change default behaviors to fit your needs: | |
234 | * <ul> | |
235 | * <li>It set the SMTP host and port in the code not by using system | |
236 | * properties</li> | |
237 | * <li>It overrides default mimetype to provide a mimetype that fit your needs | |
238 | * when mimetype detection is not enough accurate</li> | |
239 | * </ul> | |
240 | * | |
241 | * | |
242 | * <p> | |
243 | * The {@link MessagingService} may open some resources (files, sockets, ...). | |
244 | * The built {@link MessagingService} is wrapped by | |
245 | * {@link CleanableMessagingService}. This way the instantiated service can | |
246 | * clean opened resources either manually (if developer explicitly calls | |
247 | * {@link CleanableMessagingService#clean()}) or automatically (see | |
248 | * {@link CleanableMessagingService} for more information). | |
249 | * | |
250 | * | |
251 | * @author Aurélien Baudet | |
252 | * | |
253 | */ | |
254 | public class MessagingBuilder implements Builder<MessagingService> { | |
255 | private static final Logger LOG = LoggerFactory.getLogger(MessagingBuilder.class); | |
256 | public static final String BASE_PACKAGE = "fr.sii.ogham"; | |
257 | ||
258 | protected final boolean autoconfigure; | |
259 | protected final Map<ConfigurationPhase, Boolean> alreadyConfigured; | |
260 | protected final PriorizedList<ConfigurerWithPhase> configurers; | |
261 | protected final EnvironmentBuilder<MessagingBuilder> environmentBuilder; | |
262 | protected final BuildContext buildContext; | |
263 | protected final Registry<Object> registry; | |
264 | protected final Cleanable cleaner; | |
265 | protected CleanableRegistry cleanableRegistry; | |
266 | protected MimetypeDetectionBuilder<MessagingBuilder> mimetypeBuilder; | |
267 | protected StandaloneResourceResolutionBuilder<MessagingBuilder> resourceBuilder; | |
268 | protected EmailBuilder emailBuilder; | |
269 | protected SmsBuilder smsBuilder; | |
270 | protected final ConfigurationValueBuilderHelper<MessagingBuilder, Boolean> wrapUncaughtValueBuilder; | |
271 | ||
272 | /** | |
273 | * Initializes the builder with minimal requirements: | |
274 | * <ul> | |
275 | * <li>an empty {@link EnvironmentBuilder}</li> | |
276 | * <li>an empty {@link MimetypeDetectionBuilder}</li> | |
277 | * <li>an empty {@link ResourceResolutionBuilder}</li> | |
278 | * </ul> | |
279 | * | |
280 | * | |
281 | * <p> | |
282 | * If {@code autoconfigure} parameter is true, it applies all registered | |
283 | * configurers on this builder instance. | |
284 | * | |
285 | * When using {@link #standard()} and {@link #minimal()} factory methods, | |
286 | * {@code autoconfigure} parameter is set to true. | |
287 | * | |
288 | * | |
289 | * @param autoconfigure | |
290 | * Trigger configuration automatically if true (for all phases). | |
291 | * If false, you have to call | |
292 | * {@link #configure(ConfigurationPhase)} manually. | |
293 | */ | |
294 | public MessagingBuilder(boolean autoconfigure) { | |
295 | super(); | |
296 | this.autoconfigure = autoconfigure; | |
297 | alreadyConfigured = new EnumMap<>(ConfigurationPhase.class); | |
298 | configurers = new PriorizedList<>(); | |
299 | environmentBuilder = createEnvironmentBuilder(); | |
300 | registry = createRegistry(); | |
301 | cleaner = createCleanable(); | |
302 | buildContext = createBuildContext(); | |
303 | mimetypeBuilder = createMimetypeBuilder(); | |
304 | resourceBuilder = createResourceResolutionBuilder(); | |
305 | wrapUncaughtValueBuilder = buildContext.newConfigurationValueBuilder(this, Boolean.class); | |
306 | } | |
307 | ||
308 | /** | |
309 | * Registers a configurer with a priority. Configuration order may be | |
310 | * important. The priority is used to apply configurers in order. The | |
311 | * configurer with highest priority (applied first) has the greatest value. | |
312 | * | |
313 | * The configurer is applied on a this builder instance to configure it | |
314 | * (when {@link #configure(ConfigurationPhase)} is called). | |
315 | * | |
316 | * <p> | |
317 | * When using {@link #standard()} and {@link #minimal()} factory methods, | |
318 | * the list of configurers are automatically loaded from the classpath and | |
319 | * registered. The priority is indicated through the {@link ConfigurerFor} | |
320 | * annotation. | |
321 | * | |
322 | * <p> | |
323 | * The registered configurer will be executed at | |
324 | * {@link ConfigurationPhase#BEFORE_BUILD} phase. | |
325 | * | |
326 | * | |
327 | * @param configurer | |
328 | * the configurer to register | |
329 | * @param priority | |
330 | * the configurer priority | |
331 | * @return this instance for fluent chaining | |
332 | */ | |
333 | public MessagingBuilder register(MessagingConfigurer configurer, int priority) { | |
334 |
2
1. register : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::register → NO_COVERAGE 2. register : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::register → SURVIVED |
return register(configurer, priority, ConfigurationPhase.BEFORE_BUILD); |
335 | } | |
336 | ||
337 | /** | |
338 | * Registers a configurer with a priority. Configuration order may be | |
339 | * important. The priority is used to apply configurers in order. The | |
340 | * configurer with highest priority (applied first) has the greatest value. | |
341 | * | |
342 | * The configurer is applied on a this builder instance to configure it | |
343 | * (when {@link #configure(ConfigurationPhase)} is called). | |
344 | * | |
345 | * <p> | |
346 | * When using {@link #standard()} and {@link #minimal()} factory methods, | |
347 | * the list of configurers are automatically loaded from the classpath and | |
348 | * registered. The priority is indicated through the {@link ConfigurerFor} | |
349 | * annotation. | |
350 | * | |
351 | * | |
352 | * @param configurer | |
353 | * the configurer to register | |
354 | * @param priority | |
355 | * the configurer priority | |
356 | * @param phase | |
357 | * register the configurer to be executed at the defined the | |
358 | * configuration phase | |
359 | * @return this instance for fluent chaining | |
360 | */ | |
361 | public MessagingBuilder register(MessagingConfigurer configurer, int priority, ConfigurationPhase phase) { | |
362 | LOG.debug("[{}] registered for phase {} with priority={}", configurer, phase, priority); | |
363 | configurers.register(new ConfigurerWithPhase(configurer, phase), priority); | |
364 |
2
1. register : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::register → NO_COVERAGE 2. register : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::register → SURVIVED |
return this; |
365 | } | |
366 | ||
367 | /** | |
368 | * Apply all registered configurers on this builder instance for the | |
369 | * {@link ConfigurationPhase}. | |
370 | * | |
371 | * <p> | |
372 | * When using {@link #standard()} and {@link #minimal()} factory methods, | |
373 | * this method is automatically called. | |
374 | * | |
375 | * @param phase | |
376 | * the configuration phase | |
377 | */ | |
378 | public void configure(ConfigurationPhase phase) { | |
379 |
8
1. configure : negated conditional → NO_COVERAGE 2. configure : negated conditional → KILLED 3. configure : negated conditional → KILLED 4. configure : negated conditional → KILLED 5. configure : negated conditional → KILLED 6. configure : negated conditional → KILLED 7. configure : negated conditional → KILLED 8. configure : negated conditional → KILLED |
if (alreadyConfigured(phase)) { |
380 | return; | |
381 | } | |
382 | for (ConfigurerWithPhase configurerWithPhase : configurers.getOrdered()) { | |
383 |
4
1. configure : negated conditional → SURVIVED 2. configure : negated conditional → NO_COVERAGE 3. configure : negated conditional → KILLED 4. configure : negated conditional → KILLED |
if (phase == configurerWithPhase.getPhase()) { |
384 | LOG.debug("[{}] configuring for phase {}...", configurerWithPhase.getConfigurer(), phase); | |
385 |
8
1. configure : removed call to fr/sii/ogham/core/builder/configurer/MessagingConfigurer::configure → NO_COVERAGE 2. configure : removed call to fr/sii/ogham/core/builder/configurer/MessagingConfigurer::configure → TIMED_OUT 3. configure : removed call to fr/sii/ogham/core/builder/configurer/MessagingConfigurer::configure → KILLED 4. configure : removed call to fr/sii/ogham/core/builder/configurer/MessagingConfigurer::configure → KILLED 5. configure : removed call to fr/sii/ogham/core/builder/configurer/MessagingConfigurer::configure → KILLED 6. configure : removed call to fr/sii/ogham/core/builder/configurer/MessagingConfigurer::configure → KILLED 7. configure : removed call to fr/sii/ogham/core/builder/configurer/MessagingConfigurer::configure → KILLED 8. configure : removed call to fr/sii/ogham/core/builder/configurer/MessagingConfigurer::configure → KILLED |
configurerWithPhase.getConfigurer().configure(this); |
386 | } | |
387 | } | |
388 | alreadyConfigured.put(phase, true); | |
389 | } | |
390 | ||
391 | /** | |
392 | * Configures environment for the builder (and sub-builders if inherited). | |
393 | * Environment consists of configuration properties/values that are used to | |
394 | * configure the system (see {@link EnvironmentBuilder} for more | |
395 | * information). | |
396 | * | |
397 | * You can use system properties: | |
398 | * | |
399 | * <pre> | |
400 | * .environment() | |
401 | * .systemProperties(); | |
402 | * </pre> | |
403 | * | |
404 | * Or, you can load properties from a file: | |
405 | * | |
406 | * <pre> | |
407 | * .environment() | |
408 | * .properties("/path/to/file.properties") | |
409 | * </pre> | |
410 | * | |
411 | * Or using directly a {@link Properties} object: | |
412 | * | |
413 | * <pre> | |
414 | * Properties myprops = new Properties(); | |
415 | * myprops.setProperty("foo", "bar"); | |
416 | * .environment() | |
417 | * .properties(myprops) | |
418 | * </pre> | |
419 | * | |
420 | * Or defining directly properties: | |
421 | * | |
422 | * <pre> | |
423 | * .environment() | |
424 | * .properties() | |
425 | * .set("foo", "bar") | |
426 | * </pre> | |
427 | * | |
428 | * | |
429 | * <p> | |
430 | * Every time you are configuring {@link #environment()}, you update the | |
431 | * same instance. | |
432 | * </p> | |
433 | * | |
434 | * @return the builder to configure properties handling | |
435 | */ | |
436 | public EnvironmentBuilder<MessagingBuilder> environment() { | |
437 |
8
1. environment : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::environment → NO_COVERAGE 2. environment : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::environment → KILLED 3. environment : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::environment → KILLED 4. environment : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::environment → KILLED 5. environment : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::environment → KILLED 6. environment : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::environment → KILLED 7. environment : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::environment → KILLED 8. environment : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::environment → KILLED |
return environmentBuilder; |
438 | } | |
439 | ||
440 | /** | |
441 | * Cconfigures resource resolution. | |
442 | * | |
443 | * <p> | |
444 | * Resource resolution consists of finding a file: | |
445 | * <ul> | |
446 | * <li>either on filesystem</li> | |
447 | * <li>or in the classpath</li> | |
448 | * <li>or anywhere else</li> | |
449 | * </ul> | |
450 | * | |
451 | * <p> | |
452 | * To identify which resolution to use, each resolution is configured to | |
453 | * handle one or several lookups prefixes. For example, if resolution is | |
454 | * configured like this: | |
455 | * | |
456 | * <pre> | |
457 | * <code> | |
458 | * .string() | |
459 | * .lookup("string:", "s:") | |
460 | * .and() | |
461 | * .file() | |
462 | * .lookup("file:") | |
463 | * .and() | |
464 | * .classpath() | |
465 | * .lookup("classpath:", ""); | |
466 | * </code> | |
467 | * </pre> | |
468 | * | |
469 | * Then you can reference a file that is in the classpath like this: | |
470 | * | |
471 | * <pre> | |
472 | * "classpath:foo/bar.html" | |
473 | * </pre> | |
474 | * | |
475 | * | |
476 | * <p> | |
477 | * Resource resolution is also able to handle path prefix and suffix. The | |
478 | * aim is for example to have a folder that contains all templates. The | |
479 | * developer then configures a path prefix for the folder. He can also | |
480 | * configure a suffix to fix extension for templates. Thanks to those | |
481 | * prefix/suffix, templates can now be referenced by the name of the file | |
482 | * (without extension). It is useful to reference a template independently | |
483 | * from where it is in reality (classpath, file or anywhere else) . | |
484 | * Switching from classpath to file and conversely can be done easily (by | |
485 | * updating the lookup). | |
486 | * | |
487 | * For example: | |
488 | * | |
489 | * <pre> | |
490 | * .classpath().lookup("classpath:").pathPrefix("foo/").pathSuffix(".html"); | |
491 | * | |
492 | * resourceResolver.getResource("classpath:bar"); | |
493 | * </pre> | |
494 | * | |
495 | * The real path is then {@code foo/bar.html}. | |
496 | * | |
497 | * <p> | |
498 | * This implementation is used by {@link MessagingBuilder} for general | |
499 | * configuration. That configuration may be inherited (applied to other | |
500 | * resource resolution builders). | |
501 | * | |
502 | * @return the builder to configure resource resolution | |
503 | */ | |
504 | public StandaloneResourceResolutionBuilder<MessagingBuilder> resource() { | |
505 |
8
1. resource : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::resource → NO_COVERAGE 2. resource : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::resource → KILLED 3. resource : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::resource → KILLED 4. resource : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::resource → KILLED 5. resource : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::resource → KILLED 6. resource : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::resource → KILLED 7. resource : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::resource → KILLED 8. resource : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::resource → KILLED |
return resourceBuilder; |
506 | } | |
507 | ||
508 | /** | |
509 | * Builder that configures mimetype detection. | |
510 | * | |
511 | * There exists several implementations to provide the mimetype: | |
512 | * <ul> | |
513 | * <li>Using Java {@link MimetypesFileTypeMap}</li> | |
514 | * <li>Using Java 7 {@link Files#probeContentType(java.nio.file.Path)}</li> | |
515 | * <li>Using <a href="http://tika.apache.org/">Apache Tika</a></li> | |
516 | * <li>Using | |
517 | * <a href="https://github.com/arimus/jmimemagic">JMimeMagic</a></li> | |
518 | * </ul> | |
519 | * | |
520 | * <p> | |
521 | * Both implementations provided by Java are based on file extensions. This | |
522 | * can't be used in most cases as we often handle {@link InputStream}s. | |
523 | * </p> | |
524 | * | |
525 | * <p> | |
526 | * In previous version of Ogham, JMimeMagic was used and was working quite | |
527 | * well. Unfortunately, the library is no more maintained. | |
528 | * </p> | |
529 | * | |
530 | * <p> | |
531 | * You can configure how Tika will detect mimetype: | |
532 | * | |
533 | * <pre> | |
534 | * .mimetype() | |
535 | * .tika() | |
536 | * ... | |
537 | * </pre> | |
538 | * | |
539 | * <p> | |
540 | * This builder allows to use several providers. It will chain them until | |
541 | * one can find a valid mimetype. If none is found, you can explicitly | |
542 | * provide the default one: | |
543 | * | |
544 | * <pre> | |
545 | * .mimetype() | |
546 | * .defaultMimetype("text/html") | |
547 | * </pre> | |
548 | * | |
549 | * <p> | |
550 | * Every time you are configuring {@link #mimetype()}, the same instance is | |
551 | * used. | |
552 | * </p> | |
553 | * | |
554 | * @return the builder to configure mimetype detection | |
555 | */ | |
556 | public MimetypeDetectionBuilder<MessagingBuilder> mimetype() { | |
557 |
8
1. mimetype : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::mimetype → NO_COVERAGE 2. mimetype : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::mimetype → KILLED 3. mimetype : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::mimetype → KILLED 4. mimetype : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::mimetype → KILLED 5. mimetype : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::mimetype → KILLED 6. mimetype : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::mimetype → KILLED 7. mimetype : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::mimetype → KILLED 8. mimetype : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::mimetype → KILLED |
return mimetypeBuilder; |
558 | } | |
559 | ||
560 | /** | |
561 | * There are technical exceptions that are thrown by libraries used by | |
562 | * Ogham. Those exceptions are often {@link RuntimeException}s. It can be | |
563 | * difficult for developers of a big application to quickly identify what | |
564 | * caused this {@link RuntimeException}. The stack trace doesn't always help | |
565 | * to find the real source of the error. If enables, this option ensures | |
566 | * that work done by Ogham will always throw a {@link MessagingException} | |
567 | * even if it was a {@link RuntimeException} thrown by any component. It | |
568 | * then helps the developer to know that the error comes from Ogham or a any | |
569 | * used library and not something else in its application. The other benefit | |
570 | * is that in your code you only catch a {@link MessagingException} and you | |
571 | * are sure that it will handle all cases, no surprise with an unchecked | |
572 | * exception that could make a big failure in your system because you didn't | |
573 | * know this could happen. Sending a message is often not critical (if | |
574 | * message can't be sent now, it can be sent later or manually). It it fails | |
575 | * the whole system must keep on working. With this option enabled, your | |
576 | * system will never fail due to an unchecked exception and you can handle | |
577 | * the failure the same way as with checked exceptions. | |
578 | * | |
579 | * Concretely, call of | |
580 | * {@link MessagingService#send(fr.sii.ogham.core.message.Message)} catches | |
581 | * all exceptions including {@link RuntimeException}. It wraps any | |
582 | * exceptions into a {@link MessagingException}. | |
583 | * | |
584 | * | |
585 | * <p> | |
586 | * The value set using this method takes precedence over any property and | |
587 | * default value configured using {@link #wrapUncaught()}. | |
588 | * | |
589 | * <pre> | |
590 | * .wrapUncaught(false) | |
591 | * .wrapUncaught() | |
592 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
593 | * .defaultValue(true) | |
594 | * </pre> | |
595 | * | |
596 | * <pre> | |
597 | * .wrapUncaught(false) | |
598 | * .wrapUncaught() | |
599 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
600 | * .defaultValue(true) | |
601 | * </pre> | |
602 | * | |
603 | * In both cases, {@code wrapUncaught(false)} is used. | |
604 | * | |
605 | * <p> | |
606 | * If this method is called several times, only the last value is used. | |
607 | * | |
608 | * <p> | |
609 | * If {@code null} value is set, it is like not setting a value at all. The | |
610 | * property/default value configuration is applied. | |
611 | * | |
612 | * @param enable | |
613 | * enable or disable catching of unchecked exceptions | |
614 | * @return this instance for fluent chaining | |
615 | */ | |
616 | public MessagingBuilder wrapUncaught(Boolean enable) { | |
617 |
1
1. wrapUncaught : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → NO_COVERAGE |
wrapUncaughtValueBuilder.setValue(enable); |
618 |
1
1. wrapUncaught : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::wrapUncaught → NO_COVERAGE |
return this; |
619 | } | |
620 | ||
621 | /** | |
622 | * There are technical exceptions that are thrown by libraries used by | |
623 | * Ogham. Those exceptions are often {@link RuntimeException}s. It can be | |
624 | * difficult for developers of a big application to quickly identify what | |
625 | * caused this {@link RuntimeException}. The stack trace doesn't always help | |
626 | * to find the real source of the error. If enables, this option ensures | |
627 | * that work done by Ogham will always throw a {@link MessagingException} | |
628 | * even if it was a {@link RuntimeException} thrown by any component. It | |
629 | * then helps the developer to know that the error comes from Ogham or a any | |
630 | * used library and not something else in its application. The other benefit | |
631 | * is that in your code you only catch a {@link MessagingException} and you | |
632 | * are sure that it will handle all cases, no surprise with an unchecked | |
633 | * exception that could make a big failure in your system because you didn't | |
634 | * know this could happen. Sending a message is often not critical (if | |
635 | * message can't be sent now, it can be sent later or manually). It it fails | |
636 | * the whole system must keep on working. With this option enabled, your | |
637 | * system will never fail due to an unchecked exception and you can handle | |
638 | * the failure the same way as with checked exceptions. | |
639 | * | |
640 | * Concretely, call of | |
641 | * {@link MessagingService#send(fr.sii.ogham.core.message.Message)} catches | |
642 | * all exceptions including {@link RuntimeException}. It wraps any | |
643 | * exceptions into a {@link MessagingException}. | |
644 | * | |
645 | * | |
646 | * <p> | |
647 | * This method is mainly used by {@link Configurer}s to register some | |
648 | * property keys and/or a default value. The aim is to let developer be able | |
649 | * to externalize its configuration (using system properties, configuration | |
650 | * file or anything else). If the developer doesn't configure any value for | |
651 | * the registered properties, the default value is used (if set). | |
652 | * | |
653 | * <pre> | |
654 | * .wrapUncaught() | |
655 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
656 | * .defaultValue(true) | |
657 | * </pre> | |
658 | * | |
659 | * <p> | |
660 | * Non-null value set using {@link #wrapUncaught(Boolean)} takes precedence | |
661 | * over property values and default value. | |
662 | * | |
663 | * <pre> | |
664 | * .wrapUncaught(false) | |
665 | * .wrapUncaught() | |
666 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
667 | * .defaultValue(true) | |
668 | * </pre> | |
669 | * | |
670 | * The value {@code false} is used regardless of the value of the properties | |
671 | * and default value. | |
672 | * | |
673 | * <p> | |
674 | * See {@link ConfigurationValueBuilder} for more information. | |
675 | * | |
676 | * | |
677 | * @return the builder to configure property keys/default value | |
678 | */ | |
679 | public ConfigurationValueBuilder<MessagingBuilder, Boolean> wrapUncaught() { | |
680 |
8
1. wrapUncaught : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::wrapUncaught → NO_COVERAGE 2. wrapUncaught : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::wrapUncaught → KILLED 3. wrapUncaught : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::wrapUncaught → KILLED 4. wrapUncaught : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::wrapUncaught → KILLED 5. wrapUncaught : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::wrapUncaught → KILLED 6. wrapUncaught : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::wrapUncaught → KILLED 7. wrapUncaught : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::wrapUncaught → KILLED 8. wrapUncaught : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::wrapUncaught → KILLED |
return wrapUncaughtValueBuilder; |
681 | } | |
682 | ||
683 | /** | |
684 | * Configures how to send {@link Email} messages. It allows to: | |
685 | * <ul> | |
686 | * <li>register and configure several sender implementations</li> | |
687 | * <li>register and configure several template engines for parsing templates | |
688 | * as message content</li> | |
689 | * <li>configure handling of missing {@link Email} information</li> | |
690 | * <li>configure handling of file attachments</li> | |
691 | * <li>configure CSS and image handling for {@link Email}s with an HTML | |
692 | * body</li> | |
693 | * </ul> | |
694 | * | |
695 | * You can send an {@link Email} using the minimal behavior and using | |
696 | * JavaMail implementation: | |
697 | * | |
698 | * <pre> | |
699 | * <code> | |
700 | * // Instantiate the messaging service | |
701 | * MessagingService service = new MessagingBuilder() | |
702 | * .email() | |
703 | * .sender(JavaMailBuilder.class) // enable Email sending using JavaMail | |
704 | * .host("your SMTP server host") | |
705 | * .port("your SMTP server port") | |
706 | * .and() | |
707 | * .and() | |
708 | * .build(); | |
709 | * // send the email | |
710 | * service.send(new Email() | |
711 | * .from("sender email address") | |
712 | * .subject("email subject") | |
713 | * .content("email body") | |
714 | * .to("recipient email address")); | |
715 | * </code> | |
716 | * </pre> | |
717 | * | |
718 | * You can also send an {@link Email} using a template (using Freemarker for | |
719 | * example): | |
720 | * | |
721 | * The Freemarker template ("email/sample.html.ftl"): | |
722 | * | |
723 | * <pre> | |
724 | * <html> | |
725 | * <head> | |
726 | * </head> | |
727 | * <body> | |
728 | * Email content with variables: ${name} ${value} | |
729 | * </body> | |
730 | * </html> | |
731 | * </pre> | |
732 | * | |
733 | * Then you can send the {@link Email} like this: | |
734 | * | |
735 | * <pre> | |
736 | * <code> | |
737 | * // Instantiate the messaging service | |
738 | * MessagingService service = new MessagingBuilder() | |
739 | * .email() | |
740 | * .sender(JavaMailBuilder.class) // enable Email sending using JavaMail | |
741 | * .host("your SMTP server host") | |
742 | * .port("your SMTP server port") | |
743 | * .and() | |
744 | * .and() | |
745 | * .template(FreemarkerEmailBuilder.class) // enable templating using Freemarker | |
746 | * .classpath() | |
747 | * .lookup("classpath:") // search resources/templates in the classpath if a path is prefixed by "classpath:" | |
748 | * .and() | |
749 | * .and() | |
750 | * .build(); | |
751 | * // send the email | |
752 | * service.send(new Email() | |
753 | * .from("sender email address") | |
754 | * .subject("email subject") | |
755 | * .content(new TemplateContent("classpath:email/sample.html.ftl", new SampleBean("foo", 42))) | |
756 | * .to("recipient email address")); | |
757 | * </code> | |
758 | * </pre> | |
759 | * | |
760 | * <p> | |
761 | * Instead of explicitly configures SMTP host and port in your code, it | |
762 | * could be better to externalize the configuration in a properties file for | |
763 | * example (for example a file named "email.properties" in the classpath). | |
764 | * The previous example becomes: | |
765 | * | |
766 | * <pre> | |
767 | * <code> | |
768 | * // Instantiate the messaging service | |
769 | * MessagingService service = new MessagingBuilder() | |
770 | * .environment() | |
771 | * .properties("email.properties") | |
772 | * .and() | |
773 | * .email() | |
774 | * .sender(JavaMailBuilder.class) // enable Email sending using JavaMail | |
775 | * .host().properties("${mail.host}").and() | |
776 | * .port().properties("${mail.port}").and() | |
777 | * .and() | |
778 | * .and() | |
779 | * .template(FreemarkerEmailBuilder.class) // enable templating using Freemarker | |
780 | * .classpath() | |
781 | * .lookup("classpath:") // search resources/templates in the classpath if a path is prefixed by "classpath:" | |
782 | * .and() | |
783 | * .and() | |
784 | * .build(); | |
785 | * // send the email | |
786 | * service.send(new Email() | |
787 | * .from("sender email address") | |
788 | * .subject("email subject") | |
789 | * .content(new TemplateContent("classpath:email/sample.html.ftl", new SampleBean("foo", 42))) | |
790 | * .to("recipient email address")); | |
791 | * </code> | |
792 | * </pre> | |
793 | * | |
794 | * The content of the file "email.properties": | |
795 | * | |
796 | * <pre> | |
797 | * mail.host=your STMP server host | |
798 | * mail.port=your STMP server port | |
799 | * </pre> | |
800 | * | |
801 | * | |
802 | * Some fields of the Email may be automatically filled by a default value | |
803 | * if they are not defined. For example, the sender address could be | |
804 | * configured only once for your application: | |
805 | * | |
806 | * <pre> | |
807 | * <code> | |
808 | * // Instantiate the messaging service | |
809 | * MessagingService service = new MessagingBuilder() | |
810 | * .environment() | |
811 | * .properties("email.properties") | |
812 | * .and() | |
813 | * .email() | |
814 | * .sender(JavaMailBuilder.class) // enable Email sending using JavaMail | |
815 | * .host().properties("${mail.host}").and() | |
816 | * .port().properties("${mail.port}").and() | |
817 | * .and() | |
818 | * .autofill() // enables and configures autofilling | |
819 | * .from() | |
820 | * .defaultValue().properties("${email.sender.address}").and() | |
821 | * .and() | |
822 | * .and() | |
823 | * .template(FreemarkerEmailBuilder.class) // enable templating using Freemarker | |
824 | * .classpath() | |
825 | * .lookup("classpath:") // search resources/templates in the classpath if a path is prefixed by "classpath:" | |
826 | * .and() | |
827 | * .and() | |
828 | * .build(); | |
829 | * // send the email (now the sender address can be omitted) | |
830 | * service.send(new Email() | |
831 | * .subject("email subject") | |
832 | * .content(new TemplateContent("classpath:email/sample.html.ftl", new SampleBean("foo", 42))) | |
833 | * .to("recipient email address")); | |
834 | * </code> | |
835 | * </pre> | |
836 | * | |
837 | * The content of the file "email.properties": | |
838 | * | |
839 | * <pre> | |
840 | * mail.host=your STMP server host | |
841 | * mail.port=your STMP server port | |
842 | * email.sender.address=sender email address | |
843 | * </pre> | |
844 | * | |
845 | * | |
846 | * | |
847 | * Another very useful automatic filling is for providing the email subject: | |
848 | * | |
849 | * <pre> | |
850 | * <code> | |
851 | * // Instantiate the messaging service | |
852 | * MessagingService service = new MessagingBuilder() | |
853 | * .environment() | |
854 | * .properties("email.properties") | |
855 | * .and() | |
856 | * .email() | |
857 | * .sender(JavaMailBuilder.class) // enable Email sending using JavaMail | |
858 | * .host().properties("${mail.host}").and() | |
859 | * .port().properties("${mail.port}").and() | |
860 | * .and() | |
861 | * .autofill() // enables and configures autofilling | |
862 | * .from() | |
863 | * .defaultValue().properties("${email.sender.address}").and() | |
864 | * .and() | |
865 | * .subject() | |
866 | * .htmlTitle(true) // enables use of html title tag as subject | |
867 | * .and() | |
868 | * .template(FreemarkerEmailBuilder.class) // enable templating using Freemarker | |
869 | * .classpath() | |
870 | * .lookup("classpath:") // search resources/templates in the classpath if a path is prefixed by "classpath:" | |
871 | * .and() | |
872 | * .and() | |
873 | * .build(); | |
874 | * // send the email (now the subject can be omitted) | |
875 | * service.send(new Email() | |
876 | * .content(new TemplateContent("classpath:email/sample.html.ftl", new SampleBean("foo", 42))) | |
877 | * .to("recipient email address")); | |
878 | * </code> | |
879 | * </pre> | |
880 | * | |
881 | * Change your template: | |
882 | * | |
883 | * <pre> | |
884 | * <html> | |
885 | * <head> | |
886 | * <title>email subject - ${name}</title> | |
887 | * </head> | |
888 | * <body> | |
889 | * Email content with variables: ${name} ${value} | |
890 | * </body> | |
891 | * </html> | |
892 | * </pre> | |
893 | * | |
894 | * The obvious advantage is that you have a single place to handle email | |
895 | * content (body + subject). There is another benefit: you can also use | |
896 | * variables in the subject. | |
897 | * | |
898 | * | |
899 | * There many other configuration possibilities: | |
900 | * <ul> | |
901 | * <li>for configuring {@link Email}s with HTML content with a text fallback | |
902 | * (useful for smartphones preview of your email for example)</li> | |
903 | * <li>for configuring attachments handling</li> | |
904 | * <li>for configuring image and css handling</li> | |
905 | * </ul> | |
906 | * | |
907 | * <p> | |
908 | * All the previous examples are provided to understand what can be | |
909 | * configured. Hopefully, Ogham provides auto-configuration with a default | |
910 | * behavior that fits 95% of usages. This auto-configuration is provided by | |
911 | * {@link MessagingConfigurer}s. Those configurers are automatically applied | |
912 | * when using predefined {@link MessagingBuilder}s like | |
913 | * {@link MessagingBuilder#minimal()} and | |
914 | * {@link MessagingBuilder#standard()}. | |
915 | * | |
916 | * The previous sample using standard configuration becomes: | |
917 | * | |
918 | * <pre> | |
919 | * <code> | |
920 | * // Instantiate the messaging service | |
921 | * MessagingService service = new MessagingBuilder() | |
922 | * .environment() | |
923 | * .properties("email.properties") | |
924 | * .and() | |
925 | * .build(); | |
926 | * // send the email | |
927 | * service.send(new Email() | |
928 | * .content(new TemplateContent("classpath:email/sample.html.ftl", new SampleBean("foo", 42))) | |
929 | * .to("recipient email address")); | |
930 | * </code> | |
931 | * </pre> | |
932 | * | |
933 | * The new content of the file "email.properties": | |
934 | * | |
935 | * <pre> | |
936 | * mail.host=your STMP server host | |
937 | * mail.port=your STMP server port | |
938 | * ogham.email.from.default-value=sender email address | |
939 | * </pre> | |
940 | * | |
941 | * <p> | |
942 | * You can also use the auto-configuration for benefit from default | |
943 | * behaviors and override some behaviors for your needs: | |
944 | * | |
945 | * <pre> | |
946 | * <code> | |
947 | * // Instantiate the messaging service | |
948 | * MessagingService service = new MessagingBuilder() | |
949 | * .environment() | |
950 | * .properties("email.properties") | |
951 | * .and() | |
952 | * .email() | |
953 | * .autofill() | |
954 | * .from() | |
955 | * .defaultValue().properties("${email.sender.address}").and() // overrides default sender email address property | |
956 | * .and() | |
957 | * .and() | |
958 | * .and() | |
959 | * .build(); | |
960 | * // send the email | |
961 | * service.send(new Email() | |
962 | * .content(new TemplateContent("classpath:email/sample.html.ftl", new SampleBean("foo", 42))) | |
963 | * .to("recipient email address")); | |
964 | * </code> | |
965 | * </pre> | |
966 | * | |
967 | * The new content of the file "email.properties": | |
968 | * | |
969 | * <pre> | |
970 | * mail.host=your STMP server host | |
971 | * mail.port=your STMP server port | |
972 | * email.sender.address=sender email address | |
973 | * </pre> | |
974 | * | |
975 | * | |
976 | * @return the builder to configure how Email are handled | |
977 | */ | |
978 | public EmailBuilder email() { | |
979 |
8
1. email : negated conditional → NO_COVERAGE 2. email : negated conditional → KILLED 3. email : negated conditional → KILLED 4. email : negated conditional → KILLED 5. email : negated conditional → KILLED 6. email : negated conditional → KILLED 7. email : negated conditional → KILLED 8. email : negated conditional → KILLED |
if (emailBuilder == null) { |
980 | emailBuilder = new EmailBuilder(this, buildContext); | |
981 | } | |
982 |
8
1. email : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::email → NO_COVERAGE 2. email : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::email → KILLED 3. email : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::email → KILLED 4. email : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::email → KILLED 5. email : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::email → KILLED 6. email : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::email → KILLED 7. email : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::email → KILLED 8. email : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::email → KILLED |
return emailBuilder; |
983 | } | |
984 | ||
985 | /** | |
986 | * Configures how to send {@link Sms} messages. It allows to: | |
987 | * <ul> | |
988 | * <li>register and configure several sender implementations</li> | |
989 | * <li>register and configure several template engines for parsing templates | |
990 | * as message content</li> | |
991 | * <li>configure handling of missing {@link Sms} information</li> | |
992 | * <li>configure number format handling</li> | |
993 | * </ul> | |
994 | * | |
995 | * You can send a {@link Sms} using the minimal behavior and using | |
996 | * Cloudhopper implementation: | |
997 | * | |
998 | * <pre> | |
999 | * <code> | |
1000 | * // Instantiate the messaging service | |
1001 | * MessagingService service = new MessagingBuilder() | |
1002 | * .sms() | |
1003 | * .sender(CloudhopperBuilder.class) // enable SMS sending using Cloudhopper | |
1004 | * .host("your SMPP server host") | |
1005 | * .port("your SMPP server port") | |
1006 | * .systemId("your SMPP system_id") | |
1007 | * .password("an optional password") | |
1008 | * .and() | |
1009 | * .and() | |
1010 | * .build(); | |
1011 | * // send the sms | |
1012 | * service.send(new Sms() | |
1013 | * .from("sender phone number") | |
1014 | * .content("sms content") | |
1015 | * .to("recipient phone number")); | |
1016 | * </code> | |
1017 | * </pre> | |
1018 | * | |
1019 | * You can also send a {@link Sms} using a template (using Freemarker for | |
1020 | * example): | |
1021 | * | |
1022 | * The Freemarker template ("sms/sample.txt.ftl"): | |
1023 | * | |
1024 | * <pre> | |
1025 | * Sms content with variables: ${name} ${value} | |
1026 | * </pre> | |
1027 | * | |
1028 | * Then you can send the {@link Sms} like this: | |
1029 | * | |
1030 | * <pre> | |
1031 | * <code> | |
1032 | * // Instantiate the messaging service | |
1033 | * MessagingService service = new MessagingBuilder() | |
1034 | * .sms() | |
1035 | * .sender(CloudhopperBuilder.class) // enable SMS sending using Cloudhopper | |
1036 | * .host("your SMPP server host") | |
1037 | * .port("your SMPP server port") | |
1038 | * .systemId("your SMPP system_id") | |
1039 | * .password("an optional password") | |
1040 | * .and() | |
1041 | * .and() | |
1042 | * .template(FreemarkerSmsBuilder.class) // enable templating using Freemarker | |
1043 | * .classpath() | |
1044 | * .lookup("classpath:") // search resources/templates in the classpath if a path is prefixed by "classpath:" | |
1045 | * .and() | |
1046 | * .and() | |
1047 | * .build(); | |
1048 | * // send the sms | |
1049 | * service.send(new Sms() | |
1050 | * .from("sender phone number") | |
1051 | * .content(new TemplateContent("classpath:sms/sample.txt.ftl", new SampleBean("foo", 42))) | |
1052 | * .to("recipient phone number")); | |
1053 | * </code> | |
1054 | * </pre> | |
1055 | * | |
1056 | * <p> | |
1057 | * Instead of explicitly configures SMPP host/port/system_id/password in | |
1058 | * your code, it could be better to externalize the configuration in a | |
1059 | * properties file for example (for example a file named "sms.properties" in | |
1060 | * the classpath). The previous example becomes: | |
1061 | * | |
1062 | * <pre> | |
1063 | * <code> | |
1064 | * // Instantiate the messaging service | |
1065 | * MessagingService service = new MessagingBuilder() | |
1066 | * .environment() | |
1067 | * .properties("sms.properties") | |
1068 | * .and() | |
1069 | * .sms() | |
1070 | * .sender(CloudhopperBuilder.class) // enable SMS sending using Cloudhopper | |
1071 | * .host().properties("${smpp.host}").and() | |
1072 | * .port().properties("${smpp.port}").and() | |
1073 | * .systemId().properties("${smpp.system-id}").and() | |
1074 | * .password().properties("${smpp.password}").and() | |
1075 | * .and() | |
1076 | * .and() | |
1077 | * .template(FreemarkerSmsBuilder.class) // enable templating using Freemarker | |
1078 | * .classpath() | |
1079 | * .lookup("classpath:") // search resources/templates in the classpath if a path is prefixed by "classpath:" | |
1080 | * .and() | |
1081 | * .and() | |
1082 | * .build(); | |
1083 | * // send the sms | |
1084 | * service.send(new Sms() | |
1085 | * .from("sender phone number") | |
1086 | * .content(new TemplateContent("classpath:sms/sample.txt.ftl", new SampleBean("foo", 42))) | |
1087 | * .to("recipient phone number")); | |
1088 | * </code> | |
1089 | * </pre> | |
1090 | * | |
1091 | * The content of the file "sms.properties": | |
1092 | * | |
1093 | * <pre> | |
1094 | * smpp.host=your SMPP server host | |
1095 | * smpp.port=your SMPP server port | |
1096 | * smpp.system-id=your SMPP system_id | |
1097 | * smpp.password=an optional password | |
1098 | * </pre> | |
1099 | * | |
1100 | * | |
1101 | * Some fields of the SMS may be automatically filled by a default value if | |
1102 | * they are not defined. For example, the sender phone number could be | |
1103 | * configured only once for your application: | |
1104 | * | |
1105 | * <pre> | |
1106 | * <code> | |
1107 | * // Instantiate the messaging service | |
1108 | * MessagingService service = new MessagingBuilder() | |
1109 | * .environment() | |
1110 | * .properties("sms.properties") | |
1111 | * .and() | |
1112 | * .sms() | |
1113 | * .sender(CloudhopperBuilder.class) // enable SMS sending using Cloudhopper | |
1114 | * .host().properties("${smpp.host}").and() | |
1115 | * .port().properties("${smpp.port}").and() | |
1116 | * .systemId().properties("${smpp.system-id}").and() | |
1117 | * .password().properties("${smpp.password}").and() | |
1118 | * .and() | |
1119 | * .autofill() // enables and configures autofilling | |
1120 | * .from() | |
1121 | * .defaultValue().properties("${sms.sender.number}").and() | |
1122 | * .and() | |
1123 | * .and() | |
1124 | * .and() | |
1125 | * .template(FreemarkerSmsBuilder.class) // enable templating using Freemarker | |
1126 | * .classpath() | |
1127 | * .lookup("classpath:") // search resources/templates in the classpath if a path is prefixed by "classpath:" | |
1128 | * .and() | |
1129 | * .and() | |
1130 | * .build(); | |
1131 | * // send the sms (now the sender phone number can be omitted) | |
1132 | * service.send(new Sms() | |
1133 | * .content(new TemplateContent("classpath:sms/sample.txt.ftl", new SampleBean("foo", 42))) | |
1134 | * .to("recipient phone number")); | |
1135 | * </code> | |
1136 | * </pre> | |
1137 | * | |
1138 | * The new content of the file "sms.properties": | |
1139 | * | |
1140 | * <pre> | |
1141 | * smpp.host=your SMPP server host | |
1142 | * smpp.port=your SMPP server port | |
1143 | * smpp.system-id=your SMPP system_id | |
1144 | * smpp.password=an optional password | |
1145 | * sms.sender.number=the sender phone number | |
1146 | * </pre> | |
1147 | * | |
1148 | * <p> | |
1149 | * All the previous examples are provided to understand what can be | |
1150 | * configured. Hopefully, Ogham provides auto-configuration with a default | |
1151 | * behavior that fits 95% of usages. This auto-configuration is provided by | |
1152 | * {@link MessagingConfigurer}s. Those configurers are automatically applied | |
1153 | * when using predefined {@link MessagingBuilder}s like | |
1154 | * {@link MessagingBuilder#minimal()} and | |
1155 | * {@link MessagingBuilder#standard()}. | |
1156 | * | |
1157 | * The previous sample using standard configuration becomes: | |
1158 | * | |
1159 | * <pre> | |
1160 | * <code> | |
1161 | * // Instantiate the messaging service | |
1162 | * MessagingService service = MessagingBuilder.standard() | |
1163 | * .environment() | |
1164 | * .properties("sms.properties") | |
1165 | * .and() | |
1166 | * .build(); | |
1167 | * // send the sms | |
1168 | * service.send(new Sms() | |
1169 | * .content(new TemplateContent("classpath:sms/sample.txt.ftl", new SampleBean("foo", 42))) | |
1170 | * .to("recipient phone number")); | |
1171 | * </code> | |
1172 | * </pre> | |
1173 | * | |
1174 | * The new content of the file "sms.properties": | |
1175 | * | |
1176 | * <pre> | |
1177 | * ogham.sms.smpp.host=your SMPP server host | |
1178 | * ogham.sms.smpp.port=your SMPP server port | |
1179 | * ogham.sms.smpp.system-id=your SMPP system_id | |
1180 | * ogham.sms.smpp.password=an optional password | |
1181 | * ogham.sms.from.default-value=the sender phone number | |
1182 | * </pre> | |
1183 | * | |
1184 | * <p> | |
1185 | * You can also use the auto-configuration for benefit from default | |
1186 | * behaviors and override some behaviors for your needs: | |
1187 | * | |
1188 | * <pre> | |
1189 | * <code> | |
1190 | * // Instantiate the messaging service | |
1191 | * MessagingService service = MessagingBuilder.standard() | |
1192 | * .environment() | |
1193 | * .properties("sms.properties") | |
1194 | * .and() | |
1195 | * .sms() | |
1196 | * .autofill() | |
1197 | * .from() | |
1198 | * .defaultValue().properties("${sms.sender.number}").and() // overrides default sender phone number property | |
1199 | * .and() | |
1200 | * .and() | |
1201 | * .and() | |
1202 | * .build(); | |
1203 | * // send the sms | |
1204 | * service.send(new Sms() | |
1205 | * .content(new TemplateContent("classpath:sms/sample.txt.ftl", new SampleBean("foo", 42))) | |
1206 | * .to("recipient phone number")); | |
1207 | * </code> | |
1208 | * </pre> | |
1209 | * | |
1210 | * The new content of the file "sms.properties": | |
1211 | * | |
1212 | * <pre> | |
1213 | * ogham.sms.smpp.host=your SMPP server host | |
1214 | * ogham.sms.smpp.port=your SMPP server port | |
1215 | * ogham.sms.smpp.system-id=your SMPP system_id | |
1216 | * ogham.sms.smpp.password=an optional password | |
1217 | * sms.sender.number=the sender phone number | |
1218 | * </pre> | |
1219 | * | |
1220 | * @return the builder to configure how SMS are handled | |
1221 | */ | |
1222 | public SmsBuilder sms() { | |
1223 |
8
1. sms : negated conditional → NO_COVERAGE 2. sms : negated conditional → KILLED 3. sms : negated conditional → KILLED 4. sms : negated conditional → KILLED 5. sms : negated conditional → KILLED 6. sms : negated conditional → KILLED 7. sms : negated conditional → KILLED 8. sms : negated conditional → KILLED |
if (smsBuilder == null) { |
1224 | smsBuilder = new SmsBuilder(this, buildContext); | |
1225 | } | |
1226 |
8
1. sms : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::sms → NO_COVERAGE 2. sms : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::sms → KILLED 3. sms : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::sms → KILLED 4. sms : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::sms → KILLED 5. sms : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::sms → KILLED 6. sms : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::sms → KILLED 7. sms : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::sms → KILLED 8. sms : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::sms → KILLED |
return smsBuilder; |
1227 | } | |
1228 | ||
1229 | /** | |
1230 | * Builds the messaging service. The messaging service relies on the | |
1231 | * generated senders. Each sender is able to manage one or multiple | |
1232 | * messages. The default implementation of the messaging service is to ask | |
1233 | * each sender if it is able to handle the message and if it the case, then | |
1234 | * use this sender to really send the message. This implementation doesn't | |
1235 | * stop when the message is handled by a sender to possibly let another send | |
1236 | * the message through another channel. | |
1237 | * | |
1238 | * <p> | |
1239 | * If a {@link RuntimeException} is thrown while trying to send a message, | |
1240 | * the service will catch it and wrap it into a {@link MessagingException} | |
1241 | * in order to indicate that the exception was caused while trying to send a | |
1242 | * message. | |
1243 | * </p> | |
1244 | * | |
1245 | * @return the messaging service instance | |
1246 | * @throws BuildException | |
1247 | * when service couldn't be instantiated and configured | |
1248 | */ | |
1249 | @Override | |
1250 | @SuppressWarnings("squid:S5411") | |
1251 | public MessagingService build() { | |
1252 |
7
1. build : negated conditional → NO_COVERAGE 2. build : negated conditional → SURVIVED 3. build : negated conditional → KILLED 4. build : negated conditional → KILLED 5. build : negated conditional → KILLED 6. build : negated conditional → KILLED 7. build : negated conditional → KILLED |
if (autoconfigure) { |
1253 |
6
1. build : removed call to fr/sii/ogham/core/builder/MessagingBuilder::configure → NO_COVERAGE 2. build : removed call to fr/sii/ogham/core/builder/MessagingBuilder::configure → KILLED 3. build : removed call to fr/sii/ogham/core/builder/MessagingBuilder::configure → KILLED 4. build : removed call to fr/sii/ogham/core/builder/MessagingBuilder::configure → KILLED 5. build : removed call to fr/sii/ogham/core/builder/MessagingBuilder::configure → KILLED 6. build : removed call to fr/sii/ogham/core/builder/MessagingBuilder::configure → KILLED |
configure(ConfigurationPhase.BEFORE_BUILD); |
1254 | } | |
1255 | LOG.info("Using service that calls all registered senders"); | |
1256 | List<ConditionalSender> senders = buildSenders(); | |
1257 | LOG.debug("Registered senders: {}", senders); | |
1258 | MessagingService service = new EverySupportingMessagingService(senders); | |
1259 |
3
1. build : negated conditional → NO_COVERAGE 2. build : negated conditional → SURVIVED 3. build : negated conditional → KILLED |
if (wrapUncaughtValueBuilder.getValue(false)) { |
1260 | service = new WrapExceptionMessagingService(service); | |
1261 | } | |
1262 | service = new CleanableMessagingService(service, cleaner); | |
1263 |
8
1. build : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::build → NO_COVERAGE 2. build : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::build → KILLED 3. build : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::build → KILLED 4. build : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::build → KILLED 5. build : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::build → KILLED 6. build : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::build → KILLED 7. build : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::build → KILLED 8. build : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::build → KILLED |
return service; |
1264 | } | |
1265 | | |
1266 | protected StandaloneResourceResolutionBuilder<MessagingBuilder> createResourceResolutionBuilder() { | |
1267 |
8
1. createResourceResolutionBuilder : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createResourceResolutionBuilder → NO_COVERAGE 2. createResourceResolutionBuilder : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createResourceResolutionBuilder → KILLED 3. createResourceResolutionBuilder : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createResourceResolutionBuilder → KILLED 4. createResourceResolutionBuilder : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createResourceResolutionBuilder → KILLED 5. createResourceResolutionBuilder : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createResourceResolutionBuilder → KILLED 6. createResourceResolutionBuilder : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createResourceResolutionBuilder → KILLED 7. createResourceResolutionBuilder : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createResourceResolutionBuilder → KILLED 8. createResourceResolutionBuilder : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createResourceResolutionBuilder → KILLED |
return new StandaloneResourceResolutionBuilder<>(this, buildContext); |
1268 | } | |
1269 | | |
1270 | protected MimetypeDetectionBuilder<MessagingBuilder> createMimetypeBuilder() { | |
1271 |
8
1. createMimetypeBuilder : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createMimetypeBuilder → NO_COVERAGE 2. createMimetypeBuilder : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createMimetypeBuilder → KILLED 3. createMimetypeBuilder : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createMimetypeBuilder → KILLED 4. createMimetypeBuilder : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createMimetypeBuilder → KILLED 5. createMimetypeBuilder : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createMimetypeBuilder → KILLED 6. createMimetypeBuilder : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createMimetypeBuilder → KILLED 7. createMimetypeBuilder : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createMimetypeBuilder → KILLED 8. createMimetypeBuilder : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createMimetypeBuilder → KILLED |
return new SimpleMimetypeDetectionBuilder<>(this, buildContext); |
1272 | } | |
1273 | | |
1274 | protected Cleanable createCleanable() { | |
1275 |
3
1. createCleanable : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createCleanable → NO_COVERAGE 2. createCleanable : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createCleanable → SURVIVED 3. createCleanable : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createCleanable → KILLED |
return getOrCreateCleanableRegistry(); |
1276 | } | |
1277 | | |
1278 | protected Registry<Object> createRegistry() { | |
1279 |
8
1. createRegistry : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createRegistry → NO_COVERAGE 2. createRegistry : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createRegistry → KILLED 3. createRegistry : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createRegistry → KILLED 4. createRegistry : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createRegistry → KILLED 5. createRegistry : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createRegistry → KILLED 6. createRegistry : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createRegistry → KILLED 7. createRegistry : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createRegistry → KILLED 8. createRegistry : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createRegistry → KILLED |
return getOrCreateCleanableRegistry(); |
1280 | } | |
1281 | | |
1282 | protected CleanableRegistry getOrCreateCleanableRegistry() { | |
1283 |
8
1. getOrCreateCleanableRegistry : negated conditional → NO_COVERAGE 2. getOrCreateCleanableRegistry : negated conditional → KILLED 3. getOrCreateCleanableRegistry : negated conditional → KILLED 4. getOrCreateCleanableRegistry : negated conditional → KILLED 5. getOrCreateCleanableRegistry : negated conditional → KILLED 6. getOrCreateCleanableRegistry : negated conditional → KILLED 7. getOrCreateCleanableRegistry : negated conditional → KILLED 8. getOrCreateCleanableRegistry : negated conditional → KILLED |
if (cleanableRegistry == null) { |
1284 | cleanableRegistry = new CleanableRegistry(); | |
1285 | } | |
1286 |
8
1. getOrCreateCleanableRegistry : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::getOrCreateCleanableRegistry → NO_COVERAGE 2. getOrCreateCleanableRegistry : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::getOrCreateCleanableRegistry → KILLED 3. getOrCreateCleanableRegistry : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::getOrCreateCleanableRegistry → KILLED 4. getOrCreateCleanableRegistry : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::getOrCreateCleanableRegistry → KILLED 5. getOrCreateCleanableRegistry : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::getOrCreateCleanableRegistry → KILLED 6. getOrCreateCleanableRegistry : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::getOrCreateCleanableRegistry → KILLED 7. getOrCreateCleanableRegistry : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::getOrCreateCleanableRegistry → KILLED 8. getOrCreateCleanableRegistry : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::getOrCreateCleanableRegistry → KILLED |
return cleanableRegistry; |
1287 | } | |
1288 | | |
1289 | protected EnvironmentBuilder<MessagingBuilder> createEnvironmentBuilder() { | |
1290 |
8
1. createEnvironmentBuilder : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createEnvironmentBuilder → NO_COVERAGE 2. createEnvironmentBuilder : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createEnvironmentBuilder → KILLED 3. createEnvironmentBuilder : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createEnvironmentBuilder → KILLED 4. createEnvironmentBuilder : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createEnvironmentBuilder → KILLED 5. createEnvironmentBuilder : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createEnvironmentBuilder → KILLED 6. createEnvironmentBuilder : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createEnvironmentBuilder → KILLED 7. createEnvironmentBuilder : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createEnvironmentBuilder → KILLED 8. createEnvironmentBuilder : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createEnvironmentBuilder → KILLED |
return new SimpleEnvironmentBuilder<>(this); |
1291 | } | |
1292 | | |
1293 | protected BuildContext createBuildContext() { | |
1294 |
8
1. createBuildContext : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createBuildContext → NO_COVERAGE 2. createBuildContext : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createBuildContext → KILLED 3. createBuildContext : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createBuildContext → KILLED 4. createBuildContext : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createBuildContext → KILLED 5. createBuildContext : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createBuildContext → KILLED 6. createBuildContext : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createBuildContext → KILLED 7. createBuildContext : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createBuildContext → KILLED 8. createBuildContext : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::createBuildContext → KILLED |
return new EnvBuilderBasedContext(environmentBuilder, registry); |
1295 | } | |
1296 | ||
1297 | ||
1298 | /** | |
1299 | * Static factory method that initializes a {@link MessagingBuilder} | |
1300 | * instance with no auto-configuration at all. | |
1301 | * | |
1302 | * @return the empty builder that provides no behavior at all that needs to | |
1303 | * be configured | |
1304 | */ | |
1305 | public static MessagingBuilder empty() { | |
1306 |
4
1. empty : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::empty → NO_COVERAGE 2. empty : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::empty → KILLED 3. empty : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::empty → KILLED 4. empty : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::empty → KILLED |
return new MessagingBuilder(false); |
1307 | } | |
1308 | ||
1309 | /** | |
1310 | * Static factory method that initializes a {@link MessagingBuilder} | |
1311 | * instance and auto-configures it with a predefined behavior named | |
1312 | * "standard". | |
1313 | * | |
1314 | * Usage example: | |
1315 | * | |
1316 | * <pre> | |
1317 | * <code> | |
1318 | * MessagingService service = MessagingBuilder.standard() | |
1319 | * .environment() | |
1320 | * .properties("application.properties") | |
1321 | * .and() | |
1322 | * .build(); | |
1323 | * </code> | |
1324 | * </pre> | |
1325 | * | |
1326 | * <p> | |
1327 | * Basically, the standard behavior: | |
1328 | * <ul> | |
1329 | * <li>Enables all template engines that are present in the classpath and | |
1330 | * configures them</li> | |
1331 | * <li>Enables all {@link Email} sender implementations that are present in | |
1332 | * the classpath and configures them</li> | |
1333 | * <li>Enables all {@link Sms} sender implementations that are present in | |
1334 | * the classpath and configures them</li> | |
1335 | * <li>Catches all uncaught exception to wrap them in order to avoid | |
1336 | * unwanted unchecked exception</li> | |
1337 | * <li>Uses system properties</li> | |
1338 | * <li>Enables and configures useful auto-filling mechanisms (using property | |
1339 | * values and providing email subject from templates)</li> | |
1340 | * <li>Enables mimetype detection</li> | |
1341 | * <li>Enables locating templates, css, images and all other resources using | |
1342 | * lookup prefix ("file:" for files that are present on the filesystem, | |
1343 | * "classpath:" and "" for files that are present in the classpath)</li> | |
1344 | * <li>Enables use of some properties to provide path prefix/suffix for | |
1345 | * locating resources</li> | |
1346 | * <li>Enables images and css inlining used by HTML {@link Email}s</li> | |
1347 | * </ul> | |
1348 | * | |
1349 | * <p> | |
1350 | * The auto-configurers ( {@link MessagingConfigurer}s) are automatically | |
1351 | * loaded from the classpath. Only configurers that are in "fr.sii.ogham" | |
1352 | * package and sub-packages are loaded. If you want to load from other | |
1353 | * packages, use {@link #standard(String...)}. Some Ogham modules are | |
1354 | * optional meaning that according to used modules, the behavior will vary. | |
1355 | * | |
1356 | * Loaded {@link MessagingConfigurer}s are applied to the | |
1357 | * {@link MessagingBuilder} only if they are for the "standard" builder. It | |
1358 | * is accomplished thanks to the {@link ConfigurerFor} annotation (only | |
1359 | * configurers annotated and with {@link ConfigurerFor#targetedBuilder()} | |
1360 | * set to "standard"). | |
1361 | * | |
1362 | * Loaded configurers with priorities are (if all Ogham modules are used): | |
1363 | * <ul> | |
1364 | * <li><code>DefaultMessagingConfigurer</code>: 100000</li> | |
1365 | * <li><code>DefaultThymeleafEmailConfigurer</code>: 90000</li> | |
1366 | * <li><code>DefaultFreemarkerEmailConfigurer</code>: 80000</li> | |
1367 | * <li><code>DefaultThymeleafSmsConfigurer</code>: 70000</li> | |
1368 | * <li><code>DefaultFreemarkerSmsConfigurer</code>: 60000</li> | |
1369 | * <li><code>DefaultJavaMailConfigurer</code>: 50000</li> | |
1370 | * <li><code>DefaultCloudhopperConfigurer</code>: 40000</li> | |
1371 | * <li><code>DefaultSendGridConfigurer</code>: 30000</li> | |
1372 | * <li><code>DefaultOvhSmsConfigurer</code>: 20000</li> | |
1373 | * </ul> | |
1374 | * | |
1375 | * TODO: link to whole configuration that is applied by standard | |
1376 | * | |
1377 | * <p> | |
1378 | * The auto-configured {@link MessagingBuilder} will provide a default | |
1379 | * behavior that fits 95% of usages. You can still override some behaviors | |
1380 | * for your needs. | |
1381 | * | |
1382 | * For example: | |
1383 | * | |
1384 | * <pre> | |
1385 | * <code> | |
1386 | * MessagingService service = MessagingBuilder.standard() | |
1387 | * .environment() | |
1388 | * .properties("application.properties") | |
1389 | * .and() | |
1390 | * .wrapUncaught(false) // overrides and disables wrapUncaught option | |
1391 | * .build(); | |
1392 | * </code> | |
1393 | * </pre> | |
1394 | * | |
1395 | * @return the messaging builder that can be customized | |
1396 | */ | |
1397 | public static MessagingBuilder standard() { | |
1398 |
6
1. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → NO_COVERAGE 2. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → KILLED 3. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → KILLED 4. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → KILLED 5. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → KILLED 6. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → KILLED |
return standard(BASE_PACKAGE); |
1399 | } | |
1400 | ||
1401 | /** | |
1402 | * Static factory method that initializes a {@link MessagingBuilder} | |
1403 | * instance and auto-configures it with a predefined behavior named | |
1404 | * "standard". | |
1405 | * | |
1406 | * Usage example: | |
1407 | * | |
1408 | * <pre> | |
1409 | * <code> | |
1410 | * MessagingService service = MessagingBuilder.standard() | |
1411 | * .environment() | |
1412 | * .properties("application.properties") | |
1413 | * .and() | |
1414 | * .build(); | |
1415 | * </code> | |
1416 | * </pre> | |
1417 | * | |
1418 | * <p> | |
1419 | * Basically, the standard behavior: | |
1420 | * <ul> | |
1421 | * <li>Enables all template engines that are present in the classpath and | |
1422 | * configures them</li> | |
1423 | * <li>Enables all {@link Email} sender implementations that are present in | |
1424 | * the classpath and configures them</li> | |
1425 | * <li>Enables all {@link Sms} sender implementations that are present in | |
1426 | * the classpath and configures them</li> | |
1427 | * <li>Catches all uncaught exception to wrap them in order to avoid | |
1428 | * unwanted unchecked exception</li> | |
1429 | * <li>Uses system properties</li> | |
1430 | * <li>Enables and configures useful auto-filling mechanisms (using property | |
1431 | * values and providing email subject from templates)</li> | |
1432 | * <li>Enables mimetype detection</li> | |
1433 | * <li>Enables locating templates, css, images and all other resources using | |
1434 | * lookup prefix ("file:" for files that are present on the filesystem, | |
1435 | * "classpath:" and "" for files that are present in the classpath)</li> | |
1436 | * <li>Enables use of some properties to provide path prefix/suffix for | |
1437 | * locating resources</li> | |
1438 | * <li>Enables images and css inlining used by HTML {@link Email}s</li> | |
1439 | * </ul> | |
1440 | * | |
1441 | * <p> | |
1442 | * The auto-configurers ( {@link MessagingConfigurer}s) are automatically | |
1443 | * loaded from the classpath. Only configurers that are in the provided | |
1444 | * packages and sub-packages are loaded. Some Ogham modules are optional | |
1445 | * meaning that according to used modules, the behavior will vary. | |
1446 | * | |
1447 | * Loaded {@link MessagingConfigurer}s are applied to the | |
1448 | * {@link MessagingBuilder} only if they are for the "standard" builder. It | |
1449 | * is accomplished thanks to the {@link ConfigurerFor} annotation (only | |
1450 | * configurers annotated and with {@link ConfigurerFor#targetedBuilder()} | |
1451 | * set to "standard"). | |
1452 | * | |
1453 | * Loaded configurers with priorities are (if all Ogham modules are used): | |
1454 | * <ul> | |
1455 | * <li><code>DefaultMessagingConfigurer</code>: 100000</li> | |
1456 | * <li><code>DefaultThymeleafEmailConfigurer</code>: 90000</li> | |
1457 | * <li><code>DefaultFreemarkerEmailConfigurer</code>: 80000</li> | |
1458 | * <li><code>DefaultThymeleafSmsConfigurer</code>: 70000</li> | |
1459 | * <li><code>DefaultFreemarkerSmsConfigurer</code>: 60000</li> | |
1460 | * <li><code>DefaultJavaMailConfigurer</code>: 50000</li> | |
1461 | * <li><code>DefaultCloudhopperConfigurer</code>: 40000</li> | |
1462 | * <li><code>DefaultSendGridConfigurer</code>: 30000</li> | |
1463 | * <li><code>DefaultOvhSmsConfigurer</code>: 20000</li> | |
1464 | * </ul> | |
1465 | * | |
1466 | * TODO: link to whole configuration that is applied by standard | |
1467 | * | |
1468 | * <p> | |
1469 | * The auto-configured {@link MessagingBuilder} will provide a default | |
1470 | * behavior that fits 95% of usages. You can still override some behaviors | |
1471 | * for your needs. | |
1472 | * | |
1473 | * For example: | |
1474 | * | |
1475 | * <pre> | |
1476 | * <code> | |
1477 | * MessagingService service = MessagingBuilder.standard() | |
1478 | * .environment() | |
1479 | * .properties("application.properties") | |
1480 | * .and() | |
1481 | * .wrapUncaught(false) // overrides and disables wrapUncaught option | |
1482 | * .build(); | |
1483 | * </code> | |
1484 | * </pre> | |
1485 | * | |
1486 | * @param basePackages | |
1487 | * the base packages that are scanned to find | |
1488 | * {@link MessagingConfigurer} implementations | |
1489 | * @return the messaging builder that can be customized | |
1490 | */ | |
1491 | public static MessagingBuilder standard(String... basePackages) { | |
1492 |
6
1. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → NO_COVERAGE 2. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → KILLED 3. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → KILLED 4. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → KILLED 5. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → KILLED 6. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → KILLED |
return standard(true, basePackages); |
1493 | } | |
1494 | ||
1495 | /** | |
1496 | * Static factory method that initializes a {@link MessagingBuilder} | |
1497 | * instance and registers auto-configures but doesn't apply them if | |
1498 | * autoconfigure parameter is false. The | |
1499 | * {@link #configure(ConfigurationPhase)} method must be called manually. | |
1500 | * | |
1501 | * Usage example: | |
1502 | * | |
1503 | * <pre> | |
1504 | * <code> | |
1505 | * MessagingService service = MessagingBuilder.standard() | |
1506 | * .environment() | |
1507 | * .properties("application.properties") | |
1508 | * .and() | |
1509 | * .build(); | |
1510 | * </code> | |
1511 | * </pre> | |
1512 | * | |
1513 | * <p> | |
1514 | * Basically, the standard behavior: | |
1515 | * <ul> | |
1516 | * <li>Enables all template engines that are present in the classpath and | |
1517 | * configures them</li> | |
1518 | * <li>Enables all {@link Email} sender implementations that are present in | |
1519 | * the classpath and configures them</li> | |
1520 | * <li>Enables all {@link Sms} sender implementations that are present in | |
1521 | * the classpath and configures them</li> | |
1522 | * <li>Catches all uncaught exception to wrap them in order to avoid | |
1523 | * unwanted unchecked exception</li> | |
1524 | * <li>Uses system properties</li> | |
1525 | * <li>Enables and configures useful auto-filling mechanisms (using property | |
1526 | * values and providing email subject from templates)</li> | |
1527 | * <li>Enables mimetype detection</li> | |
1528 | * <li>Enables locating templates, css, images and all other resources using | |
1529 | * lookup prefix ("file:" for files that are present on the filesystem, | |
1530 | * "classpath:" and "" for files that are present in the classpath)</li> | |
1531 | * <li>Enables use of some properties to provide path prefix/suffix for | |
1532 | * locating resources</li> | |
1533 | * <li>Enables images and css inlining used by HTML {@link Email}s</li> | |
1534 | * </ul> | |
1535 | * | |
1536 | * <p> | |
1537 | * The auto-configurers ( {@link MessagingConfigurer}s) are automatically | |
1538 | * loaded from the classpath. Only configurers that are in "fr.sii.ogham" | |
1539 | * package and sub-packages are loaded. If you want to load from other | |
1540 | * packages, use {@link #standard(String...)}. Some Ogham modules are | |
1541 | * optional meaning that according to used modules, the behavior will vary. | |
1542 | * | |
1543 | * Loaded {@link MessagingConfigurer}s are applied to the | |
1544 | * {@link MessagingBuilder} only if they are for the "standard" builder. It | |
1545 | * is accomplished thanks to the {@link ConfigurerFor} annotation (only | |
1546 | * configurers annotated and with {@link ConfigurerFor#targetedBuilder()} | |
1547 | * set to "standard"). | |
1548 | * | |
1549 | * Loaded configurers with priorities are (if all Ogham modules are used): | |
1550 | * <ul> | |
1551 | * <li><code>DefaultMessagingConfigurer</code>: 100000</li> | |
1552 | * <li><code>DefaultThymeleafEmailConfigurer</code>: 90000</li> | |
1553 | * <li><code>DefaultFreemarkerEmailConfigurer</code>: 80000</li> | |
1554 | * <li><code>DefaultThymeleafSmsConfigurer</code>: 70000</li> | |
1555 | * <li><code>DefaultFreemarkerSmsConfigurer</code>: 60000</li> | |
1556 | * <li><code>DefaultJavaMailConfigurer</code>: 50000</li> | |
1557 | * <li><code>DefaultCloudhopperConfigurer</code>: 40000</li> | |
1558 | * <li><code>DefaultSendGridConfigurer</code>: 30000</li> | |
1559 | * <li><code>DefaultOvhSmsConfigurer</code>: 20000</li> | |
1560 | * </ul> | |
1561 | * | |
1562 | * TODO: link to whole configuration that is applied by standard | |
1563 | * | |
1564 | * <p> | |
1565 | * The auto-configured {@link MessagingBuilder} will provide a default | |
1566 | * behavior that fits 95% of usages. You can still override some behaviors | |
1567 | * for your needs. | |
1568 | * | |
1569 | * For example: | |
1570 | * | |
1571 | * <pre> | |
1572 | * <code> | |
1573 | * MessagingService service = MessagingBuilder.standard() | |
1574 | * .environment() | |
1575 | * .properties("application.properties") | |
1576 | * .and() | |
1577 | * .wrapUncaught(false) // overrides and disables wrapUncaught option | |
1578 | * .build(); | |
1579 | * </code> | |
1580 | * </pre> | |
1581 | * | |
1582 | * @param autoconfigure | |
1583 | * true to automatically apply found configurers, false to | |
1584 | * configure manually later by calling | |
1585 | * {@link #configure(ConfigurationPhase)} | |
1586 | * @return the messaging builder that can be customized | |
1587 | */ | |
1588 | public static MessagingBuilder standard(boolean autoconfigure) { | |
1589 |
1
1. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → NO_COVERAGE |
return standard(autoconfigure, BASE_PACKAGE); |
1590 | } | |
1591 | ||
1592 | /** | |
1593 | * Static factory method that initializes a {@link MessagingBuilder} | |
1594 | * instance and registers auto-configures but doesn't apply them if | |
1595 | * autoconfigure parameter is false. The | |
1596 | * {@link #configure(ConfigurationPhase)} method must be called manually. | |
1597 | * | |
1598 | * Usage example: | |
1599 | * | |
1600 | * <pre> | |
1601 | * <code> | |
1602 | * MessagingService service = MessagingBuilder.standard() | |
1603 | * .environment() | |
1604 | * .properties("application.properties") | |
1605 | * .and() | |
1606 | * .build(); | |
1607 | * </code> | |
1608 | * </pre> | |
1609 | * | |
1610 | * <p> | |
1611 | * Basically, the standard behavior: | |
1612 | * <ul> | |
1613 | * <li>Enables all template engines that are present in the classpath and | |
1614 | * configures them</li> | |
1615 | * <li>Enables all {@link Email} sender implementations that are present in | |
1616 | * the classpath and configures them</li> | |
1617 | * <li>Enables all {@link Sms} sender implementations that are present in | |
1618 | * the classpath and configures them</li> | |
1619 | * <li>Catches all uncaught exception to wrap them in order to avoid | |
1620 | * unwanted unchecked exception</li> | |
1621 | * <li>Uses system properties</li> | |
1622 | * <li>Enables and configures useful auto-filling mechanisms (using property | |
1623 | * values and providing email subject from templates)</li> | |
1624 | * <li>Enables mimetype detection</li> | |
1625 | * <li>Enables locating templates, css, images and all other resources using | |
1626 | * lookup prefix ("file:" for files that are present on the filesystem, | |
1627 | * "classpath:" and "" for files that are present in the classpath)</li> | |
1628 | * <li>Enables use of some properties to provide path prefix/suffix for | |
1629 | * locating resources</li> | |
1630 | * <li>Enables images and css inlining used by HTML {@link Email}s</li> | |
1631 | * </ul> | |
1632 | * | |
1633 | * <p> | |
1634 | * The auto-configurers ( {@link MessagingConfigurer}s) are automatically | |
1635 | * loaded from the classpath. Only configurers that are in the provided | |
1636 | * packages and sub-packages are loaded. Some Ogham modules are optional | |
1637 | * meaning that according to used modules, the behavior will vary. | |
1638 | * | |
1639 | * Loaded {@link MessagingConfigurer}s are applied to the | |
1640 | * {@link MessagingBuilder} only if they are for the "standard" builder. It | |
1641 | * is accomplished thanks to the {@link ConfigurerFor} annotation (only | |
1642 | * configurers annotated and with {@link ConfigurerFor#targetedBuilder()} | |
1643 | * set to "standard"). | |
1644 | * | |
1645 | * Loaded configurers with priorities are (if all Ogham modules are used): | |
1646 | * <ul> | |
1647 | * <li><code>DefaultMessagingConfigurer</code>: 100000</li> | |
1648 | * <li><code>DefaultThymeleafEmailConfigurer</code>: 90000</li> | |
1649 | * <li><code>DefaultFreemarkerEmailConfigurer</code>: 80000</li> | |
1650 | * <li><code>DefaultThymeleafSmsConfigurer</code>: 70000</li> | |
1651 | * <li><code>DefaultFreemarkerSmsConfigurer</code>: 60000</li> | |
1652 | * <li><code>DefaultJavaMailConfigurer</code>: 50000</li> | |
1653 | * <li><code>DefaultCloudhopperConfigurer</code>: 40000</li> | |
1654 | * <li><code>DefaultSendGridConfigurer</code>: 30000</li> | |
1655 | * <li><code>DefaultOvhSmsConfigurer</code>: 20000</li> | |
1656 | * </ul> | |
1657 | * | |
1658 | * TODO: link to whole configuration that is applied by standard | |
1659 | * | |
1660 | * <p> | |
1661 | * The auto-configured {@link MessagingBuilder} will provide a default | |
1662 | * behavior that fits 95% of usages. You can still override some behaviors | |
1663 | * for your needs. | |
1664 | * | |
1665 | * For example: | |
1666 | * | |
1667 | * <pre> | |
1668 | * <code> | |
1669 | * MessagingService service = MessagingBuilder.standard() | |
1670 | * .environment() | |
1671 | * .properties("application.properties") | |
1672 | * .and() | |
1673 | * .wrapUncaught(false) // overrides and disables wrapUncaught option | |
1674 | * .build(); | |
1675 | * </code> | |
1676 | * </pre> | |
1677 | * | |
1678 | * @param autoconfigure | |
1679 | * true to automatically apply found configurers, false to | |
1680 | * configure manually later by calling | |
1681 | * {@link #configure(ConfigurationPhase)} | |
1682 | * @param basePackages | |
1683 | * the base packages that are scanned to find | |
1684 | * {@link MessagingConfigurer} implementations | |
1685 | * @return the messaging builder that can be customized | |
1686 | */ | |
1687 | public static MessagingBuilder standard(boolean autoconfigure, String... basePackages) { | |
1688 |
12
1. lambda$standard$0 : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::lambda$standard$0 → NO_COVERAGE 2. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → NO_COVERAGE 3. lambda$standard$0 : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::lambda$standard$0 → KILLED 4. lambda$standard$0 : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::lambda$standard$0 → KILLED 5. lambda$standard$0 : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::lambda$standard$0 → KILLED 6. lambda$standard$0 : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::lambda$standard$0 → KILLED 7. lambda$standard$0 : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::lambda$standard$0 → KILLED 8. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → KILLED 9. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → KILLED 10. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → KILLED 11. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → KILLED 12. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → KILLED |
return standard(() -> new MessagingBuilder(autoconfigure), autoconfigure, basePackages); |
1689 | } | |
1690 | ||
1691 | /** | |
1692 | * Static factory method that initializes a {@link MessagingBuilder} | |
1693 | * instance and registers auto-configures but doesn't apply them if | |
1694 | * autoconfigure parameter is false. The | |
1695 | * {@link #configure(ConfigurationPhase)} method must be called manually. | |
1696 | * | |
1697 | * <p> | |
1698 | * This method allows to use a custom {@link MessagingBuilder} | |
1699 | * implementation. | |
1700 | * | |
1701 | * <p> | |
1702 | * <strong>NOTE:</strong> This is for advanced usage only. | |
1703 | * | |
1704 | * Usage example: | |
1705 | * | |
1706 | * <pre> | |
1707 | * <code> | |
1708 | * MessagingService service = MessagingBuilder.standard() | |
1709 | * .environment() | |
1710 | * .properties("application.properties") | |
1711 | * .and() | |
1712 | * .build(); | |
1713 | * </code> | |
1714 | * </pre> | |
1715 | * | |
1716 | * <p> | |
1717 | * Basically, the standard behavior: | |
1718 | * <ul> | |
1719 | * <li>Enables all template engines that are present in the classpath and | |
1720 | * configures them</li> | |
1721 | * <li>Enables all {@link Email} sender implementations that are present in | |
1722 | * the classpath and configures them</li> | |
1723 | * <li>Enables all {@link Sms} sender implementations that are present in | |
1724 | * the classpath and configures them</li> | |
1725 | * <li>Catches all uncaught exception to wrap them in order to avoid | |
1726 | * unwanted unchecked exception</li> | |
1727 | * <li>Uses system properties</li> | |
1728 | * <li>Enables and configures useful auto-filling mechanisms (using property | |
1729 | * values and providing email subject from templates)</li> | |
1730 | * <li>Enables mimetype detection</li> | |
1731 | * <li>Enables locating templates, css, images and all other resources using | |
1732 | * lookup prefix ("file:" for files that are present on the filesystem, | |
1733 | * "classpath:" and "" for files that are present in the classpath)</li> | |
1734 | * <li>Enables use of some properties to provide path prefix/suffix for | |
1735 | * locating resources</li> | |
1736 | * <li>Enables images and css inlining used by HTML {@link Email}s</li> | |
1737 | * </ul> | |
1738 | * | |
1739 | * <p> | |
1740 | * The auto-configurers ( {@link MessagingConfigurer}s) are automatically | |
1741 | * loaded from the classpath. Only configurers that are in the provided | |
1742 | * packages and sub-packages are loaded. Some Ogham modules are optional | |
1743 | * meaning that according to used modules, the behavior will vary. | |
1744 | * | |
1745 | * Loaded {@link MessagingConfigurer}s are applied to the | |
1746 | * {@link MessagingBuilder} only if they are for the "standard" builder. It | |
1747 | * is accomplished thanks to the {@link ConfigurerFor} annotation (only | |
1748 | * configurers annotated and with {@link ConfigurerFor#targetedBuilder()} | |
1749 | * set to "standard"). | |
1750 | * | |
1751 | * Loaded configurers with priorities are (if all Ogham modules are used): | |
1752 | * <ul> | |
1753 | * <li><code>DefaultMessagingConfigurer</code>: 100000</li> | |
1754 | * <li><code>DefaultThymeleafEmailConfigurer</code>: 90000</li> | |
1755 | * <li><code>DefaultFreemarkerEmailConfigurer</code>: 80000</li> | |
1756 | * <li><code>DefaultThymeleafSmsConfigurer</code>: 70000</li> | |
1757 | * <li><code>DefaultFreemarkerSmsConfigurer</code>: 60000</li> | |
1758 | * <li><code>DefaultJavaMailConfigurer</code>: 50000</li> | |
1759 | * <li><code>DefaultCloudhopperConfigurer</code>: 40000</li> | |
1760 | * <li><code>DefaultSendGridConfigurer</code>: 30000</li> | |
1761 | * <li><code>DefaultOvhSmsConfigurer</code>: 20000</li> | |
1762 | * </ul> | |
1763 | * | |
1764 | * TODO: link to whole configuration that is applied by standard | |
1765 | * | |
1766 | * <p> | |
1767 | * The auto-configured {@link MessagingBuilder} will provide a default | |
1768 | * behavior that fits 95% of usages. You can still override some behaviors | |
1769 | * for your needs. | |
1770 | * | |
1771 | * For example: | |
1772 | * | |
1773 | * <pre> | |
1774 | * <code> | |
1775 | * MessagingService service = MessagingBuilder.standard() | |
1776 | * .environment() | |
1777 | * .properties("application.properties") | |
1778 | * .and() | |
1779 | * .wrapUncaught(false) // overrides and disables wrapUncaught option | |
1780 | * .build(); | |
1781 | * </code> | |
1782 | * </pre> | |
1783 | * | |
1784 | * | |
1785 | * @param factory | |
1786 | * the factory used to create the {@link MessagingBuilder} | |
1787 | * instance | |
1788 | * @param autoconfigure | |
1789 | * true to automatically apply found configurers, false to | |
1790 | * configure manually later by calling | |
1791 | * {@link #configure(ConfigurationPhase)} | |
1792 | * @param basePackages | |
1793 | * the base packages that are scanned to find | |
1794 | * {@link MessagingConfigurer} implementations | |
1795 | * @param <T> | |
1796 | * the type of final {@link MessagingBuilder} | |
1797 | * @return the messaging builder that can be customized | |
1798 | */ | |
1799 | public static <T extends MessagingBuilder> T standard(Supplier<T> factory, boolean autoconfigure, String... basePackages) { | |
1800 | T builder = factory.get(); | |
1801 |
8
1. standard : removed call to fr/sii/ogham/core/builder/MessagingBuilder::findAndRegister → NO_COVERAGE 2. standard : removed call to fr/sii/ogham/core/builder/MessagingBuilder::findAndRegister → KILLED 3. standard : removed call to fr/sii/ogham/core/builder/MessagingBuilder::findAndRegister → KILLED 4. standard : removed call to fr/sii/ogham/core/builder/MessagingBuilder::findAndRegister → KILLED 5. standard : removed call to fr/sii/ogham/core/builder/MessagingBuilder::findAndRegister → KILLED 6. standard : removed call to fr/sii/ogham/core/builder/MessagingBuilder::findAndRegister → KILLED 7. standard : removed call to fr/sii/ogham/core/builder/MessagingBuilder::findAndRegister → KILLED 8. standard : removed call to fr/sii/ogham/core/builder/MessagingBuilder::findAndRegister → KILLED |
findAndRegister(builder, "standard", basePackages); |
1802 |
2
1. standard : negated conditional → SURVIVED 2. standard : negated conditional → NO_COVERAGE |
if (autoconfigure) { |
1803 |
2
1. standard : removed call to fr/sii/ogham/core/builder/MessagingBuilder::configure → SURVIVED 2. standard : removed call to fr/sii/ogham/core/builder/MessagingBuilder::configure → NO_COVERAGE |
builder.configure(ConfigurationPhase.AFTER_INIT); |
1804 | } | |
1805 |
8
1. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → NO_COVERAGE 2. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → KILLED 3. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → KILLED 4. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → KILLED 5. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → KILLED 6. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → KILLED 7. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → KILLED 8. standard : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::standard → KILLED |
return builder; |
1806 | } | |
1807 | ||
1808 | /** | |
1809 | * Static factory method that initializes a {@link MessagingBuilder} | |
1810 | * instance and auto-configures it with a predefined behavior named | |
1811 | * "minimal". | |
1812 | * | |
1813 | * Usage example: | |
1814 | * | |
1815 | * <pre> | |
1816 | * <code> | |
1817 | * MessagingService service = MessagingBuilder.minimal() | |
1818 | * .environment() | |
1819 | * .properties("application.properties") | |
1820 | * .and() | |
1821 | * .build(); | |
1822 | * </code> | |
1823 | * </pre> | |
1824 | * | |
1825 | * <p> | |
1826 | * Basically, the minimal behavior: | |
1827 | * <ul> | |
1828 | * <li>Enables all template engines that are present in the classpath and | |
1829 | * configures them</li> | |
1830 | * <li>Catches all uncaught exception to wrap them in order to avoid | |
1831 | * unwanted unchecked exception</li> | |
1832 | * <li>Uses system properties</li> | |
1833 | * <li>Enables and configures useful auto-filling mechanisms (using property | |
1834 | * values and providing email subject from templates)</li> | |
1835 | * <li>Enables mimetype detection</li> | |
1836 | * <li>Enables locating templates, css, images and all other resources using | |
1837 | * lookup prefix ("file:" for files that are present on the filesystem, | |
1838 | * "classpath:" and "" for files that are present in the classpath)</li> | |
1839 | * <li>Enables use of some properties to provide path prefix/suffix for | |
1840 | * locating resources</li> | |
1841 | * <li>Enables images and css inlining used by HTML {@link Email}s</li> | |
1842 | * </ul> | |
1843 | * | |
1844 | * The minimal behavior doesn't automatically auto-configure sender | |
1845 | * implementations. | |
1846 | * | |
1847 | * <p> | |
1848 | * The auto-configurers ( {@link MessagingConfigurer}s) are automatically | |
1849 | * loaded from the classpath. Only configurers that are in "fr.sii.ogham" | |
1850 | * package and sub-packages are loaded. If you want to load from other | |
1851 | * packages, use {@link #minimal(String...)}. Some Ogham modules are | |
1852 | * optional meaning that according to used modules, the behavior will vary. | |
1853 | * | |
1854 | * Loaded {@link MessagingConfigurer}s are applied to the | |
1855 | * {@link MessagingBuilder} only if they are for the "minimal" builder. It | |
1856 | * is accomplished thanks to the {@link ConfigurerFor} annotation (only | |
1857 | * configurers annotated and with {@link ConfigurerFor#targetedBuilder()} | |
1858 | * set to "minimal"). | |
1859 | * | |
1860 | * Loaded configurers with priorities are (if all Ogham modules are used): | |
1861 | * <ul> | |
1862 | * <li><code>DefaultMessagingConfigurer</code>: 100000</li> | |
1863 | * <li><code>DefaultThymeleafEmailConfigurer</code>: 90000</li> | |
1864 | * <li><code>DefaultFreemarkerEmailConfigurer</code>: 80000</li> | |
1865 | * <li><code>DefaultThymeleafSmsConfigurer</code>: 70000</li> | |
1866 | * <li><code>DefaultFreemarkerSmsConfigurer</code>: 60000</li> | |
1867 | * </ul> | |
1868 | * | |
1869 | * TODO: link to whole configuration that is applied by minimal | |
1870 | * | |
1871 | * <p> | |
1872 | * The auto-configured {@link MessagingBuilder} will provide a default | |
1873 | * behavior with no sender implementation. This is useful if you only want | |
1874 | * to use a particular implementation or your custom sender implementation. | |
1875 | * You can still override some behaviors for your needs. | |
1876 | * | |
1877 | * For example: | |
1878 | * | |
1879 | * <pre> | |
1880 | * <code> | |
1881 | * MessagingService service = MessagingBuilder.minimal() | |
1882 | * .environment() | |
1883 | * .properties("application.properties") | |
1884 | * .and() | |
1885 | * .wrapUncaught(false) // overrides and disables wrapUncaught option | |
1886 | * .build(); | |
1887 | * </code> | |
1888 | * </pre> | |
1889 | * | |
1890 | * @return the messaging builder that can be customized | |
1891 | */ | |
1892 | public static MessagingBuilder minimal() { | |
1893 |
2
1. minimal : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::minimal → NO_COVERAGE 2. minimal : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::minimal → KILLED |
return minimal(BASE_PACKAGE); |
1894 | } | |
1895 | ||
1896 | /** | |
1897 | * Static factory method that initializes a {@link MessagingBuilder} | |
1898 | * instance and auto-configures it with a predefined behavior named | |
1899 | * "minimal". | |
1900 | * | |
1901 | * Usage example: | |
1902 | * | |
1903 | * <pre> | |
1904 | * <code> | |
1905 | * MessagingService service = MessagingBuilder.minimal() | |
1906 | * .environment() | |
1907 | * .properties("application.properties") | |
1908 | * .and() | |
1909 | * .build(); | |
1910 | * </code> | |
1911 | * </pre> | |
1912 | * | |
1913 | * <p> | |
1914 | * Basically, the minimal behavior: | |
1915 | * <ul> | |
1916 | * <li>Enables all template engines that are present in the classpath and | |
1917 | * configures them</li> | |
1918 | * <li>Catches all uncaught exception to wrap them in order to avoid | |
1919 | * unwanted unchecked exception</li> | |
1920 | * <li>Uses system properties</li> | |
1921 | * <li>Enables and configures useful auto-filling mechanisms (using property | |
1922 | * values and providing email subject from templates)</li> | |
1923 | * <li>Enables mimetype detection</li> | |
1924 | * <li>Enables locating templates, css, images and all other resources using | |
1925 | * lookup prefix ("file:" for files that are present on the filesystem, | |
1926 | * "classpath:" and "" for files that are present in the classpath)</li> | |
1927 | * <li>Enables use of some properties to provide path prefix/suffix for | |
1928 | * locating resources</li> | |
1929 | * <li>Enables images and css inlining used by HTML {@link Email}s</li> | |
1930 | * </ul> | |
1931 | * | |
1932 | * The minimal behavior doesn't automatically auto-configure sender | |
1933 | * implementations. | |
1934 | * | |
1935 | * <p> | |
1936 | * The auto-configurers ( {@link MessagingConfigurer}s) are automatically | |
1937 | * loaded from the classpath. Only configurers that are in the provided | |
1938 | * packages and sub-packages are loaded. Some Ogham modules are optional | |
1939 | * meaning that according to used modules, the behavior will vary. | |
1940 | * | |
1941 | * Loaded {@link MessagingConfigurer}s are applied to the | |
1942 | * {@link MessagingBuilder} only if they are for the "minimal" builder. It | |
1943 | * is accomplished thanks to the {@link ConfigurerFor} annotation (only | |
1944 | * configurers annotated and with {@link ConfigurerFor#targetedBuilder()} | |
1945 | * set to "minimal"). | |
1946 | * | |
1947 | * Loaded configurers with priorities are (if all Ogham modules are used): | |
1948 | * <ul> | |
1949 | * <li><code>DefaultMessagingConfigurer</code>: 100000</li> | |
1950 | * <li><code>DefaultThymeleafEmailConfigurer</code>: 90000</li> | |
1951 | * <li><code>DefaultFreemarkerEmailConfigurer</code>: 80000</li> | |
1952 | * <li><code>DefaultThymeleafSmsConfigurer</code>: 70000</li> | |
1953 | * <li><code>DefaultFreemarkerSmsConfigurer</code>: 60000</li> | |
1954 | * </ul> | |
1955 | * | |
1956 | * TODO: link to whole configuration that is applied by minimal | |
1957 | * | |
1958 | * <p> | |
1959 | * The auto-configured {@link MessagingBuilder} will provide a default | |
1960 | * behavior with no sender implementation. This is useful if you only want | |
1961 | * to use a particular implementation or your custom sender implementation. | |
1962 | * You can still override some behaviors for your needs. | |
1963 | * | |
1964 | * For example: | |
1965 | * | |
1966 | * <pre> | |
1967 | * <code> | |
1968 | * MessagingService service = MessagingBuilder.minimal() | |
1969 | * .environment() | |
1970 | * .properties("application.properties") | |
1971 | * .and() | |
1972 | * .wrapUncaught(false) // overrides and disables wrapUncaught option | |
1973 | * .build(); | |
1974 | * </code> | |
1975 | * </pre> | |
1976 | * | |
1977 | * @param basePackages | |
1978 | * the base packages that are scanned to find | |
1979 | * {@link MessagingConfigurer} implementations | |
1980 | * @return the messaging builder that can be customized | |
1981 | */ | |
1982 | public static MessagingBuilder minimal(String... basePackages) { | |
1983 |
2
1. minimal : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::minimal → NO_COVERAGE 2. minimal : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::minimal → KILLED |
return minimal(true, basePackages); |
1984 | } | |
1985 | ||
1986 | /** | |
1987 | * Static factory method that initializes a {@link MessagingBuilder} | |
1988 | * instance and registers auto-configures but doesn't apply them if | |
1989 | * autoconfigure parameter is false. The | |
1990 | * {@link #configure(ConfigurationPhase)} method must be called manually. | |
1991 | * | |
1992 | * Usage example: | |
1993 | * | |
1994 | * <pre> | |
1995 | * <code> | |
1996 | * MessagingService service = MessagingBuilder.minimal() | |
1997 | * .environment() | |
1998 | * .properties("application.properties") | |
1999 | * .and() | |
2000 | * .build(); | |
2001 | * </code> | |
2002 | * </pre> | |
2003 | * | |
2004 | * <p> | |
2005 | * Basically, the minimal behavior: | |
2006 | * <ul> | |
2007 | * <li>Enables all template engines that are present in the classpath and | |
2008 | * configures them</li> | |
2009 | * <li>Catches all uncaught exception to wrap them in order to avoid | |
2010 | * unwanted unchecked exception</li> | |
2011 | * <li>Uses system properties</li> | |
2012 | * <li>Enables and configures useful auto-filling mechanisms (using property | |
2013 | * values and providing email subject from templates)</li> | |
2014 | * <li>Enables mimetype detection</li> | |
2015 | * <li>Enables locating templates, css, images and all other resources using | |
2016 | * lookup prefix ("file:" for files that are present on the filesystem, | |
2017 | * "classpath:" and "" for files that are present in the classpath)</li> | |
2018 | * <li>Enables use of some properties to provide path prefix/suffix for | |
2019 | * locating resources</li> | |
2020 | * <li>Enables images and css inlining used by HTML {@link Email}s</li> | |
2021 | * </ul> | |
2022 | * | |
2023 | * The minimal behavior doesn't automatically auto-configure sender | |
2024 | * implementations. | |
2025 | * | |
2026 | * <p> | |
2027 | * The auto-configurers ( {@link MessagingConfigurer}s) are automatically | |
2028 | * loaded from the classpath. Only configurers that are in "fr.sii.ogham" | |
2029 | * package and sub-packages are loaded. If you want to load from other | |
2030 | * packages, use {@link #minimal(String...)}. Some Ogham modules are | |
2031 | * optional meaning that according to used modules, the behavior will vary. | |
2032 | * | |
2033 | * Loaded {@link MessagingConfigurer}s are applied to the | |
2034 | * {@link MessagingBuilder} only if they are for the "minimal" builder. It | |
2035 | * is accomplished thanks to the {@link ConfigurerFor} annotation (only | |
2036 | * configurers annotated and with {@link ConfigurerFor#targetedBuilder()} | |
2037 | * set to "minimal"). | |
2038 | * | |
2039 | * Loaded configurers with priorities are (if all Ogham modules are used): | |
2040 | * <ul> | |
2041 | * <li><code>DefaultMessagingConfigurer</code>: 100000</li> | |
2042 | * <li><code>DefaultThymeleafEmailConfigurer</code>: 90000</li> | |
2043 | * <li><code>DefaultFreemarkerEmailConfigurer</code>: 80000</li> | |
2044 | * <li><code>DefaultThymeleafSmsConfigurer</code>: 70000</li> | |
2045 | * <li><code>DefaultFreemarkerSmsConfigurer</code>: 60000</li> | |
2046 | * </ul> | |
2047 | * | |
2048 | * TODO: link to whole configuration that is applied by minimal | |
2049 | * | |
2050 | * <p> | |
2051 | * The auto-configured {@link MessagingBuilder} will provide a default | |
2052 | * behavior with no sender implementation. This is useful if you only want | |
2053 | * to use a particular implementation or your custom sender implementation. | |
2054 | * You can still override some behaviors for your needs. | |
2055 | * | |
2056 | * For example: | |
2057 | * | |
2058 | * <pre> | |
2059 | * <code> | |
2060 | * MessagingService service = MessagingBuilder.minimal() | |
2061 | * .environment() | |
2062 | * .properties("application.properties") | |
2063 | * .and() | |
2064 | * .wrapUncaught(false) // overrides and disables wrapUncaught option | |
2065 | * .build(); | |
2066 | * </code> | |
2067 | * </pre> | |
2068 | * | |
2069 | * @param autoconfigure | |
2070 | * true to automatically apply found configurers, false to | |
2071 | * configure manually later by calling | |
2072 | * {@link #configure(ConfigurationPhase)} | |
2073 | * @return the messaging builder that can be customized | |
2074 | */ | |
2075 | public static MessagingBuilder minimal(boolean autoconfigure) { | |
2076 |
1
1. minimal : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::minimal → NO_COVERAGE |
return minimal(autoconfigure, BASE_PACKAGE); |
2077 | } | |
2078 | ||
2079 | /** | |
2080 | * Static factory method that initializes a {@link MessagingBuilder} | |
2081 | * instance and registers auto-configures but doesn't apply them if | |
2082 | * autoconfigure parameter is false. The | |
2083 | * {@link #configure(ConfigurationPhase)} method must be called manually. | |
2084 | * | |
2085 | * | |
2086 | * Usage example: | |
2087 | * | |
2088 | * <pre> | |
2089 | * <code> | |
2090 | * MessagingService service = MessagingBuilder.minimal() | |
2091 | * .environment() | |
2092 | * .properties("application.properties") | |
2093 | * .and() | |
2094 | * .build(); | |
2095 | * </code> | |
2096 | * </pre> | |
2097 | * | |
2098 | * <p> | |
2099 | * Basically, the minimal behavior: | |
2100 | * <ul> | |
2101 | * <li>Enables all template engines that are present in the classpath and | |
2102 | * configures them</li> | |
2103 | * <li>Catches all uncaught exception to wrap them in order to avoid | |
2104 | * unwanted unchecked exception</li> | |
2105 | * <li>Uses system properties</li> | |
2106 | * <li>Enables and configures useful auto-filling mechanisms (using property | |
2107 | * values and providing email subject from templates)</li> | |
2108 | * <li>Enables mimetype detection</li> | |
2109 | * <li>Enables locating templates, css, images and all other resources using | |
2110 | * lookup prefix ("file:" for files that are present on the filesystem, | |
2111 | * "classpath:" and "" for files that are present in the classpath)</li> | |
2112 | * <li>Enables use of some properties to provide path prefix/suffix for | |
2113 | * locating resources</li> | |
2114 | * <li>Enables images and css inlining used by HTML {@link Email}s</li> | |
2115 | * </ul> | |
2116 | * | |
2117 | * The minimal behavior doesn't automatically auto-configure sender | |
2118 | * implementations. | |
2119 | * | |
2120 | * <p> | |
2121 | * The auto-configurers ( {@link MessagingConfigurer}s) are automatically | |
2122 | * loaded from the classpath. Only configurers that are in the provided | |
2123 | * packages and sub-packages are loaded. Some Ogham modules are optional | |
2124 | * meaning that according to used modules, the behavior will vary. | |
2125 | * | |
2126 | * Loaded {@link MessagingConfigurer}s are applied to the | |
2127 | * {@link MessagingBuilder} only if they are for the "minimal" builder. It | |
2128 | * is accomplished thanks to the {@link ConfigurerFor} annotation (only | |
2129 | * configurers annotated and with {@link ConfigurerFor#targetedBuilder()} | |
2130 | * set to "minimal"). | |
2131 | * | |
2132 | * Loaded configurers with priorities are (if all Ogham modules are used): | |
2133 | * <ul> | |
2134 | * <li><code>DefaultMessagingConfigurer</code>: 100000</li> | |
2135 | * <li><code>DefaultThymeleafEmailConfigurer</code>: 90000</li> | |
2136 | * <li><code>DefaultFreemarkerEmailConfigurer</code>: 80000</li> | |
2137 | * <li><code>DefaultThymeleafSmsConfigurer</code>: 70000</li> | |
2138 | * <li><code>DefaultFreemarkerSmsConfigurer</code>: 60000</li> | |
2139 | * </ul> | |
2140 | * | |
2141 | * TODO: link to whole configuration that is applied by minimal | |
2142 | * | |
2143 | * <p> | |
2144 | * The auto-configured {@link MessagingBuilder} will provide a default | |
2145 | * behavior with no sender implementation. This is useful if you only want | |
2146 | * to use a particular implementation or your custom sender implementation. | |
2147 | * You can still override some behaviors for your needs. | |
2148 | * | |
2149 | * For example: | |
2150 | * | |
2151 | * <pre> | |
2152 | * <code> | |
2153 | * MessagingService service = MessagingBuilder.minimal() | |
2154 | * .environment() | |
2155 | * .properties("application.properties") | |
2156 | * .and() | |
2157 | * .wrapUncaught(false) // overrides and disables wrapUncaught option | |
2158 | * .build(); | |
2159 | * </code> | |
2160 | * </pre> | |
2161 | * | |
2162 | * @param autoconfigure | |
2163 | * true to automatically apply found configurers, false to | |
2164 | * configure manually later by calling | |
2165 | * {@link #configure(ConfigurationPhase)} | |
2166 | * @param basePackages | |
2167 | * the base packages that are scanned to find | |
2168 | * {@link MessagingConfigurer} implementations | |
2169 | * @return the messaging builder that can be customized | |
2170 | */ | |
2171 | public static MessagingBuilder minimal(boolean autoconfigure, String... basePackages) { | |
2172 |
4
1. lambda$minimal$1 : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::lambda$minimal$1 → NO_COVERAGE 2. minimal : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::minimal → NO_COVERAGE 3. lambda$minimal$1 : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::lambda$minimal$1 → KILLED 4. minimal : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::minimal → KILLED |
return minimal(() -> new MessagingBuilder(autoconfigure), autoconfigure, basePackages); |
2173 | } | |
2174 | ||
2175 | /** | |
2176 | * Static factory method that initializes a {@link MessagingBuilder} | |
2177 | * instance and registers auto-configures but doesn't apply them if | |
2178 | * autoconfigure parameter is false. The | |
2179 | * {@link #configure(ConfigurationPhase)} method must be called manually. | |
2180 | * | |
2181 | * <p> | |
2182 | * This method allows to use a custom {@link MessagingBuilder} | |
2183 | * implementation. | |
2184 | * | |
2185 | * <p> | |
2186 | * <strong>NOTE:</strong> This is for advanced usage only. | |
2187 | * | |
2188 | * | |
2189 | * Usage example: | |
2190 | * | |
2191 | * <pre> | |
2192 | * <code> | |
2193 | * MessagingService service = MessagingBuilder.minimal() | |
2194 | * .environment() | |
2195 | * .properties("application.properties") | |
2196 | * .and() | |
2197 | * .build(); | |
2198 | * </code> | |
2199 | * </pre> | |
2200 | * | |
2201 | * <p> | |
2202 | * Basically, the minimal behavior: | |
2203 | * <ul> | |
2204 | * <li>Enables all template engines that are present in the classpath and | |
2205 | * configures them</li> | |
2206 | * <li>Catches all uncaught exception to wrap them in order to avoid | |
2207 | * unwanted unchecked exception</li> | |
2208 | * <li>Uses system properties</li> | |
2209 | * <li>Enables and configures useful auto-filling mechanisms (using property | |
2210 | * values and providing email subject from templates)</li> | |
2211 | * <li>Enables mimetype detection</li> | |
2212 | * <li>Enables locating templates, css, images and all other resources using | |
2213 | * lookup prefix ("file:" for files that are present on the filesystem, | |
2214 | * "classpath:" and "" for files that are present in the classpath)</li> | |
2215 | * <li>Enables use of some properties to provide path prefix/suffix for | |
2216 | * locating resources</li> | |
2217 | * <li>Enables images and css inlining used by HTML {@link Email}s</li> | |
2218 | * </ul> | |
2219 | * | |
2220 | * The minimal behavior doesn't automatically auto-configure sender | |
2221 | * implementations. | |
2222 | * | |
2223 | * <p> | |
2224 | * The auto-configurers ( {@link MessagingConfigurer}s) are automatically | |
2225 | * loaded from the classpath. Only configurers that are in the provided | |
2226 | * packages and sub-packages are loaded. Some Ogham modules are optional | |
2227 | * meaning that according to used modules, the behavior will vary. | |
2228 | * | |
2229 | * Loaded {@link MessagingConfigurer}s are applied to the | |
2230 | * {@link MessagingBuilder} only if they are for the "minimal" builder. It | |
2231 | * is accomplished thanks to the {@link ConfigurerFor} annotation (only | |
2232 | * configurers annotated and with {@link ConfigurerFor#targetedBuilder()} | |
2233 | * set to "minimal"). | |
2234 | * | |
2235 | * Loaded configurers with priorities are (if all Ogham modules are used): | |
2236 | * <ul> | |
2237 | * <li><code>DefaultMessagingConfigurer</code>: 100000</li> | |
2238 | * <li><code>DefaultThymeleafEmailConfigurer</code>: 90000</li> | |
2239 | * <li><code>DefaultFreemarkerEmailConfigurer</code>: 80000</li> | |
2240 | * <li><code>DefaultThymeleafSmsConfigurer</code>: 70000</li> | |
2241 | * <li><code>DefaultFreemarkerSmsConfigurer</code>: 60000</li> | |
2242 | * </ul> | |
2243 | * | |
2244 | * TODO: link to whole configuration that is applied by minimal | |
2245 | * | |
2246 | * <p> | |
2247 | * The auto-configured {@link MessagingBuilder} will provide a default | |
2248 | * behavior with no sender implementation. This is useful if you only want | |
2249 | * to use a particular implementation or your custom sender implementation. | |
2250 | * You can still override some behaviors for your needs. | |
2251 | * | |
2252 | * For example: | |
2253 | * | |
2254 | * <pre> | |
2255 | * <code> | |
2256 | * MessagingService service = MessagingBuilder.minimal() | |
2257 | * .environment() | |
2258 | * .properties("application.properties") | |
2259 | * .and() | |
2260 | * .wrapUncaught(false) // overrides and disables wrapUncaught option | |
2261 | * .build(); | |
2262 | * </code> | |
2263 | * </pre> | |
2264 | * | |
2265 | * @param factory | |
2266 | * the factory used to create the {@link MessagingBuilder} | |
2267 | * instance | |
2268 | * @param autoconfigure | |
2269 | * true to automatically apply found configurers, false to | |
2270 | * configure manually later by calling | |
2271 | * {@link #configure(ConfigurationPhase)} | |
2272 | * @param basePackages | |
2273 | * the base packages that are scanned to find | |
2274 | * {@link MessagingConfigurer} implementations | |
2275 | * @param <T> | |
2276 | * the type of final {@link MessagingBuilder} | |
2277 | * @return the messaging builder that can be customized | |
2278 | */ | |
2279 | public static <T extends MessagingBuilder> T minimal(Supplier<T> factory, boolean autoconfigure, String... basePackages) { | |
2280 | T builder = factory.get(); | |
2281 |
2
1. minimal : removed call to fr/sii/ogham/core/builder/MessagingBuilder::findAndRegister → SURVIVED 2. minimal : removed call to fr/sii/ogham/core/builder/MessagingBuilder::findAndRegister → NO_COVERAGE |
findAndRegister(builder, "minimal", basePackages); |
2282 |
2
1. minimal : negated conditional → NO_COVERAGE 2. minimal : negated conditional → SURVIVED |
if (autoconfigure) { |
2283 |
2
1. minimal : removed call to fr/sii/ogham/core/builder/MessagingBuilder::configure → NO_COVERAGE 2. minimal : removed call to fr/sii/ogham/core/builder/MessagingBuilder::configure → SURVIVED |
builder.configure(ConfigurationPhase.AFTER_INIT); |
2284 | } | |
2285 |
2
1. minimal : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::minimal → NO_COVERAGE 2. minimal : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder::minimal → KILLED |
return builder; |
2286 | } | |
2287 | ||
2288 | /** | |
2289 | * You can use this method if {@link #standard()} and {@link #minimal()} | |
2290 | * factory methods doesn't fit your needs. The aim is to auto-configure a | |
2291 | * builder with matching configurers. | |
2292 | * | |
2293 | * Utility method that searches all {@link MessagingConfigurer}s that are in | |
2294 | * the classpath. Only configurers that are in the provided packages (and | |
2295 | * sub-packages) are loaded. | |
2296 | * | |
2297 | * Once configurers are found, they are filtered thanks to information | |
2298 | * provided by {@link ConfigurerFor} annotation. Only configurers with | |
2299 | * {@link ConfigurerFor#targetedBuilder()} value that matches the | |
2300 | * builderName parameter are kept. | |
2301 | * | |
2302 | * The found and filtered configurers are registered into the provided | |
2303 | * builder instance. | |
2304 | * | |
2305 | * @param builder | |
2306 | * the builder to configure with matching configurers | |
2307 | * @param builderName | |
2308 | * the name that is referenced by | |
2309 | * {@link ConfigurerFor#targetedBuilder()} | |
2310 | * @param basePackages | |
2311 | * the packages that are scanned to find | |
2312 | * {@link MessagingConfigurer} implementations | |
2313 | */ | |
2314 | public static void findAndRegister(MessagingBuilder builder, String builderName, String... basePackages) { | |
2315 | Reflections reflections = new Reflections(basePackages, new SubTypesScanner()); | |
2316 | Set<Class<? extends MessagingConfigurer>> configurerClasses = reflections.getSubTypesOf(MessagingConfigurer.class); | |
2317 | for (Class<? extends MessagingConfigurer> configurerClass : configurerClasses) { | |
2318 | ConfigurerFor annotation = configurerClass.getAnnotation(ConfigurerFor.class); | |
2319 |
16
1. findAndRegister : negated conditional → NO_COVERAGE 2. findAndRegister : negated conditional → NO_COVERAGE 3. findAndRegister : negated conditional → KILLED 4. findAndRegister : negated conditional → KILLED 5. findAndRegister : negated conditional → KILLED 6. findAndRegister : negated conditional → KILLED 7. findAndRegister : negated conditional → KILLED 8. findAndRegister : negated conditional → KILLED 9. findAndRegister : negated conditional → KILLED 10. findAndRegister : negated conditional → KILLED 11. findAndRegister : negated conditional → KILLED 12. findAndRegister : negated conditional → KILLED 13. findAndRegister : negated conditional → KILLED 14. findAndRegister : negated conditional → KILLED 15. findAndRegister : negated conditional → KILLED 16. findAndRegister : negated conditional → KILLED |
if (annotation != null && asList(annotation.targetedBuilder()).contains(builderName)) { |
2320 |
8
1. findAndRegister : removed call to fr/sii/ogham/core/builder/MessagingBuilder::register → NO_COVERAGE 2. findAndRegister : removed call to fr/sii/ogham/core/builder/MessagingBuilder::register → KILLED 3. findAndRegister : removed call to fr/sii/ogham/core/builder/MessagingBuilder::register → KILLED 4. findAndRegister : removed call to fr/sii/ogham/core/builder/MessagingBuilder::register → KILLED 5. findAndRegister : removed call to fr/sii/ogham/core/builder/MessagingBuilder::register → KILLED 6. findAndRegister : removed call to fr/sii/ogham/core/builder/MessagingBuilder::register → KILLED 7. findAndRegister : removed call to fr/sii/ogham/core/builder/MessagingBuilder::register → KILLED 8. findAndRegister : removed call to fr/sii/ogham/core/builder/MessagingBuilder::register → KILLED |
register(builder, builderName, configurerClass, annotation); |
2321 | } | |
2322 | } | |
2323 | } | |
2324 | ||
2325 | private static void register(MessagingBuilder builder, String builderName, Class<? extends MessagingConfigurer> configurerClass, ConfigurerFor annotation) { | |
2326 | try { | |
2327 | builder.register(configurerClass.newInstance(), annotation.priority(), annotation.phase()); | |
2328 | } catch (InstantiationException | IllegalAccessException e) { | |
2329 | throw new BuildException("Failed to register custom auto-discovered configurer (" + configurerClass.getSimpleName() + ") for " + builderName + " messaging builder", e); | |
2330 | } | |
2331 | } | |
2332 | ||
2333 | private List<ConditionalSender> buildSenders() { | |
2334 | List<ConditionalSender> senders = new ArrayList<>(); | |
2335 |
7
1. buildSenders : negated conditional → SURVIVED 2. buildSenders : negated conditional → NO_COVERAGE 3. buildSenders : negated conditional → KILLED 4. buildSenders : negated conditional → KILLED 5. buildSenders : negated conditional → KILLED 6. buildSenders : negated conditional → KILLED 7. buildSenders : negated conditional → KILLED |
if (emailBuilder != null) { |
2336 | LOG.debug("building email sender with {}", emailBuilder); | |
2337 | senders.add(emailBuilder.build()); | |
2338 | } | |
2339 |
8
1. buildSenders : negated conditional → NO_COVERAGE 2. buildSenders : negated conditional → KILLED 3. buildSenders : negated conditional → KILLED 4. buildSenders : negated conditional → KILLED 5. buildSenders : negated conditional → KILLED 6. buildSenders : negated conditional → KILLED 7. buildSenders : negated conditional → KILLED 8. buildSenders : negated conditional → KILLED |
if (smsBuilder != null) { |
2340 | LOG.debug("building email sender with {}", emailBuilder); | |
2341 | senders.add(smsBuilder.build()); | |
2342 | } | |
2343 |
8
1. buildSenders : replaced return value with Collections.emptyList for fr/sii/ogham/core/builder/MessagingBuilder::buildSenders → NO_COVERAGE 2. buildSenders : replaced return value with Collections.emptyList for fr/sii/ogham/core/builder/MessagingBuilder::buildSenders → KILLED 3. buildSenders : replaced return value with Collections.emptyList for fr/sii/ogham/core/builder/MessagingBuilder::buildSenders → KILLED 4. buildSenders : replaced return value with Collections.emptyList for fr/sii/ogham/core/builder/MessagingBuilder::buildSenders → KILLED 5. buildSenders : replaced return value with Collections.emptyList for fr/sii/ogham/core/builder/MessagingBuilder::buildSenders → KILLED 6. buildSenders : replaced return value with Collections.emptyList for fr/sii/ogham/core/builder/MessagingBuilder::buildSenders → KILLED 7. buildSenders : replaced return value with Collections.emptyList for fr/sii/ogham/core/builder/MessagingBuilder::buildSenders → KILLED 8. buildSenders : replaced return value with Collections.emptyList for fr/sii/ogham/core/builder/MessagingBuilder::buildSenders → KILLED |
return senders; |
2344 | } | |
2345 | ||
2346 | private boolean alreadyConfigured(ConfigurationPhase phase) { | |
2347 | Boolean configured = alreadyConfigured.get(phase); | |
2348 |
17
1. alreadyConfigured : replaced boolean return with true for fr/sii/ogham/core/builder/MessagingBuilder::alreadyConfigured → NO_COVERAGE 2. alreadyConfigured : negated conditional → NO_COVERAGE 3. alreadyConfigured : negated conditional → NO_COVERAGE 4. alreadyConfigured : replaced boolean return with true for fr/sii/ogham/core/builder/MessagingBuilder::alreadyConfigured → KILLED 5. alreadyConfigured : replaced boolean return with true for fr/sii/ogham/core/builder/MessagingBuilder::alreadyConfigured → KILLED 6. alreadyConfigured : replaced boolean return with true for fr/sii/ogham/core/builder/MessagingBuilder::alreadyConfigured → KILLED 7. alreadyConfigured : replaced boolean return with true for fr/sii/ogham/core/builder/MessagingBuilder::alreadyConfigured → KILLED 8. alreadyConfigured : replaced boolean return with true for fr/sii/ogham/core/builder/MessagingBuilder::alreadyConfigured → KILLED 9. alreadyConfigured : replaced boolean return with true for fr/sii/ogham/core/builder/MessagingBuilder::alreadyConfigured → KILLED 10. alreadyConfigured : replaced boolean return with true for fr/sii/ogham/core/builder/MessagingBuilder::alreadyConfigured → KILLED 11. alreadyConfigured : negated conditional → KILLED 12. alreadyConfigured : negated conditional → KILLED 13. alreadyConfigured : negated conditional → KILLED 14. alreadyConfigured : negated conditional → KILLED 15. alreadyConfigured : negated conditional → KILLED 16. alreadyConfigured : negated conditional → KILLED 17. alreadyConfigured : negated conditional → KILLED |
return configured != null && configured; |
2349 | } | |
2350 | ||
2351 | private static class ConfigurerWithPhase { | |
2352 | private final MessagingConfigurer configurer; | |
2353 | private final ConfigurationPhase phase; | |
2354 | ||
2355 | public ConfigurerWithPhase(MessagingConfigurer configurer, ConfigurationPhase phase) { | |
2356 | super(); | |
2357 | this.configurer = configurer; | |
2358 | this.phase = phase; | |
2359 | } | |
2360 | ||
2361 | public MessagingConfigurer getConfigurer() { | |
2362 |
8
1. getConfigurer : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder$ConfigurerWithPhase::getConfigurer → NO_COVERAGE 2. getConfigurer : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder$ConfigurerWithPhase::getConfigurer → KILLED 3. getConfigurer : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder$ConfigurerWithPhase::getConfigurer → KILLED 4. getConfigurer : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder$ConfigurerWithPhase::getConfigurer → KILLED 5. getConfigurer : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder$ConfigurerWithPhase::getConfigurer → KILLED 6. getConfigurer : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder$ConfigurerWithPhase::getConfigurer → KILLED 7. getConfigurer : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder$ConfigurerWithPhase::getConfigurer → KILLED 8. getConfigurer : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder$ConfigurerWithPhase::getConfigurer → KILLED |
return configurer; |
2363 | } | |
2364 | ||
2365 | public ConfigurationPhase getPhase() { | |
2366 |
8
1. getPhase : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder$ConfigurerWithPhase::getPhase → NO_COVERAGE 2. getPhase : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder$ConfigurerWithPhase::getPhase → KILLED 3. getPhase : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder$ConfigurerWithPhase::getPhase → KILLED 4. getPhase : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder$ConfigurerWithPhase::getPhase → KILLED 5. getPhase : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder$ConfigurerWithPhase::getPhase → KILLED 6. getPhase : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder$ConfigurerWithPhase::getPhase → KILLED 7. getPhase : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder$ConfigurerWithPhase::getPhase → KILLED 8. getPhase : replaced return value with null for fr/sii/ogham/core/builder/MessagingBuilder$ConfigurerWithPhase::getPhase → KILLED |
return phase; |
2367 | } | |
2368 | ||
2369 | } | |
2370 | } | |
Mutations | ||
334 |
1.1 2.2 |
|
364 |
1.1 2.2 |
|
379 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
383 |
1.1 2.2 3.3 4.4 |
|
385 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
437 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
505 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
557 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
617 |
1.1 |
|
618 |
1.1 |
|
680 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
979 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
982 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
1223 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
1226 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
1252 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 |
|
1253 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
1259 |
1.1 2.2 3.3 |
|
1263 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
1267 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
1271 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
1275 |
1.1 2.2 3.3 |
|
1279 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
1283 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
1286 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
1290 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
1294 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
1306 |
1.1 2.2 3.3 4.4 |
|
1398 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
1492 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
1589 |
1.1 |
|
1688 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 10.10 11.11 12.12 |
|
1801 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
1802 |
1.1 2.2 |
|
1803 |
1.1 2.2 |
|
1805 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
1893 |
1.1 2.2 |
|
1983 |
1.1 2.2 |
|
2076 |
1.1 |
|
2172 |
1.1 2.2 3.3 4.4 |
|
2281 |
1.1 2.2 |
|
2282 |
1.1 2.2 |
|
2283 |
1.1 2.2 |
|
2285 |
1.1 2.2 |
|
2319 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 10.10 11.11 12.12 13.13 14.14 15.15 16.16 |
|
2320 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
2335 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 |
|
2339 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
2343 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
2348 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 10.10 11.11 12.12 13.13 14.14 15.15 16.16 17.17 |
|
2362 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
2366 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |