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 public class ExceptionHolder implements ExceptionListener
18 {
19 protected final Log logger = LogFactory.getLog(getClass());
20 private List<Exception> exceptions = new ArrayList<Exception>(2);
21
22 public void exceptionThrown(Exception e)
23 {
24 exceptions.add(e);
25 }
26
27 public List getExceptions()
28 {
29 return exceptions;
30 }
31
32 public boolean isExceptionThrown()
33 {
34 return exceptions.size() > 0;
35 }
36
37 public void clear()
38 {
39 exceptions.clear();
40 }
41
42 public void print()
43 {
44 for (Exception exception : exceptions)
45 {
46 logger.error(exception);
47 }
48 }
49 }