* V4 `- C* S: l* V下面类中有几个无关的方法去掉了,可以忽略 9 l9 |! g. i9 L- t6 L2 M O 2 n Q) A _* c+ \% Kpackage com.javacode2018.lesson002.demo18.test4; + c6 M) N a) b; L+ q: J# ^# i/ x* s7 N I
/ T/ F1 I5 \! z aimport org.springframework.beans.factory.ObjectFactory; 0 E5 d/ J% t0 f# f, A2 ~3 Limport org.springframework.beans.factory.config.Scope;: i9 Z7 F. E6 U2 T, R* |
import org.springframework.lang.Nullable;- k/ N. B& E% C$ G) d2 C2 t/ b# C8 ?* B
( Y+ X* {% T, O# `7 Z# L8 N
import java.util.concurrent.ConcurrentHashMap;+ U& h& H. |! A: ?5 @
9 N' l1 c. q$ S0 b! S, ?. d' x6 d% kpublic class BeanRefreshScope implements Scope { 0 ], b3 n" P5 v* I - X, v0 n9 U/ ~; e% E" x, N public static final String SCOPE_REFRESH = "refresh"; , t- E4 A; f" l4 l1 U( O! Z ! x4 D3 `: \4 B& p! @7 o0 g4 k( v private static final BeanRefreshScope INSTANCE = new BeanRefreshScope(); + R: U" I1 I5 T U @% O 7 H- T# s9 E" M# V7 f; w" l- b //来个map用来缓存bean& n$ w D( J i0 T8 s
private ConcurrentHashMap<String, Object> beanMap = new ConcurrentHashMap<>(); //@1 ' c& Q) R7 t1 t) h9 j& {. G' ^2 _: E0 h; F, t
private BeanRefreshScope() { 6 Y, ^, ~+ u' @ }5 K3 |! n. ^# k4 I# G# }6 h/ @1 Z# d