[*] Switch to Apache Commons Logging (#10)

This commit is contained in:
2025-06-14 00:24:27 +02:00
parent 6e5c9a23c2
commit 694fb85c31
5 changed files with 42 additions and 45 deletions

View File

@@ -40,7 +40,7 @@ dependencies {
compileOnly(libs.jspecify.annotations) compileOnly(libs.jspecify.annotations)
testImplementation(libs.jspecify.annotations) testImplementation(libs.jspecify.annotations)
implementation(libs.slf4j.api) implementation(libs.acl)
"localRuntimeOnly"(libs.slf4j.rt) "localRuntimeOnly"(libs.slf4j.rt)
testRuntimeOnly(libs.slf4j.rt) testRuntimeOnly(libs.slf4j.rt)

View File

@@ -1,6 +1,7 @@
[versions] [versions]
assertj = "3.26.3" assertj = "3.26.3"
autoservice = "1.1.1" autoservice = "1.1.1"
acl = "1.3.5"
java-main = "8" java-main = "8"
java-test = "21" java-test = "21"
jetbrains-annotations = "26.0.1" jetbrains-annotations = "26.0.1"
@@ -14,6 +15,7 @@ slf4j = "2.0.16"
lombok = { id = "io.freefair.lombok", version = "8.13.1" } lombok = { id = "io.freefair.lombok", version = "8.13.1" }
[libraries] [libraries]
acl = { group = "commons-logging", name = "commons-logging", version.ref = "acl" }
assertj = { group = "org.assertj", name = "assertj-core", version.ref = "assertj" } assertj = { group = "org.assertj", name = "assertj-core", version.ref = "assertj" }
autoservice-annotations = { group = "com.google.auto.service", name = "auto-service-annotations", version.ref = "autoservice" } autoservice-annotations = { group = "com.google.auto.service", name = "auto-service-annotations", version.ref = "autoservice" }
autoservice-processor = { group = "com.google.auto.service", name = "auto-service", version.ref = "autoservice" } autoservice-processor = { group = "com.google.auto.service", name = "auto-service", version.ref = "autoservice" }

View File

@@ -1,12 +1,15 @@
package de.siphalor.tweed5.weaver.pojoext.serde.api; package de.siphalor.tweed5.weaver.pojoext.serde.api;
import de.siphalor.tweed5.core.api.entry.ConfigEntry; import de.siphalor.tweed5.core.api.entry.ConfigEntry;
import de.siphalor.tweed5.data.extension.api.*; import de.siphalor.tweed5.data.extension.api.ReadWriteExtension;
import de.siphalor.tweed5.data.extension.api.TweedEntryReader;
import de.siphalor.tweed5.data.extension.api.TweedEntryWriter;
import de.siphalor.tweed5.data.extension.api.TweedReaderWriterProvider;
import de.siphalor.tweed5.data.extension.impl.TweedEntryReaderWriterImpls; import de.siphalor.tweed5.data.extension.impl.TweedEntryReaderWriterImpls;
import de.siphalor.tweed5.weaver.pojo.api.weaving.WeavingContext; import de.siphalor.tweed5.weaver.pojo.api.weaving.WeavingContext;
import de.siphalor.tweed5.weaver.pojo.api.weaving.postprocess.TweedPojoWeavingPostProcessor; import de.siphalor.tweed5.weaver.pojo.api.weaving.postprocess.TweedPojoWeavingPostProcessor;
import de.siphalor.tweed5.weaver.pojoext.serde.impl.SerdePojoReaderWriterSpec; import de.siphalor.tweed5.weaver.pojoext.serde.impl.SerdePojoReaderWriterSpec;
import lombok.extern.slf4j.Slf4j; import lombok.extern.apachecommons.CommonsLog;
import org.jspecify.annotations.Nullable; import org.jspecify.annotations.Nullable;
import java.lang.reflect.Array; import java.lang.reflect.Array;
@@ -14,7 +17,7 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.*; import java.util.*;
@Slf4j @CommonsLog
public class ReadWritePojoPostProcessor implements TweedPojoWeavingPostProcessor { public class ReadWritePojoPostProcessor implements TweedPojoWeavingPostProcessor {
private final Map<String, TweedReaderWriterProvider.ReaderWriterFactory<TweedEntryReader<?, ?>>> readerFactories = new HashMap<>(); private final Map<String, TweedReaderWriterProvider.ReaderWriterFactory<TweedEntryReader<?, ?>>> readerFactories = new HashMap<>();
private final Map<String, TweedReaderWriterProvider.ReaderWriterFactory<TweedEntryWriter<?, ?>>> writerFactories = new HashMap<>(); private final Map<String, TweedReaderWriterProvider.ReaderWriterFactory<TweedEntryWriter<?, ?>>> writerFactories = new HashMap<>();
@@ -33,11 +36,10 @@ public class ReadWritePojoPostProcessor implements TweedPojoWeavingPostProcessor
String id, String id,
TweedReaderWriterProvider.ReaderWriterFactory<TweedEntryReader<?, ?>> readerFactory TweedReaderWriterProvider.ReaderWriterFactory<TweedEntryReader<?, ?>> readerFactory
) { ) {
if (readerFactories.putIfAbsent(id, readerFactory) != null) { if (readerFactories.putIfAbsent(id, readerFactory) != null && log.isWarnEnabled()) {
log.warn( log.warn(
"Found duplicate Tweed entry reader id \"{}\" in provider class {}", "Found duplicate Tweed entry reader id \"" + id + "\" in provider class "
id, + readerWriterProvider.getClass().getName()
readerWriterProvider.getClass().getName()
); );
} }
} }
@@ -47,11 +49,10 @@ public class ReadWritePojoPostProcessor implements TweedPojoWeavingPostProcessor
String id, String id,
TweedReaderWriterProvider.ReaderWriterFactory<TweedEntryWriter<?, ?>> writerFactory TweedReaderWriterProvider.ReaderWriterFactory<TweedEntryWriter<?, ?>> writerFactory
) { ) {
if (writerFactories.putIfAbsent(id, writerFactory) != null) { if (writerFactories.putIfAbsent(id, writerFactory) != null && log.isWarnEnabled()) {
log.warn( log.warn(
"Found duplicate Tweed entry writer id \"{}\" in provider class {}", "Found duplicate Tweed entry writer id \"" + id + "\" in provider class {}"
id, + readerWriterProvider.getClass().getName()
readerWriterProvider.getClass().getName()
); );
} }
} }
@@ -69,8 +70,8 @@ public class ReadWritePojoPostProcessor implements TweedPojoWeavingPostProcessor
} }
ReadWriteExtension readWriteExtension = context.configContainer().extension(ReadWriteExtension.class).orElse(null); ReadWriteExtension readWriteExtension = context.configContainer().extension(ReadWriteExtension.class).orElse(null);
if (readWriteExtension == null) { if (readWriteExtension == null && log.isErrorEnabled()) {
log.error("You must not use {} without the {}", this.getClass().getSimpleName(), ReadWriteExtension.class.getSimpleName()); log.error("You must not use " + getClass().getName() + " without the " + ReadWriteExtension.class.getName());
return; return;
} }
@@ -110,9 +111,9 @@ public class ReadWritePojoPostProcessor implements TweedPojoWeavingPostProcessor
return SerdePojoReaderWriterSpec.parse(specText); return SerdePojoReaderWriterSpec.parse(specText);
} catch (SerdePojoReaderWriterSpec.ParseException e) { } catch (SerdePojoReaderWriterSpec.ParseException e) {
log.warn( log.warn(
"Failed to parse definition for reader or writer on entry {}, entry will not be included in serde", "Failed to parse definition for reader or writer on entry "
context.path(), + Arrays.toString(context.path())
e + ", entry will not be included in serde", e
); );
return null; return null;
} }
@@ -141,9 +142,8 @@ public class ReadWritePojoPostProcessor implements TweedPojoWeavingPostProcessor
} }
} catch (Exception e) { } catch (Exception e) {
log.warn( log.warn(
"Failed to resolve reader or writer factory \"{}\" for entry {}, entry will not be included in serde", "Failed to resolve reader or writer factory \"" + spec.identifier() + "\" for entry "
spec.identifier(), + Arrays.toString(context.path()) + ", entry will not be included in serde",
context.path(),
e e
); );
return null; return null;
@@ -165,7 +165,7 @@ public class ReadWritePojoPostProcessor implements TweedPojoWeavingPostProcessor
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
return null; return null;
} catch (NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { } catch (NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) {
log.warn("Failed to instantiate class {}", className, e); log.warn("Failed to instantiate class " + className, e);
return null; return null;
} }
} }

View File

@@ -4,7 +4,7 @@ import lombok.AccessLevel;
import lombok.Builder; import lombok.Builder;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.Value; import lombok.Value;
import lombok.extern.slf4j.Slf4j; import lombok.extern.apachecommons.CommonsLog;
import org.jspecify.annotations.Nullable; import org.jspecify.annotations.Nullable;
import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandle;
@@ -17,7 +17,7 @@ import java.util.Collections;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
@Slf4j @CommonsLog
@RequiredArgsConstructor(access = AccessLevel.PRIVATE) @RequiredArgsConstructor(access = AccessLevel.PRIVATE)
public class PojoClassIntrospector { public class PojoClassIntrospector {
private final Class<?> clazz; private final Class<?> clazz;
@@ -71,19 +71,17 @@ public class PojoClassIntrospector {
} else { } else {
Property existingProperty = properties.get(field.getName()); Property existingProperty = properties.get(field.getName());
log.error( log.error(
"Duplicate property \"{}\" detected in hierarchy of {} in classes: {} and {}", "Duplicate property \"" + field.getName() + "\" detected in hierarchy of "
field.getName(), + clazz.getName() + " in classes: "
clazz.getName(), + existingProperty.field().getDeclaringClass().getName() + " and "
existingProperty.field().getDeclaringClass().getName(), + targetClass.getName()
targetClass.getName()
); );
} }
} }
} catch (Exception e) { } catch (Exception e) {
log.error( log.error(
"Got unexpected error introspecting the properties of class {} (in hierarchy of {})", "Got unexpected error introspecting the properties of class "
targetClass.getName(), + targetClass.getName() + " (in hierarchy of " + clazz.getName() + ")",
clazz.getName(),
e e
); );
} }
@@ -193,10 +191,9 @@ public class PojoClassIntrospector {
return null; return null;
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
log.warn( log.warn(
"Failed to access method \"{}\" of class {} in hierarchy of {}", "Failed to access method \"" + methodDescriptor + "\" of class "
methodDescriptor, + targetClass.getName() + " in hierarchy of "
targetClass.getName(), + clazz.getName(),
clazz.getName(),
e e
); );
return null; return null;
@@ -211,10 +208,9 @@ public class PojoClassIntrospector {
return null; return null;
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
log.warn( log.warn(
"Failed to access getter for field \"{}\" of class {} in hierarchy of {}", "Failed to access getter for field \"" + field.getName() + "\" of class "
field.getName(), + field.getDeclaringClass().getName() + " in hierarchy of "
field.getDeclaringClass().getName(), + clazz.getName(),
clazz.getName(),
e e
); );
return null; return null;
@@ -229,10 +225,9 @@ public class PojoClassIntrospector {
return null; return null;
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
log.warn( log.warn(
"Failed to access setter for field \"{}\" of class {} in hierarchy of {}", "Failed to access setter for field \"" + field.getName() + "\" of class "
field.getName(), + field.getDeclaringClass().getName() + " in hierarchy of "
field.getDeclaringClass().getName(), + clazz.getName(),
clazz.getName(),
e e
); );
return null; return null;

View File

@@ -11,7 +11,7 @@ import de.siphalor.tweed5.weaver.pojo.api.weaving.WeavingContext;
import de.siphalor.tweed5.weaver.pojo.api.weaving.postprocess.TweedPojoWeavingPostProcessor; import de.siphalor.tweed5.weaver.pojo.api.weaving.postprocess.TweedPojoWeavingPostProcessor;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.apachecommons.CommonsLog;
import org.jspecify.annotations.Nullable; import org.jspecify.annotations.Nullable;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
@@ -23,7 +23,7 @@ import java.util.stream.Collectors;
* A class that sets up and handles all the bits and bobs for weaving a {@link ConfigContainer} out of a POJO. * A class that sets up and handles all the bits and bobs for weaving a {@link ConfigContainer} out of a POJO.
* The POJO must be annotated with {@link PojoWeaving}. * The POJO must be annotated with {@link PojoWeaving}.
*/ */
@Slf4j @CommonsLog
@RequiredArgsConstructor(access = AccessLevel.PRIVATE) @RequiredArgsConstructor(access = AccessLevel.PRIVATE)
public class TweedPojoWeaverBootstrapper<T> { public class TweedPojoWeaverBootstrapper<T> {
private final Class<T> pojoClass; private final Class<T> pojoClass;