methanol-jaxb-jakarta¶
Adapters for XML using Jakarta EE's JAXB.
Installation¶
Gradle¶
implementation("com.github.mizosoft.methanol:methanol-jaxb-jakarta:1.7.0")
Maven¶
<dependency>
<groupId>com.github.mizosoft.methanol</groupId>
<artifactId>methanol-jaxb-jakarta</artifactId>
<version>1.7.0</version>
</dependency>
Usage¶
var adapterCodec =
AdapterCodec.newBuilder()
.encoder(JaxbAdapterFactory.createEncoder())
.decoder(JaxbAdapterFactory.createDecoder())
.build();
var client =
Methanol.newBuilder()
.adapterCodec(adapterCodec)
.build();
record Person(String name) {}
var bruceLee = new Person("Bruce Lee");
var response = client.send(
MutableRequest.POST(".../echo", bruceLee, MediaType.APPLICATION_XML),
Person.class);
assertThat(response.body()).isEqualTo(bruceLee);
Legacy Adapters¶
See Legacy Adapters