Search in sources :

Example 1 with RaiseEventService

use of org.jaffa.soa.services.RaiseEventService in project jaffa-framework by jaffa-projects.

the class TestThread method run.

@Override
public void run() {
    UOW uow = null;
    UserContextWrapper ucw = null;
    try {
        synchronized (this) {
            ucw = UserContextWrapperFactory.instance(userId);
        }
        uow = new UOW();
        HeaderParam headerParam = new HeaderParam(soaEventParamName, soaEventParamValue);
        RaiseEventService raiseEventService = new RaiseEventService();
        List<HeaderParam> headerParamList = new ArrayList<HeaderParam>();
        headerParamList.add(headerParam);
        raiseEventService.raiseSoaEvent(uow, eventName, eventDesc, null, headerParamList);
        uow.commit();
    } catch (ApplicationExceptions applicationExceptions) {
        applicationExceptions.printStackTrace();
    } catch (FrameworkException fe) {
        fe.printStackTrace();
    } catch (ApplicationException ae) {
        ae.printStackTrace();
    } finally {
        synchronized (this) {
            if (ucw != null)
                ucw.unsetContext();
        }
        if (uow != null) {
            try {
                uow.rollback();
            } catch (Exception e) {
                e.printStackTrace();
            // the uow cannot be rolled back
            }
        }
    }
}
Also used : HeaderParam(org.jaffa.modules.messaging.services.HeaderParam) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ApplicationException(org.jaffa.exceptions.ApplicationException) FrameworkException(org.jaffa.exceptions.FrameworkException) UserContextWrapper(org.jaffa.modules.user.services.UserContextWrapper) RaiseEventService(org.jaffa.soa.services.RaiseEventService) ArrayList(java.util.ArrayList) UOW(org.jaffa.persistence.UOW) FrameworkException(org.jaffa.exceptions.FrameworkException) ApplicationException(org.jaffa.exceptions.ApplicationException)

Example 2 with RaiseEventService

use of org.jaffa.soa.services.RaiseEventService in project jaffa-framework by jaffa-projects.

the class SOAEventBaseHandler method raiseSOAEvent.

/**
 * Raises the SOA event defined in the rule meta data
 *
 * @param uow          UOW for handler life cycle event
 * @param targetObject the target object
 * @param rule         the raise soa event rule meta data
 * @throws ApplicationExceptions
 * @throws FrameworkException
 */
private void raiseSOAEvent(UOW uow, Object targetObject, RuleMetaData rule, Object[] args) throws ApplicationExceptions, FrameworkException {
    UOW localUow = uow;
    if (uow == null || !uow.isActive()) {
        localUow = getUOW(targetObject);
    }
    if (log.isDebugEnabled()) {
        log.debug("Applying " + rule + " on " + targetObject);
    }
    // Add Parameters for the SOAEvent
    List<HeaderParam> headerParamsList = new ArrayList<>();
    headerParamsList.addAll(createSOAEventParameters(rule.getParameter("staticParameters"), null, null, null));
    headerParamsList.addAll(createSOAEventParameters(rule.getParameter("dynamicParameters"), targetObject, args, rule));
    RaiseEventService raiseEventService = new RaiseEventService();
    raiseEventService.raiseSoaEvent(localUow, rule.getParameter("eventName"), rule.getParameter("description"), rule.getParameter("category"), headerParamsList);
}
Also used : HeaderParam(org.jaffa.modules.messaging.services.HeaderParam) RaiseEventService(org.jaffa.soa.services.RaiseEventService) ArrayList(java.util.ArrayList) UOW(org.jaffa.persistence.UOW)

Aggregations

ArrayList (java.util.ArrayList)2 HeaderParam (org.jaffa.modules.messaging.services.HeaderParam)2 UOW (org.jaffa.persistence.UOW)2 RaiseEventService (org.jaffa.soa.services.RaiseEventService)2 ApplicationException (org.jaffa.exceptions.ApplicationException)1 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)1 FrameworkException (org.jaffa.exceptions.FrameworkException)1 UserContextWrapper (org.jaffa.modules.user.services.UserContextWrapper)1