
io.jexxa.jexxatest.integrationtest.rest.RESTBinding Maven / Gradle / Ivy
package io.jexxa.jexxatest.integrationtest.rest;
import io.jexxa.common.facade.json.JSONManager;
import io.jexxa.core.BoundedContext;
import kong.unirest.GenericType;
import kong.unirest.ObjectMapper;
import kong.unirest.Unirest;
import java.util.Properties;
public class RESTBinding
{
private final Properties properties;
public RESTBinding(Properties properties)
{
Unirest.config().setObjectMapper(new UnirestObjectMapper());
this.properties = properties;
}
public RESTHandler getRESTHandler(Class> endpoint)
{
return new RESTHandler(properties, endpoint);
}
public BoundedContextHandler getBoundedContext()
{
return new BoundedContextHandler(properties, BoundedContext.class);
}
private static class UnirestObjectMapper implements ObjectMapper
{
@Override
public T readValue(String value, Class valueType)
{
return JSONManager.getJSONConverter().fromJson(value, valueType);
}
@Override
public T readValue(String value, GenericType genericType)
{
return JSONManager.getJSONConverter().fromJson(value, genericType.getType());
}
@Override
public String writeValue(Object value)
{
return JSONManager.getJSONConverter().toJson(value);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy