1
2
3
4
5
6
7
8
9
10
11
12
13
14 package org.slf4j.test_osgi;
15
16 import java.util.ArrayList;
17 import java.util.List;
18
19 import org.osgi.framework.FrameworkEvent;
20 import org.osgi.framework.FrameworkListener;
21
22 public class FrameworkErrorListener implements FrameworkListener {
23
24 public List<FrameworkEvent> errorList = new ArrayList<FrameworkEvent>();
25
26 public void frameworkEvent(FrameworkEvent fe) {
27 if (fe.getType() == FrameworkEvent.ERROR) {
28 errorList.add(fe);
29 }
30 }
31
32 private void dump(FrameworkEvent fe) {
33 Throwable t = fe.getThrowable();
34 String tString = null;
35 if (t != null) {
36 tString = t.toString();
37 }
38 System.out.println(
39 "Framework ERROR:" + ", source " + fe.getSource() + ", bundle=" + fe.getBundle() + ", ex=" + tString);
40 if (t != null) {
41 t.printStackTrace();
42 }
43 }
44
45 public void dumpAll() {
46 for (int i = 0; i < errorList.size(); i++) {
47 FrameworkEvent fe = (FrameworkEvent) errorList.get(i);
48 dump(fe);
49 }
50 }
51 }