26
26
import org .springframework .beans .factory .BeanFactory ;
27
27
import org .springframework .beans .factory .BeanFactoryAware ;
28
28
import org .springframework .beans .factory .BeanFactoryUtils ;
29
+ import org .springframework .beans .factory .FactoryBean ;
29
30
import org .springframework .beans .factory .ListableBeanFactory ;
30
31
import org .springframework .beans .factory .config .BeanDefinition ;
31
32
import org .springframework .beans .factory .config .ConfigurableListableBeanFactory ;
@@ -133,7 +134,7 @@ public int hashCode() {
133
134
* {@link ConfigurationClassPostProcessor} and adds a {@link Tracer} bean definition
134
135
* when a {@link Tracer} hasn't already been registered.
135
136
*/
136
- private static class NoopTracerRegistrar implements BeanDefinitionRegistryPostProcessor , Ordered , BeanFactoryAware {
137
+ static class NoopTracerRegistrar implements BeanDefinitionRegistryPostProcessor , Ordered , BeanFactoryAware {
137
138
138
139
private BeanFactory beanFactory ;
139
140
@@ -154,7 +155,7 @@ public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) t
154
155
}
155
156
if (BeanFactoryUtils .beanNamesForTypeIncludingAncestors ((ListableBeanFactory ) this .beanFactory ,
156
157
Tracer .class , false , false ).length == 0 ) {
157
- registry .registerBeanDefinition ("noopTracer" , new RootBeanDefinition (Tracer .class , () -> Tracer . NOOP ));
158
+ registry .registerBeanDefinition ("noopTracer" , new RootBeanDefinition (NoopTracerFactoryBean .class ));
158
159
}
159
160
}
160
161
@@ -164,4 +165,18 @@ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
164
165
165
166
}
166
167
168
+ static class NoopTracerFactoryBean implements FactoryBean <Tracer > {
169
+
170
+ @ Override
171
+ public Tracer getObject () {
172
+ return Tracer .NOOP ;
173
+ }
174
+
175
+ @ Override
176
+ public Class <?> getObjectType () {
177
+ return Tracer .class ;
178
+ }
179
+
180
+ }
181
+
167
182
}
0 commit comments