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

io.ebeaninternal.server.json.DJsonBeanReader Maven / Gradle / Ivy

There is a newer version: 15.8.0
Show newest version
package io.ebeaninternal.server.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 final 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.persistenceContext(); } @Override public T read(T target) { try { return desc.jsonRead(readJson, null, target); } catch (IOException e) { throw new PersistenceIOException(e); } } @Override public JsonBeanReader forJson(JsonParser moreJson) { return new DJsonBeanReader<>(desc, readJson.forJson(moreJson)); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy