19 package org.turro.mail.provider;
21 import java.io.IOException;
22 import org.turro.elephant.context.Application;
23 import org.turro.elephant.context.ElephantContext;
24 import org.turro.elephant.context.IConstructor;
25 import org.turro.file.Document;
26 import org.turro.log.WebLoggers;
27 import org.turro.mail.pool.MailMessagePool;
35 public static final String
GENERIC =
"Generic";
46 if(providers !=
null) {
48 if(provider !=
null) {
56 if(providers !=
null) {
57 return providers.get(name);
68 private static final String PROVIDERS_FILE =
"/WEB-INF/elephant/conf/mail/providers.json";
73 providers = loadProviders();
76 private MailProviderSet loadProviders() {
77 Document providersFile = Document.from(ElephantContext.getRealPath(PROVIDERS_FILE));
78 if(providersFile.exists()) {
80 return MailProviderSet.from(providersFile.content());
81 }
catch (IOException ex) {
82 WebLoggers.severe(
this).exception(ex).log();
85 MailProviderSet mailProviderSet = MailProviderMigration.migrate();
87 providersFile.content(mailProviderSet.toJson());
88 return mailProviderSet;
89 }
catch (IOException ex) {
90 WebLoggers.severe(
this).exception(ex).log();
IConstructor getConstructor()
static Application getApplication()
MailProvider getProvider(String name)
MailMessagePool getGeneric()
static MailProviders instance()
static final String GENERIC
MailMessagePool getPool(IConstructor constructor, String name)
MailMessagePool getGeneric(IConstructor constructor)