Skip to content

Commit 9601b17

Browse files
committed
test applicationContext isSingleton/isPrototype/getType
1 parent 58dda1b commit 9601b17

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

help/http-requests.http

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ GET http://localhost:9100/bean/nameComponent
44
### bean/names/path
55
GET http://localhost:9100/bean/names/path?path=cn/netbuffer/springboot/demo
66

7+
### /bean/isSingleton
8+
GET http://localhost:9100/bean/isSingleton?bean=beanController
9+
10+
### /bean/isPrototype
11+
GET http://localhost:9100/bean/isPrototype?bean=beanController
12+
13+
### /bean/getType
14+
GET http://localhost:9100/bean/getType?bean=beanController
15+
716
### async task with error
817
GET http://localhost:9100/async/error
918

src/main/java/cn/netbuffer/springboot/demo/controller/BeanController.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,21 @@ public String[] getBeanDefinitionNames() {
5151
return applicationContext.getBeanDefinitionNames();
5252
}
5353

54+
@GetMapping(value = {"isSingleton"})
55+
public boolean isSingleton(String bean) {
56+
return applicationContext.isSingleton(bean);
57+
}
58+
59+
@GetMapping(value = {"isPrototype"})
60+
public boolean isPrototype(String bean) {
61+
return applicationContext.isPrototype(bean);
62+
}
63+
64+
@GetMapping(value = {"getType"})
65+
public Class<?> getType(String bean) {
66+
return applicationContext.getType(bean);
67+
}
68+
5469
/**
5570
* get beans in package
5671
*
@@ -84,7 +99,7 @@ public int memoryAlloc(int gb) {
8499
for (int i = 0; i < gb; i++) {
85100
memoryAlloc.put(String.valueOf(i), new byte[1024 * 1024 * 1024]);
86101
}
87-
log.debug("memory alloc gb={}",gb);
102+
log.debug("memory alloc gb={}", gb);
88103
return memoryAlloc.size();
89104
}
90105

@@ -93,7 +108,7 @@ public int memoryRelease(int gb) {
93108
for (int i = 0; i < gb; i++) {
94109
memoryAlloc.remove(String.valueOf(i));
95110
}
96-
log.debug("memory release gb={}",gb);
111+
log.debug("memory release gb={}", gb);
97112
return memoryAlloc.size();
98113
}
99114

0 commit comments

Comments
 (0)