[*] Switch to Apache Commons Logging (#10)
This commit is contained in:
@@ -40,7 +40,7 @@ dependencies {
|
||||
compileOnly(libs.jspecify.annotations)
|
||||
testImplementation(libs.jspecify.annotations)
|
||||
|
||||
implementation(libs.slf4j.api)
|
||||
implementation(libs.acl)
|
||||
"localRuntimeOnly"(libs.slf4j.rt)
|
||||
testRuntimeOnly(libs.slf4j.rt)
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
[versions]
|
||||
assertj = "3.26.3"
|
||||
autoservice = "1.1.1"
|
||||
acl = "1.3.5"
|
||||
java-main = "8"
|
||||
java-test = "21"
|
||||
jetbrains-annotations = "26.0.1"
|
||||
@@ -14,6 +15,7 @@ slf4j = "2.0.16"
|
||||
lombok = { id = "io.freefair.lombok", version = "8.13.1" }
|
||||
|
||||
[libraries]
|
||||
acl = { group = "commons-logging", name = "commons-logging", version.ref = "acl" }
|
||||
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-processor = { group = "com.google.auto.service", name = "auto-service", version.ref = "autoservice" }
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package de.siphalor.tweed5.weaver.pojoext.serde.api;
|
||||
|
||||
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.weaver.pojo.api.weaving.WeavingContext;
|
||||
import de.siphalor.tweed5.weaver.pojo.api.weaving.postprocess.TweedPojoWeavingPostProcessor;
|
||||
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 java.lang.reflect.Array;
|
||||
@@ -14,7 +17,7 @@ import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
@CommonsLog
|
||||
public class ReadWritePojoPostProcessor implements TweedPojoWeavingPostProcessor {
|
||||
private final Map<String, TweedReaderWriterProvider.ReaderWriterFactory<TweedEntryReader<?, ?>>> readerFactories = new HashMap<>();
|
||||
private final Map<String, TweedReaderWriterProvider.ReaderWriterFactory<TweedEntryWriter<?, ?>>> writerFactories = new HashMap<>();
|
||||
@@ -33,11 +36,10 @@ public class ReadWritePojoPostProcessor implements TweedPojoWeavingPostProcessor
|
||||
String id,
|
||||
TweedReaderWriterProvider.ReaderWriterFactory<TweedEntryReader<?, ?>> readerFactory
|
||||
) {
|
||||
if (readerFactories.putIfAbsent(id, readerFactory) != null) {
|
||||
if (readerFactories.putIfAbsent(id, readerFactory) != null && log.isWarnEnabled()) {
|
||||
log.warn(
|
||||
"Found duplicate Tweed entry reader id \"{}\" in provider class {}",
|
||||
id,
|
||||
readerWriterProvider.getClass().getName()
|
||||
"Found duplicate Tweed entry reader id \"" + id + "\" in provider class "
|
||||
+ readerWriterProvider.getClass().getName()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -47,11 +49,10 @@ public class ReadWritePojoPostProcessor implements TweedPojoWeavingPostProcessor
|
||||
String id,
|
||||
TweedReaderWriterProvider.ReaderWriterFactory<TweedEntryWriter<?, ?>> writerFactory
|
||||
) {
|
||||
if (writerFactories.putIfAbsent(id, writerFactory) != null) {
|
||||
if (writerFactories.putIfAbsent(id, writerFactory) != null && log.isWarnEnabled()) {
|
||||
log.warn(
|
||||
"Found duplicate Tweed entry writer id \"{}\" in provider class {}",
|
||||
id,
|
||||
readerWriterProvider.getClass().getName()
|
||||
"Found duplicate Tweed entry writer id \"" + id + "\" in provider class {}"
|
||||
+ readerWriterProvider.getClass().getName()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -69,8 +70,8 @@ public class ReadWritePojoPostProcessor implements TweedPojoWeavingPostProcessor
|
||||
}
|
||||
|
||||
ReadWriteExtension readWriteExtension = context.configContainer().extension(ReadWriteExtension.class).orElse(null);
|
||||
if (readWriteExtension == null) {
|
||||
log.error("You must not use {} without the {}", this.getClass().getSimpleName(), ReadWriteExtension.class.getSimpleName());
|
||||
if (readWriteExtension == null && log.isErrorEnabled()) {
|
||||
log.error("You must not use " + getClass().getName() + " without the " + ReadWriteExtension.class.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -110,9 +111,9 @@ public class ReadWritePojoPostProcessor implements TweedPojoWeavingPostProcessor
|
||||
return SerdePojoReaderWriterSpec.parse(specText);
|
||||
} catch (SerdePojoReaderWriterSpec.ParseException e) {
|
||||
log.warn(
|
||||
"Failed to parse definition for reader or writer on entry {}, entry will not be included in serde",
|
||||
context.path(),
|
||||
e
|
||||
"Failed to parse definition for reader or writer on entry "
|
||||
+ Arrays.toString(context.path())
|
||||
+ ", entry will not be included in serde", e
|
||||
);
|
||||
return null;
|
||||
}
|
||||
@@ -141,9 +142,8 @@ public class ReadWritePojoPostProcessor implements TweedPojoWeavingPostProcessor
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn(
|
||||
"Failed to resolve reader or writer factory \"{}\" for entry {}, entry will not be included in serde",
|
||||
spec.identifier(),
|
||||
context.path(),
|
||||
"Failed to resolve reader or writer factory \"" + spec.identifier() + "\" for entry "
|
||||
+ Arrays.toString(context.path()) + ", entry will not be included in serde",
|
||||
e
|
||||
);
|
||||
return null;
|
||||
@@ -165,7 +165,7 @@ public class ReadWritePojoPostProcessor implements TweedPojoWeavingPostProcessor
|
||||
} catch (ClassNotFoundException e) {
|
||||
return null;
|
||||
} catch (NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) {
|
||||
log.warn("Failed to instantiate class {}", className, e);
|
||||
log.warn("Failed to instantiate class " + className, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import lombok.AccessLevel;
|
||||
import lombok.Builder;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Value;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import lombok.extern.apachecommons.CommonsLog;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
@@ -17,7 +17,7 @@ import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@CommonsLog
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class PojoClassIntrospector {
|
||||
private final Class<?> clazz;
|
||||
@@ -71,19 +71,17 @@ public class PojoClassIntrospector {
|
||||
} else {
|
||||
Property existingProperty = properties.get(field.getName());
|
||||
log.error(
|
||||
"Duplicate property \"{}\" detected in hierarchy of {} in classes: {} and {}",
|
||||
field.getName(),
|
||||
clazz.getName(),
|
||||
existingProperty.field().getDeclaringClass().getName(),
|
||||
targetClass.getName()
|
||||
"Duplicate property \"" + field.getName() + "\" detected in hierarchy of "
|
||||
+ clazz.getName() + " in classes: "
|
||||
+ existingProperty.field().getDeclaringClass().getName() + " and "
|
||||
+ targetClass.getName()
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(
|
||||
"Got unexpected error introspecting the properties of class {} (in hierarchy of {})",
|
||||
targetClass.getName(),
|
||||
clazz.getName(),
|
||||
"Got unexpected error introspecting the properties of class "
|
||||
+ targetClass.getName() + " (in hierarchy of " + clazz.getName() + ")",
|
||||
e
|
||||
);
|
||||
}
|
||||
@@ -193,10 +191,9 @@ public class PojoClassIntrospector {
|
||||
return null;
|
||||
} catch (IllegalAccessException e) {
|
||||
log.warn(
|
||||
"Failed to access method \"{}\" of class {} in hierarchy of {}",
|
||||
methodDescriptor,
|
||||
targetClass.getName(),
|
||||
clazz.getName(),
|
||||
"Failed to access method \"" + methodDescriptor + "\" of class "
|
||||
+ targetClass.getName() + " in hierarchy of "
|
||||
+ clazz.getName(),
|
||||
e
|
||||
);
|
||||
return null;
|
||||
@@ -211,10 +208,9 @@ public class PojoClassIntrospector {
|
||||
return null;
|
||||
} catch (IllegalAccessException e) {
|
||||
log.warn(
|
||||
"Failed to access getter for field \"{}\" of class {} in hierarchy of {}",
|
||||
field.getName(),
|
||||
field.getDeclaringClass().getName(),
|
||||
clazz.getName(),
|
||||
"Failed to access getter for field \"" + field.getName() + "\" of class "
|
||||
+ field.getDeclaringClass().getName() + " in hierarchy of "
|
||||
+ clazz.getName(),
|
||||
e
|
||||
);
|
||||
return null;
|
||||
@@ -229,10 +225,9 @@ public class PojoClassIntrospector {
|
||||
return null;
|
||||
} catch (IllegalAccessException e) {
|
||||
log.warn(
|
||||
"Failed to access setter for field \"{}\" of class {} in hierarchy of {}",
|
||||
field.getName(),
|
||||
field.getDeclaringClass().getName(),
|
||||
clazz.getName(),
|
||||
"Failed to access setter for field \"" + field.getName() + "\" of class "
|
||||
+ field.getDeclaringClass().getName() + " in hierarchy of "
|
||||
+ clazz.getName(),
|
||||
e
|
||||
);
|
||||
return null;
|
||||
|
||||
@@ -11,7 +11,7 @@ import de.siphalor.tweed5.weaver.pojo.api.weaving.WeavingContext;
|
||||
import de.siphalor.tweed5.weaver.pojo.api.weaving.postprocess.TweedPojoWeavingPostProcessor;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import lombok.extern.apachecommons.CommonsLog;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
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.
|
||||
* The POJO must be annotated with {@link PojoWeaving}.
|
||||
*/
|
||||
@Slf4j
|
||||
@CommonsLog
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class TweedPojoWeaverBootstrapper<T> {
|
||||
private final Class<T> pojoClass;
|
||||
|
||||
Reference in New Issue
Block a user