|
4 | 4 | import java.util.Arrays; |
5 | 5 | import java.util.Collections; |
6 | 6 | import java.util.HashMap; |
| 7 | +import java.util.List; |
7 | 8 | import java.util.Map; |
| 9 | +import java.util.Map.Entry; |
8 | 10 | import java.util.Objects; |
9 | 11 | import java.util.Optional; |
10 | 12 | import java.util.stream.Stream; |
@@ -78,6 +80,12 @@ private void populateComponents() { |
78 | 80 | .map(Package::getName) |
79 | 81 | .toArray(String[]::new); |
80 | 82 |
|
| 83 | + if (logger.isTraceEnabled()) { |
| 84 | + final List<String> packages = Arrays.asList(availablePackages); |
| 85 | + packages.stream().sorted() |
| 86 | + .forEach(p -> logger.trace(p)); |
| 87 | + } |
| 88 | + |
81 | 89 | new Reflections(ConfigurationBuilder.build().forPackages(availablePackages)) |
82 | 90 | .getTypesAnnotatedWith(annotationType).stream() |
83 | 91 | .forEach((Class<?> clazz) -> { |
@@ -126,22 +134,39 @@ protected <T> T getComponentImpl(String sdkVersion, final SdkComponentType compo |
126 | 134 | } |
127 | 135 |
|
128 | 136 | protected <T> T getComponentImpl(String sdkVersion, final SdkComponentType componentType, |
129 | | - final String qualifier, final Class<T> intf, Object... initArgs) throws InstantiationException { |
| 137 | + final String qualifier, final Class<T> intf, Object... initArgs) |
| 138 | + throws InstantiationException { |
130 | 139 |
|
131 | 140 | String normalizedVersion = normalizeVersion(sdkVersion); |
132 | 141 |
|
133 | 142 | ComponentSelector selector = new ComponentSelector(componentType, qualifier); |
134 | 143 |
|
| 144 | + Map<ComponentSelector, SdkComponentDescriptor<?>> map = |
| 145 | + Optional.ofNullable(componentsMap.get(normalizedVersion)) |
| 146 | + .orElseGet(Collections::emptyMap); |
| 147 | + |
| 148 | + if (logger.isTraceEnabled()) { |
| 149 | + logger.trace("Looking for component with version=[{}], componentType=[{}], qualifier=[{}]", |
| 150 | + normalizedVersion, selector.componentType, selector.qualifier); |
| 151 | + for (Entry<ComponentSelector, SdkComponentDescriptor<?>> entry : map.entrySet()) { |
| 152 | + logger.trace( |
| 153 | + "Available component for this version: " |
| 154 | + + "componentType=[{}], qualifier=[{}], value=[{}]", |
| 155 | + entry.getKey().componentType, |
| 156 | + entry.getKey().qualifier, |
| 157 | + entry.getValue().getImplType().getName()); |
| 158 | + } |
| 159 | + } |
| 160 | + |
135 | 161 | @SuppressWarnings("unchecked") |
136 | 162 | SdkComponentDescriptor<T> descriptor = |
137 | | - (SdkComponentDescriptor<T>) Optional.ofNullable(componentsMap.get(normalizedVersion)) |
138 | | - .orElseGet(Collections::emptyMap).get(selector); |
| 163 | + (SdkComponentDescriptor<T>) map.get(selector); |
139 | 164 |
|
140 | 165 | if (descriptor == null) { |
141 | 166 | logger.error("Failed to load required components of SDK [{}]", sdkVersion); |
142 | 167 | throw new IllegalArgumentException( |
143 | 168 | MessageFormat.format( |
144 | | - "No implementation found for SDK [{0}], component type [{1}] and qualifier '{2}'.", |
| 169 | + "No implementation found for SDK [{0}], component type [{1}] and qualifier [{2}].", |
145 | 170 | sdkVersion, componentType, qualifier)); |
146 | 171 | } |
147 | 172 |
|
|
0 commit comments