KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > graph > def > ExceptionHandler


1 package org.jbpm.graph.def;
2
3 import java.io.*;
4 import java.util.*;
5 import org.jbpm.graph.exe.*;
6 import org.jbpm.instantiation.*;
7
8 public class ExceptionHandler implements Serializable {
9
10   private static final long serialVersionUID = 1L;
11
12   long id = 0;
13   protected String JavaDoc exceptionClassName = null;
14   protected GraphElement graphElement = null;
15   protected List actions = null;
16
17   public ExceptionHandler() {
18   }
19
20   public boolean matches( Throwable JavaDoc exception ) {
21     boolean matches = true;
22     if (exceptionClassName!=null) {
23       Class JavaDoc clazz = ClassLoaderUtil.loadClass(exceptionClassName);
24       if (! clazz.isAssignableFrom(exception.getClass())) {
25         matches = false;
26       }
27     }
28     return matches;
29   }
30
31   public void handleException(ExecutionContext executionContext) throws Exception JavaDoc {
32     if (actions!=null) {
33       Iterator iter = actions.iterator();
34       while (iter.hasNext()) {
35         Action action = (Action) iter.next();
36         action.execute(executionContext);
37       }
38     }
39   }
40
41   // actions
42
/////////////////////////////////////////////////////////////////////////////
43
public List getActions() {
44     return actions;
45   }
46   
47   public void addAction(Action action) {
48     if (actions==null) actions = new ArrayList();
49     actions.add(action);
50   }
51   
52   public void removeAction(Action action) {
53     if (actions!=null) {
54       actions.remove(action);
55     }
56   }
57
58   public void reorderAction(int oldIndex, int newIndex) {
59     if (actions!=null) {
60       actions.add(newIndex, actions.remove(oldIndex));
61     }
62   }
63
64   // getters and setters
65
/////////////////////////////////////////////////////////////////////////////
66

67   public String JavaDoc getExceptionClassName() {
68     return exceptionClassName;
69   }
70   public void setExceptionClassName(String JavaDoc exceptionClassName) {
71     this.exceptionClassName = exceptionClassName;
72   }
73   public GraphElement getGraphElement() {
74     return graphElement;
75   }
76 }
77
Popular Tags