use of org.nhindirect.gateway.smtp.dsn.DSNCreator in project nhin-d by DirectProject.
the class AbstractNotificationAwareMailet method createDSNGenerator.
/**
* Creates the DSNCreator object
* @param initModules The initial Guice modules created by the init() method
*/
protected void createDSNGenerator(final Collection<Module> initModules) {
Collection<Module> modules = initModules;
// attempt to use the existing modules first
final boolean usingDefaultMoudles = (modules == null);
if (modules == null) {
// create a default module
final Provider<DSNCreator> provider = getDSNProvider();
if (provider == null)
return;
final DSNCreatorProviderModule module = DSNCreatorProviderModule.create(provider);
modules = Arrays.asList((Module) module);
}
Injector dsnInjector = Guice.createInjector(modules);
try {
dsnCreator = dsnInjector.getInstance(DSNCreator.class);
} catch (Exception e) {
///CLOVER:OFF
LOGGER.debug("First attempt to create DSNCreator failed.", e);
if (!usingDefaultMoudles)
LOGGER.debug("Will attempt to create from default DSNCreator from Guice module.");
else
LOGGER.warn("DSNCreator already attempted to use the defualt DSNCreator Guice module. DSN creation will be disabled.");
///CLOVER:ON
}
// try again using the default Guice module
if (dsnCreator == null && !usingDefaultMoudles) {
try {
// create a default module
final Provider<DSNCreator> provider = getDSNProvider();
if (provider == null)
return;
final DSNCreatorProviderModule module = DSNCreatorProviderModule.create(provider);
modules = Arrays.asList((Module) module);
dsnInjector = Guice.createInjector(modules);
dsnCreator = dsnInjector.getInstance(DSNCreator.class);
}///CLOVER:OFF
catch (Exception e) {
LOGGER.warn("Failed to create DSNCreator. DSN creation will be disabled.");
}
///CLOVER:ON
}
}
Aggregations