public ExceptionHandlerImpl createExceptionHandler() { ExceptionHandlerImpl exceptionHandler = new ExceptionHandlerImpl(); addExceptionHandler(exceptionHandler); return exceptionHandler; }
public ObjectReference<EventListener> createActivityReference(String expression) { ObjectReference<EventListener> eventListenerReference = createEventListenerReference(); eventListenerReference.setExpression(expression); return eventListenerReference; }
public boolean matches(Exception exception) { return matches(exception.getClass()); }
if (exceptionHandlers!=null) { for (ExceptionHandlerImpl exceptionHandler: exceptionHandlers) { if (exceptionHandler.matches(exception)) { try { exceptionHandler.handle(this, exception); return; } catch (Exception rethrowException) { if (!exceptionHandler.isRethrowMasked()) { exception = rethrowException; ExceptionHandlerImpl.rethrow(exception, rethrowMessage+": "+exception.getMessage());
public Object execute(Environment environment) { // reload the execution DbSession dbSession = environment.get(DbSession.class); if (dbSession==null) { throw new PvmException("no "+DbSession.class.getName()+" available in the environment for reloading the execution"); } execution = dbSession.get(ExecutionImpl.class, execution.getDbid()); exceptionHandler.executeHandler(execution, exception); return null; }
/** creates a named node. * The current parent is either the process definition or a composite node * in case method {@link #compositeNode(String)} was called previously. */ public ProcessFactory node(String nodeName) { if (exceptionHandler!=null) { exceptionHandler.setNodeName(nodeName); } else { node = compositeElement.createNode(nodeName); scope = null; observableElement = node; event = null; eventListenerReference = null; transition = null; exceptionHandler = null; } return this; }
/** adds an action to the current event. The current event was either * created by {@link #event(String)} or by a {@link #transition()}. * Subsequent invocations of {@link #exceptionHandler(Class)} will * be associated to this event listener. */ public ProcessFactory listener(String expression) { if (exceptionHandler!=null) { exceptionHandler.createActivityReference(expression); } else { eventListenerReference = getEvent().createEventListenerReference(expression); } return this; }
/** creates an exception handler for the given exception class on the current process element; * until the {@link #exceptionHandlerEnd()}. Subsequent invocations of * {@link #listener(Activity) listeners} or {@link #transition() transitions} will * have the created exception handler as a target. * * DONT'T FORGET TO CLOSE THE EXCEPTION HANDLER WITH exceptionHandlerEnd. */ public ProcessFactory exceptionHandler(Class<? extends Exception> exceptionClass) { if (exceptionHandler!=null) { throw new PvmException("exceptionHandler needs to be closed with exceptionHandlerEnd"); } ProcessElementImpl processElement = null; if (eventListenerReference!=null) { processElement = eventListenerReference; } else if (event!=null) { processElement = event; } else if (observableElement!=null) { processElement = observableElement; } else { throw new PvmException("no current process element, event or action"); } exceptionHandler = processElement.createExceptionHandler(); if (exceptionClass!=null) { exceptionHandler.setExceptionClassName(exceptionClass.getName()); } return this; }
public void handle(ExecutionImpl execution, Exception exception) { if (isTransactional) { Environment environment = Environment.getCurrent(); Transaction transaction = (environment!=null ? environment.get(Transaction.class) : null); if (transaction!=null) { log.trace("registering exception handler to "+transaction); CommandService commandService = environment.get(CommandService.class); if (commandService==null) { throw new PvmException("environment doesn't have a command service for registering transactional exception handler", exception); } ExceptionHandlerSynchronization exceptionHandlerSynchronization = new ExceptionHandlerSynchronization( this, execution, exception, commandService ); // registration of the synchronization is delegated to the AfterTxCompletionListener // to avoid a dependency on class Synchronization exceptionHandlerSynchronization.register(transaction); log.trace("registering exception handler to "+transaction); throw new PvmException("transaction exception handler registered handler after transaction completed. make sure this transaction is rolled back", exception); } else { throw new PvmException("no transaction present in the environment for transactional exception handler", exception); } } else { executeHandler(execution, exception); } }
public ObjectReference<EventListener> createEventListenerReference(Descriptor descriptor) { ObjectReference<EventListener> eventListenerReference = createEventListenerReference(); eventListenerReference.setDescriptor(descriptor); return eventListenerReference; }
public boolean matches(Class<?> exceptionClass) { if (exceptionClass==null) { return false; } if ( (exceptionClassName==null) || (exceptionClass.getName().equals(exceptionClassName)) ) { return true; } Class<?> superClass = exceptionClass.getSuperclass(); if (superClass!=null) { return matches(superClass); } return false; }
public ObjectReference<EventListener> createEventListenerReference(EventListener eventListener) { ObjectReference<EventListener> eventListenerReference = createEventListenerReference(); eventListenerReference.set(eventListener); return eventListenerReference; }
/** adds an action to the current event. The current event was either * created by {@link #event(String)} or by a {@link #transition()}. * Subsequent invocations of {@link #exceptionHandler(Class)} will * be associated to this event listener. */ public ProcessFactory listener(Descriptor descriptor) { if (exceptionHandler!=null) { exceptionHandler.createEventListenerReference(descriptor); } else { getEvent().createEventListenerReference(descriptor); } return this; }
/** adds an action to the current event. The current event was either * created by {@link #event(String)} or by a {@link #transition()}. * Subsequent invocations of {@link #exceptionHandler(Class)} will * be associated to this event listener. */ public ProcessFactory listener(EventListener eventListener) { if (exceptionHandler!=null) { exceptionHandler.createEventListenerReference(eventListener); } else { eventListenerReference = getEvent().createEventListenerReference(eventListener); } return this; }