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