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

com.genexus.ws.JAXRSObjectMapper Maven / Gradle / Ivy

Go to download

Core classes for the runtime used by Java and Android apps generated with GeneXus

There is a newer version: 4.7.3
Show newest version
package com.genexus.ws;

import com.fasterxml.jackson.core.StreamReadConstraints;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.ws.rs.ext.ContextResolver;
import jakarta.ws.rs.ext.Provider;

@Provider
public class JAXRSObjectMapper implements ContextResolver {

	private final ObjectMapper mapper;

	public JAXRSObjectMapper() {
		this.mapper = createObjectMapper();
	}

	@Override
	public ObjectMapper getContext(Class type) {
		return mapper;
	}

	private ObjectMapper createObjectMapper() {
		ObjectMapper mapper = new ObjectMapper();
		String bodyLengthLimit = System.getProperty("gx.jackson.bodylengthlimit");
		if (bodyLengthLimit != null)
			mapper.getFactory().setStreamReadConstraints(StreamReadConstraints.builder().maxStringLength(Integer.parseInt(bodyLengthLimit)).build());
		return mapper;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy