All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gruelbox.transactionoutbox.jackson.CustomInvocationSerializer Maven / Gradle / Ivy

Go to download

A safe implementation of the transactional outbox pattern for Java (Jackson extension library)

There is a newer version: 6.0.553
Show newest version
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