
com.gruelbox.transactionoutbox.jackson.CustomInvocationSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of transactionoutbox-jackson Show documentation
Show all versions of transactionoutbox-jackson Show documentation
A safe implementation of the transactional outbox pattern for Java (Jackson extension library)
package com.gruelbox.transactionoutbox.jackson;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import com.gruelbox.transactionoutbox.Invocation;
import java.io.IOException;
class CustomInvocationSerializer extends StdSerializer {
public CustomInvocationSerializer() {
this(Invocation.class);
}
protected CustomInvocationSerializer(Class t) {
super(t);
}
@Override
public void serialize(Invocation value, JsonGenerator gen, SerializerProvider provider)
throws IOException {
gen.writeStartObject();
gen.writeStringField("className", value.getClassName());
gen.writeStringField("methodName", value.getMethodName());
gen.writeArrayFieldStart("parameterTypes");
for (Class> parameterType : value.getParameterTypes()) {
gen.writeString(parameterType.getCanonicalName());
}
gen.writeEndArray();
gen.writeObjectField("args", value.getArgs());
gen.writeObjectField("mdc", value.getMdc());
gen.writeEndObject();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy