/** * Tells whether the given context can handle exception by checking for: * <ul> * <li>the absence of a previous exception</li> * <li>an active transaction, or no transaction present</li> * </ul> */ private static boolean isAbleToHandleExceptions(ExecutionContext executionContext) { // if executionContext has an exception set, it is already handling an exception // in this case, do not offer exception to handlers; throw at client // see https://jira.jboss.org/browse/JBPM-1887 if (executionContext.getException() != null) return false; // check whether transaction is still active before scanning exception handlers // this way, the exception handlers can be loaded lazily // see https://jira.jboss.org/browse/JBPM-1775 JbpmContext jbpmContext = executionContext.getJbpmContext(); if (jbpmContext != null) { PersistenceService persistenceService = jbpmContext.getServices().getPersistenceService(); if (persistenceService instanceof DbPersistenceService) { DbPersistenceService dbPersistenceService = (DbPersistenceService) persistenceService; return dbPersistenceService.isTransactionActive(); } } // no transaction present; likely running in memory return true; }
/** * Tells whether the given context can handle exception by checking for: * <ul> * <li>the absence of a previous exception</li> * <li>an active transaction, or no transaction present</li> * </ul> */ private static boolean isAbleToHandleExceptions(ExecutionContext executionContext) { // if executionContext has an exception set, it is already handling an exception // in this case, do not offer exception to handlers; throw at client // see https://jira.jboss.org/browse/JBPM-1887 if (executionContext.getException() != null) return false; // check whether transaction is still active before scanning exception handlers // this way, the exception handlers can be loaded lazily // see https://jira.jboss.org/browse/JBPM-1775 JbpmContext jbpmContext = executionContext.getJbpmContext(); if (jbpmContext != null) { PersistenceService persistenceService = jbpmContext.getServices().getPersistenceService(); if (persistenceService instanceof DbPersistenceService) { DbPersistenceService dbPersistenceService = (DbPersistenceService) persistenceService; return dbPersistenceService.isTransactionActive(); } } // no transaction present; likely running in memory return true; }