File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
hsweb-commons/hsweb-commons-utils
src/main/java/org/hswebframework/web Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change 38
38
<optional >true</optional >
39
39
</dependency >
40
40
41
+ <dependency >
42
+ <groupId >org.springframework</groupId >
43
+ <artifactId >spring-context</artifactId >
44
+ <optional >true</optional >
45
+ </dependency >
46
+
41
47
<dependency >
42
48
<groupId >org.aspectj</groupId >
43
49
<artifactId >aspectjweaver</artifactId >
Original file line number Diff line number Diff line change
1
+ package org .hswebframework .web ;
2
+
3
+ import org .springframework .beans .factory .annotation .Autowired ;
4
+ import org .springframework .context .ApplicationContext ;
5
+ import org .springframework .stereotype .Component ;
6
+
7
+ /**
8
+ * TODO 完成注释
9
+ *
10
+ * @author zhouhao
11
+ */
12
+ @ Component
13
+ public class ApplicationContextHolder {
14
+ private static ApplicationContext context ;
15
+
16
+ public static final ApplicationContext get () {
17
+ if (null == context ) {
18
+ throw new UnsupportedOperationException ("ApplicationContext not ready!" );
19
+ }
20
+ return context ;
21
+ }
22
+
23
+ @ Autowired
24
+ public void setContext (ApplicationContext context ) {
25
+ if (null == ApplicationContextHolder .context )
26
+ ApplicationContextHolder .context = context ;
27
+ }
28
+ }
You can’t perform that action at this time.
0 commit comments