1
2
3
4
5
6
7
8
9
10
11
12
13
14 package net.sf.appstatus.jmx;
15
16 import net.sf.appstatus.core.IObjectInstantiationListener;
17
18 import org.springframework.beans.BeansException;
19 import org.springframework.context.ApplicationContext;
20
21
22
23
24
25
26
27 public class SpringBeanInstantiationListener implements IObjectInstantiationListener {
28
29 private final ApplicationContext applicationContext;
30
31
32
33
34
35
36
37 public SpringBeanInstantiationListener(ApplicationContext springApplicationContext) {
38 this.applicationContext = springApplicationContext;
39 }
40
41 public Object getInstance(String className) {
42 Object obj = null;
43
44 try {
45 obj = this.applicationContext.getBean(className);
46 } catch (BeansException e) {
47 }
48
49 return obj;
50 }
51 }