Search in sources :

Example 1 with IProcessorModule

use of com.helger.as2lib.processor.module.IProcessorModule in project as2-lib by phax.

the class AbstractMessageProcessor method executeAction.

/**
 * Execution the provided action with the registered modules.
 *
 * @param sAction
 *        Action to execute. Never <code>null</code>.
 * @param aMsg
 *        Message it is about. Never <code>null</code>.
 * @param aOptions
 *        Optional options map to be used. May be <code>null</code>.
 * @throws AS2ProcessorException
 *         In case of error
 */
protected final void executeAction(@Nonnull final String sAction, @Nonnull final IMessage aMsg, @Nullable final Map<String, Object> aOptions) throws AS2Exception {
    final ICommonsList<AS2Exception> aCauses = new CommonsArrayList<>();
    final ICommonsList<IProcessorModule> aModulesFound = new CommonsArrayList<>();
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("  handling action '" + sAction + "' on message '" + aMsg.getMessageID() + "' with options " + aOptions);
    final ICommonsList<IProcessorModule> aAllModules = getAllModules();
    for (final IProcessorModule aModule : aAllModules) if (aModule.canHandle(sAction, aMsg, aOptions)) {
        if (LOGGER.isDebugEnabled())
            LOGGER.debug("  handling action '" + sAction + "' with module " + aModule);
        try {
            aModulesFound.add(aModule);
            aModule.handle(sAction, aMsg, aOptions);
        } catch (final AS2Exception ex) {
            aCauses.add(ex);
        }
    } else {
        if (LOGGER.isTraceEnabled())
            LOGGER.trace("  Not handling action '" + sAction + "' with module " + aModule);
    }
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("  action '" + sAction + "' was handled by modules: " + aModulesFound);
    if (aCauses.isNotEmpty()) {
        if (LOGGER.isDebugEnabled())
            LOGGER.debug("  action '" + sAction + "' was handled but failed: " + aCauses);
        throw new AS2ProcessorException(this, aCauses);
    }
    if (aModulesFound.isEmpty()) {
        if (LOGGER.isDebugEnabled())
            LOGGER.debug("  no modules found for '" + sAction + "'; modules are: " + aAllModules);
        throw new AS2NoModuleException(sAction, aMsg, aOptions);
    }
}
Also used : AS2Exception(com.helger.as2lib.exception.AS2Exception) IProcessorModule(com.helger.as2lib.processor.module.IProcessorModule) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList)

Example 2 with IProcessorModule

use of com.helger.as2lib.processor.module.IProcessorModule in project as2-lib by phax.

the class AS2ServletXMLSession method _loadProcessorModule.

private void _loadProcessorModule(@Nonnull final IMessageProcessor aMsgProcessor, @Nonnull final IMicroElement eModule) throws AS2Exception {
    final IProcessorModule aProcessorModule = AS2XMLHelper.createComponent(eModule, IProcessorModule.class, this, m_sBaseDirectory);
    aMsgProcessor.addModule(aProcessorModule);
    LOGGER.info("  Loaded processor module " + aProcessorModule.getName());
}
Also used : IProcessorModule(com.helger.as2lib.processor.module.IProcessorModule)

Example 3 with IProcessorModule

use of com.helger.as2lib.processor.module.IProcessorModule in project as2-server by phax.

the class AS2ServerXMLSession method loadProcessorModule.

protected void loadProcessorModule(@Nonnull final IMessageProcessor aMsgProcessor, @Nonnull final IMicroElement eModule) throws OpenAS2Exception {
    final IProcessorModule aProcessorModule = AS2XMLHelper.createComponent(eModule, IProcessorModule.class, this, m_sBaseDirectory);
    aMsgProcessor.addModule(aProcessorModule);
    LOGGER.info("    loaded processor module " + aProcessorModule.getName());
}
Also used : IProcessorModule(com.helger.as2lib.processor.module.IProcessorModule)

Example 4 with IProcessorModule

use of com.helger.as2lib.processor.module.IProcessorModule in project as2-lib by phax.

the class AS2ServerXMLSession method loadProcessorModule.

protected void loadProcessorModule(@Nonnull final IMessageProcessor aMsgProcessor, @Nonnull final IMicroElement eModule) throws AS2Exception {
    final IProcessorModule aProcessorModule = AS2XMLHelper.createComponent(eModule, IProcessorModule.class, this, m_sBaseDirectory);
    aMsgProcessor.addModule(aProcessorModule);
    LOGGER.info("    loaded processor module " + aProcessorModule.getName());
}
Also used : IProcessorModule(com.helger.as2lib.processor.module.IProcessorModule)

Aggregations

IProcessorModule (com.helger.as2lib.processor.module.IProcessorModule)4 AS2Exception (com.helger.as2lib.exception.AS2Exception)1 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)1