|
30 | 30 | import jakarta.enterprise.context.Dependent;
|
31 | 31 | import jakarta.enterprise.inject.CreationException;
|
32 | 32 |
|
33 |
| -import org.eclipse.microprofile.config.Config; |
34 | 33 | import org.eclipse.microprofile.config.ConfigValue;
|
35 | 34 | import org.eclipse.microprofile.config.inject.ConfigProperties;
|
36 | 35 | import org.eclipse.microprofile.config.inject.ConfigProperty;
|
|
42 | 41 | import org.jboss.jandex.DotName;
|
43 | 42 | import org.jboss.jandex.FieldInfo;
|
44 | 43 | import org.jboss.jandex.MethodInfo;
|
45 |
| -import org.jboss.jandex.ParameterizedType; |
46 | 44 | import org.jboss.jandex.Type;
|
47 | 45 | import org.jboss.jandex.Type.Kind;
|
48 |
| -import org.jboss.logging.Logger; |
49 | 46 |
|
50 | 47 | import io.quarkus.arc.Unremovable;
|
51 | 48 | import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem.BeanConfiguratorBuildItem;
|
|
67 | 64 | import io.quarkus.deployment.builditem.ConfigPropertiesBuildItem;
|
68 | 65 | import io.quarkus.deployment.builditem.ConfigurationBuildItem;
|
69 | 66 | import io.quarkus.deployment.builditem.GeneratedClassBuildItem;
|
70 |
| -import io.quarkus.deployment.builditem.RunTimeConfigurationDefaultBuildItem; |
71 | 67 | import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
|
72 | 68 | import io.quarkus.deployment.configuration.definition.RootDefinition;
|
73 | 69 | import io.quarkus.deployment.recording.RecorderContext;
|
|
80 | 76 | * MicroProfile Config related build steps.
|
81 | 77 | */
|
82 | 78 | public class ConfigBuildStep {
|
83 |
| - private static final Logger LOGGER = Logger.getLogger(ConfigBuildStep.class.getName()); |
84 | 79 |
|
85 |
| - private static final DotName MP_CONFIG = DotName.createSimple(Config.class.getName()); |
86 | 80 | static final DotName MP_CONFIG_PROPERTY_NAME = DotName.createSimple(ConfigProperty.class.getName());
|
87 | 81 | private static final DotName MP_CONFIG_PROPERTIES_NAME = DotName.createSimple(ConfigProperties.class.getName());
|
88 | 82 | private static final DotName MP_CONFIG_VALUE_NAME = DotName.createSimple(ConfigValue.class.getName());
|
89 | 83 |
|
90 |
| - private static final DotName SR_CONFIG = DotName.createSimple(io.smallrye.config.SmallRyeConfig.class.getName()); |
91 | 84 | private static final DotName SR_CONFIG_VALUE_NAME = DotName.createSimple(io.smallrye.config.ConfigValue.class.getName());
|
92 | 85 |
|
93 | 86 | private static final DotName MAP_NAME = DotName.createSimple(Map.class.getName());
|
@@ -474,67 +467,6 @@ void validateConfigPropertiesInjectionPoints(
|
474 | 467 | toRegister.forEach(configProperties::produce);
|
475 | 468 | }
|
476 | 469 |
|
477 |
| - @BuildStep |
478 |
| - void warnStaticInitInjectionPoints( |
479 |
| - CombinedIndexBuildItem indexBuildItem, |
480 |
| - ValidationPhaseBuildItem validationPhase, |
481 |
| - List<ConfigClassBuildItem> configClasses, |
482 |
| - List<ConfigInjectionStaticInitBuildItem> configInjectionStaticInit, |
483 |
| - BuildProducer<RunTimeConfigurationDefaultBuildItem> runTimeConfigurationDefault) { |
484 |
| - |
485 |
| - // Add here annotated classes that are initialized during static init |
486 |
| - Set<DotName> declaringClassCandidates = configInjectionStaticInit.stream() |
487 |
| - .map(ConfigInjectionStaticInitBuildItem::getDeclaringCandidate).collect(toSet()); |
488 |
| - |
489 |
| - Set<Type> configClassesTypes = configClasses.stream().map(ConfigClassBuildItem::getTypes).flatMap(Collection::stream) |
490 |
| - .collect(toSet()); |
491 |
| - |
492 |
| - for (InjectionPointInfo injectionPoint : validationPhase.getContext().getInjectionPoints()) { |
493 |
| - if (injectionPoint.getType().name().equals(DotNames.INSTANCE)) { |
494 |
| - continue; |
495 |
| - } |
496 |
| - |
497 |
| - Type type = Type.create(injectionPoint.getRequiredType().name(), Type.Kind.CLASS); |
498 |
| - DotName injectionTypeName = null; |
499 |
| - if (type.name().equals(MP_CONFIG) || type.name().equals(SR_CONFIG)) { |
500 |
| - injectionTypeName = type.name(); |
501 |
| - } else if (injectionPoint.getRequiredQualifier(MP_CONFIG_PROPERTY_NAME) != null) { |
502 |
| - injectionTypeName = MP_CONFIG_PROPERTY_NAME; |
503 |
| - } else if (configClassesTypes.contains(type)) { |
504 |
| - injectionTypeName = type.name(); |
505 |
| - } |
506 |
| - |
507 |
| - if (injectionTypeName != null) { |
508 |
| - AnnotationTarget target = injectionPoint.getTarget(); |
509 |
| - if (FIELD.equals(target.kind())) { |
510 |
| - FieldInfo field = target.asField(); |
511 |
| - ClassInfo declaringClass = field.declaringClass(); |
512 |
| - Map<DotName, List<AnnotationInstance>> annotationsMap = declaringClass.annotationsMap(); |
513 |
| - for (DotName declaringClassCandidate : declaringClassCandidates) { |
514 |
| - List<AnnotationInstance> annotationInstances = annotationsMap.get(declaringClassCandidate); |
515 |
| - if (annotationInstances != null && annotationInstances.size() == 1) { |
516 |
| - AnnotationInstance annotationInstance = annotationInstances.get(0); |
517 |
| - if (annotationInstance.target().equals(declaringClass)) { |
518 |
| - LOGGER.warn("Directly injecting a " + |
519 |
| - injectionTypeName + |
520 |
| - " into a " + |
521 |
| - declaringClassCandidate + |
522 |
| - " may lead to unexpected results. To ensure proper results, please " + |
523 |
| - "change the type of the field to " + |
524 |
| - ParameterizedType.create(DotNames.INSTANCE, new Type[] { type }, null) + |
525 |
| - ". Offending field is '" + |
526 |
| - field.name() + |
527 |
| - "' of class '" + |
528 |
| - field.declaringClass() + |
529 |
| - "'"); |
530 |
| - } |
531 |
| - } |
532 |
| - } |
533 |
| - } |
534 |
| - } |
535 |
| - } |
536 |
| - } |
537 |
| - |
538 | 470 | @BuildStep
|
539 | 471 | @Record(RUNTIME_INIT)
|
540 | 472 | void registerConfigClasses(
|
|
0 commit comments