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 1 commit
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 @@ -50,7 +50,7 @@ public T createInstance(Object... initArgs) throws InstantiationException {
.collect(Collectors.toList())
.toArray(new Class[0]);

logger.trace("Creating an instance of [{}] using constructor with parameter types: {}",
logger.debug("Creating an instance of [{}] using constructor with parameter types: {}",
bertrand-lorentz marked this conversation as resolved.
Show resolved Hide resolved
implType, paramTypes);

Constructor<T> constructor = Optional
Expand Down 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,20 @@ private void populateComponents() {
.map(Package::getName)
.toArray(String[]::new);

if (logger.isDebugEnabled()) {
bertrand-lorentz marked this conversation as resolved.
Show resolved Hide resolved
final List<String> packages = Arrays.asList(availablePackages);

logger.debug("eforms eu packages:");
packages.stream().sorted()
.filter(p -> p.contains("eu.") && !p.contains("digit"))
.forEach(p -> logger.debug(p));

logger.debug("viewer package");
packages.stream().sorted()
.filter(p -> p.contains("eu.europa.ted.eforms.viewer"))
.forEach(p -> logger.debug(p));
}

new Reflections(ConfigurationBuilder.build().forPackages(availablePackages))
.getTypesAnnotatedWith(annotationType).stream()
.forEach((Class<?> clazz) -> {
Expand Down Expand Up @@ -126,22 +142,40 @@ 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.isDebugEnabled()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should rather be done at the "trace" level.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK i will use trace

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has not been changed, it is still done at "debug" level".

logger.debug("selector componentType={}", selector.componentType);
logger.debug("selector qualifier={}", selector.qualifier);
logger.debug("normalized version={}", normalizedVersion);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those 3 lines should be merged into one, with a clearer text.
And for other logs, those values are in square brackets, so let's be consistent.
So for example:
"Looking for component with version=[{}], componentType=[{}], qualifier=[{}]"

for (Entry<ComponentSelector, SdkComponentDescriptor<?>> entry : map.entrySet()) {
logger.debug(
"entry key componentType={}, key qualifier={}, value={}",
bertrand-lorentz marked this conversation as resolved.
Show resolved Hide resolved
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);
logger.debug("descriptor descriptor={}", descriptor);
bertrand-lorentz marked this conversation as resolved.
Show resolved Hide resolved

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