|
1 | 1 | /* |
2 | | - * Copyright 2002-2019 the original author or authors. |
| 2 | + * Copyright 2002-2024 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
|
18 | 18 |
|
19 | 19 | import java.util.ArrayList; |
20 | 20 | import java.util.List; |
| 21 | +import java.util.function.Supplier; |
21 | 22 |
|
22 | 23 | import org.apache.commons.logging.Log; |
23 | 24 | import org.apache.commons.logging.LogFactory; |
@@ -94,25 +95,26 @@ private <T> List<BeanWithName<T>> getBeansWithName(Class<T> type) { |
94 | 95 | String[] beanNames = InitializeAuthenticationProviderBeanManagerConfigurer.this.context |
95 | 96 | .getBeanNamesForType(type); |
96 | 97 | for (String beanName : beanNames) { |
97 | | - T bean = InitializeAuthenticationProviderBeanManagerConfigurer.this.context.getBean(beanName, type); |
98 | | - beanWithNames.add(new BeanWithName<T>(bean, beanName)); |
| 98 | + Supplier<T> bean = () -> InitializeAuthenticationProviderBeanManagerConfigurer.this.context |
| 99 | + .getBean(beanName, type); |
| 100 | + beanWithNames.add(new BeanWithName<>(bean, beanName)); |
99 | 101 | } |
100 | 102 | return beanWithNames; |
101 | 103 | } |
102 | 104 |
|
103 | 105 | static class BeanWithName<T> { |
104 | 106 |
|
105 | | - private final T bean; |
| 107 | + private final Supplier<T> bean; |
106 | 108 |
|
107 | 109 | private final String name; |
108 | 110 |
|
109 | | - BeanWithName(T bean, String name) { |
| 111 | + BeanWithName(Supplier<T> bean, String name) { |
110 | 112 | this.bean = bean; |
111 | 113 | this.name = name; |
112 | 114 | } |
113 | 115 |
|
114 | 116 | T getBean() { |
115 | | - return this.bean; |
| 117 | + return this.bean.get(); |
116 | 118 | } |
117 | 119 |
|
118 | 120 | String getName() { |
|
0 commit comments