1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
package org.mule.util; |
8 | |
|
9 | |
import java.beans.ExceptionListener; |
10 | |
import java.util.ArrayList; |
11 | |
import java.util.List; |
12 | |
|
13 | |
import org.apache.commons.logging.Log; |
14 | |
import org.apache.commons.logging.LogFactory; |
15 | |
|
16 | |
|
17 | 0 | public class ExceptionHolder implements ExceptionListener |
18 | |
{ |
19 | 0 | protected final Log logger = LogFactory.getLog(getClass()); |
20 | 0 | private List<Exception> exceptions = new ArrayList<Exception>(2); |
21 | |
|
22 | |
public void exceptionThrown(Exception e) |
23 | |
{ |
24 | 0 | exceptions.add(e); |
25 | 0 | } |
26 | |
|
27 | |
public List getExceptions() |
28 | |
{ |
29 | 0 | return exceptions; |
30 | |
} |
31 | |
|
32 | |
public boolean isExceptionThrown() |
33 | |
{ |
34 | 0 | return exceptions.size() > 0; |
35 | |
} |
36 | |
|
37 | |
public void clear() |
38 | |
{ |
39 | 0 | exceptions.clear(); |
40 | 0 | } |
41 | |
|
42 | |
public void print() |
43 | |
{ |
44 | 0 | for (Exception exception : exceptions) |
45 | |
{ |
46 | 0 | logger.error(exception); |
47 | |
} |
48 | 0 | } |
49 | |
} |