io.ebeaninternal.server.text.json.DJsonBeanReader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ebean Show documentation
Show all versions of ebean Show documentation
composite of common runtime dependencies for all platforms
package io.ebeaninternal.server.text.json;
import com.fasterxml.jackson.core.JsonParser;
import io.ebean.PersistenceIOException;
import io.ebean.bean.PersistenceContext;
import io.ebean.text.json.JsonBeanReader;
import io.ebeaninternal.api.json.SpiJsonReader;
import io.ebeaninternal.server.deploy.BeanDescriptor;
import java.io.IOException;
/**
* A 'context' for reading entity beans from JSON.
*
* This is used such that a load context and persistence context can be used to span multiple marshalling requests.
*
*/
public class DJsonBeanReader implements JsonBeanReader {
private final BeanDescriptor desc;
private final SpiJsonReader readJson;
public DJsonBeanReader(BeanDescriptor desc, SpiJsonReader readJson) {
this.desc = desc;
this.readJson = readJson;
}
@Override
public void persistenceContextPut(Object beanId, T currentBean) {
readJson.persistenceContextPut(beanId, currentBean);
}
@Override
public PersistenceContext getPersistenceContext() {
return readJson.getPersistenceContext();
}
@Override
public T read() {
try {
return desc.jsonRead(readJson, null);
} catch (IOException e) {
throw new PersistenceIOException(e);
}
}
@Override
public JsonBeanReader forJson(JsonParser moreJson, boolean resetContext) {
return new DJsonBeanReader<>(desc, readJson.forJson(moreJson, resetContext));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy