| 1 | package fr.sii.ogham.spring.email; | |
| 2 | ||
| 3 | import fr.sii.ogham.email.sender.impl.JavaxMailSender; | |
| 4 | import fr.sii.ogham.spring.email.condition.JavaxActivationDataHandlersAvailable; | |
| 5 | import fr.sii.ogham.spring.email.condition.JavaxMailServiceProvidersAvailable; | |
| 6 | import org.springframework.beans.factory.annotation.Autowired; | |
| 7 | import org.springframework.boot.autoconfigure.AutoConfigureAfter; | |
| 8 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | |
| 9 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | |
| 10 | import org.springframework.boot.autoconfigure.mail.MailProperties; | |
| 11 | import org.springframework.boot.autoconfigure.mail.MailSenderAutoConfiguration; | |
| 12 | import org.springframework.boot.context.properties.EnableConfigurationProperties; | |
| 13 | import org.springframework.context.annotation.Bean; | |
| 14 | import org.springframework.context.annotation.Conditional; | |
| 15 | import org.springframework.context.annotation.Configuration; | |
| 16 | ||
| 17 | @Configuration | |
| 18 | @ConditionalOnClass({ | |
| 19 | // need mail api | |
| 20 | javax.mail.internet.MimeMessage.class, | |
| 21 | javax.mail.Session.class, | |
| 22 | // import hard coded in Session | |
| 23 | com.sun.mail.util.MailLogger.class, | |
| 24 | // need activation api | |
| 25 | javax.activation.MimeType.class, | |
| 26 | javax.activation.DataHandler.class, | |
| 27 | // need ogham sender | |
| 28 | JavaxMailSender.class | |
| 29 | }) | |
| 30 | // also need implementation but relies on ServiceLoader | |
| 31 | // also check that it is consistent and that mail could be sent | |
| 32 | @Conditional({ | |
| 33 | JavaxMailServiceProvidersAvailable.class, | |
| 34 | JavaxActivationDataHandlersAvailable.class | |
| 35 | }) | |
| 36 | @EnableConfigurationProperties(OghamJavaMailProperties.class) | |
| 37 | @AutoConfigureAfter(MailSenderAutoConfiguration.class) | |
| 38 | public class OghamJavaxMailConfiguration { | |
| 39 | ||
| 40 | @Bean | |
| 41 | @ConditionalOnMissingBean(SpringMailJavaxConfigurer.class) | |
| 42 | public SpringMailJavaxConfigurer springMailJavaxConfigurer( | |
| 43 | @Autowired(required=false) OghamJavaMailProperties properties, | |
| 44 | @Autowired(required=false) MailProperties springProperties) { | |
| 45 |
1
1. springMailJavaxConfigurer : replaced return value with null for fr/sii/ogham/spring/email/OghamJavaxMailConfiguration::springMailJavaxConfigurer → NO_COVERAGE |
return new SpringMailJavaxConfigurer(properties, springProperties); |
| 46 | } | |
| 47 | } | |
Mutations | ||
| 45 |
1.1 |