Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TEDEFO-3325 added more debug logs which give insight into the package… #35

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public boolean equals(Object obj) {
if (getClass() != obj.getClass())
return false;
SdkComponentDescriptor<?> other = (SdkComponentDescriptor<?>) obj;
return componentType == other.componentType
return componentType == other.componentType
&& Objects.equals(sdkVersion, other.sdkVersion)
&& Objects.equals(qualifier, other.qualifier)
&& Objects.equals(implType, other.implType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Stream;
Expand Down Expand Up @@ -78,6 +80,12 @@ private void populateComponents() {
.map(Package::getName)
.toArray(String[]::new);

if (logger.isTraceEnabled()) {
final List<String> packages = Arrays.asList(availablePackages);
packages.stream().sorted()
.forEach(p -> logger.trace(p));
}

new Reflections(ConfigurationBuilder.build().forPackages(availablePackages))
.getTypesAnnotatedWith(annotationType).stream()
.forEach((Class<?> clazz) -> {
Expand Down Expand Up @@ -126,22 +134,39 @@ protected <T> T getComponentImpl(String sdkVersion, final SdkComponentType compo
}

protected <T> T getComponentImpl(String sdkVersion, final SdkComponentType componentType,
final String qualifier, final Class<T> intf, Object... initArgs) throws InstantiationException {
final String qualifier, final Class<T> intf, Object... initArgs)
throws InstantiationException {

String normalizedVersion = normalizeVersion(sdkVersion);

ComponentSelector selector = new ComponentSelector(componentType, qualifier);

Map<ComponentSelector, SdkComponentDescriptor<?>> map =
Optional.ofNullable(componentsMap.get(normalizedVersion))
.orElseGet(Collections::emptyMap);

if (logger.isTraceEnabled()) {
logger.trace("Looking for component with version=[{}], componentType=[{}], qualifier=[{}]",
normalizedVersion, selector.componentType, selector.qualifier);
for (Entry<ComponentSelector, SdkComponentDescriptor<?>> entry : map.entrySet()) {
logger.trace(
"Available component for this version: "
+ "componentType=[{}], qualifier=[{}], value=[{}]",
entry.getKey().componentType,
entry.getKey().qualifier,
entry.getValue().getImplType().getName());
}
}

@SuppressWarnings("unchecked")
SdkComponentDescriptor<T> descriptor =
(SdkComponentDescriptor<T>) Optional.ofNullable(componentsMap.get(normalizedVersion))
.orElseGet(Collections::emptyMap).get(selector);
(SdkComponentDescriptor<T>) map.get(selector);

if (descriptor == null) {
logger.error("Failed to load required components of SDK [{}]", sdkVersion);
throw new IllegalArgumentException(
MessageFormat.format(
"No implementation found for SDK [{0}], component type [{1}] and qualifier '{2}'.",
"No implementation found for SDK [{0}], component type [{1}] and qualifier [{2}].",
bertrand-lorentz marked this conversation as resolved.
Show resolved Hide resolved
sdkVersion, componentType, qualifier));
}

Expand Down