Search in sources :

Example 1 with SOAEventLifecycleHandler

use of org.jaffa.soa.dataaccess.SOAEventLifecycleHandler in project jaffa-framework by jaffa-projects.

the class LifecycleHandlerConfig method addLifecycleHandler.

/**
 * Create an instance of a lifecycle handler and add it to the factory as a prepended or appended handler.
 */
private void addLifecycleHandler(String ruleName, final RuleMetaData rule, String targetClassName) throws ClassNotFoundException {
    ILifecycleHandlerFactory.ILifecycleHandlerProvider provider = null;
    if (ruleName.equals(SoaEventRuleName)) {
        provider = new ILifecycleHandlerFactory.ILifecycleHandlerProvider() {

            @Override
            public ILifecycleHandler getHandler() {
                return new SOAEventLifecycleHandler(rule);
            }
        };
    } else if (ruleName.equals(ScriptRuleName)) {
        provider = new ILifecycleHandlerFactory.ILifecycleHandlerProvider() {

            @Override
            public ILifecycleHandler getHandler() {
                return new ScriptLifecycleHandler(rule);
            }
        };
    }
    // if the handler is not defined, we are done here
    if (provider == null) {
        log.debug("No handler provider defined for rule: " + rule);
        return;
    }
    // append or prepend based on the input flag
    Boolean executeOnReturn = Parser.parseBoolean(rule.getParameter(RuleMetaData.PARAMETER_EXECUTE_ON_RETURN));
    if (executeOnReturn) {
        lifecycleHandlerFactory.addAppendedHandlerProvider(Class.forName(targetClassName), provider);
    } else {
        lifecycleHandlerFactory.addPrependedHandlerProvider(Class.forName(targetClassName), provider);
    }
}
Also used : ILifecycleHandler(org.jaffa.persistence.ILifecycleHandler) ScriptLifecycleHandler(org.jaffa.rules.rulemeta.ScriptLifecycleHandler) ILifecycleHandlerFactory(org.jaffa.beans.factory.ILifecycleHandlerFactory) SOAEventLifecycleHandler(org.jaffa.soa.dataaccess.SOAEventLifecycleHandler)

Aggregations

ILifecycleHandlerFactory (org.jaffa.beans.factory.ILifecycleHandlerFactory)1 ILifecycleHandler (org.jaffa.persistence.ILifecycleHandler)1 ScriptLifecycleHandler (org.jaffa.rules.rulemeta.ScriptLifecycleHandler)1 SOAEventLifecycleHandler (org.jaffa.soa.dataaccess.SOAEventLifecycleHandler)1