Search in sources :

Example 1 with TxService

use of org.nhindirect.common.tx.TxService in project nhin-d by DirectProject.

the class AbstractNotificationAwareMailet method createTxServices.

/**
	 * Creates the Tx services
	 * @param initModules The initial Guice modules created by the init() method
	 */
protected void createTxServices(final Collection<Module> initModules) {
    Collection<Module> modules = initModules;
    // now try to get the TxParser
    // attempt to use the existing modules first
    final boolean usingDefaultTxServiceMoudles = (modules == null);
    if (modules == null) {
        // create a default module for the TxService
        modules = createDefaultTxServiceModules();
    }
    Injector txInjector = Guice.createInjector(modules);
    try {
        txParser = txInjector.getInstance(TxDetailParser.class);
        txService = txInjector.getInstance(TxService.class);
    } catch (Exception e) {
        LOGGER.debug("First attempt to create message monitoring service failed.", e);
        if (!usingDefaultTxServiceMoudles)
            LOGGER.debug("Will attempt to create from default Tx service Guice module.");
        else
            ///CLOVER:OFF
            LOGGER.warn("Monitoring service already attempted to use the defualt Tx service Guice module.  Monitoring will be disabled.");
    ///CLOVER:ON
    }
    // try again using the default Guice module
    if ((txParser == null || txService == null) && !usingDefaultTxServiceMoudles) {
        try {
            // create a default module for the TxService
            modules = createDefaultTxServiceModules();
            txInjector = Guice.createInjector(modules);
            if (txParser == null)
                txParser = txInjector.getInstance(TxDetailParser.class);
            if (txService == null)
                txService = txInjector.getInstance(TxService.class);
        }///CLOVER:OFF
         catch (Exception e) {
            LOGGER.warn("Failed to create message monitoring service.  Monitoring will be disabled");
        }
    ///CLOVER:ON
    }
}
Also used : Injector(com.google.inject.Injector) TxDetailParser(org.nhindirect.common.tx.TxDetailParser) Module(com.google.inject.Module) DefaultTxDetailParserModule(org.nhindirect.common.tx.module.DefaultTxDetailParserModule) ProviderTxServiceModule(org.nhindirect.common.tx.module.ProviderTxServiceModule) DSNCreatorProviderModule(org.nhindirect.gateway.smtp.dsn.module.DSNCreatorProviderModule) TxService(org.nhindirect.common.tx.TxService) MessagingException(javax.mail.MessagingException)

Aggregations

Injector (com.google.inject.Injector)1 Module (com.google.inject.Module)1 MessagingException (javax.mail.MessagingException)1 TxDetailParser (org.nhindirect.common.tx.TxDetailParser)1 TxService (org.nhindirect.common.tx.TxService)1 DefaultTxDetailParserModule (org.nhindirect.common.tx.module.DefaultTxDetailParserModule)1 ProviderTxServiceModule (org.nhindirect.common.tx.module.ProviderTxServiceModule)1 DSNCreatorProviderModule (org.nhindirect.gateway.smtp.dsn.module.DSNCreatorProviderModule)1