1 19 20 package org.apache.cayenne.remote.hessian.service; 21 22 import java.io.IOException ; 23 24 import org.apache.cayenne.CayenneRuntimeException; 25 import org.apache.cayenne.map.EntityResolver; 26 import org.apache.cayenne.map.ObjEntity; 27 import org.apache.cayenne.query.AbstractQuery; 28 29 import com.caucho.hessian.io.AbstractHessianInput; 30 import com.caucho.hessian.io.JavaDeserializer; 31 32 38 class ServerAbstractQueryDeserializer extends JavaDeserializer { 39 40 private EntityResolver clientResolver; 41 42 ServerAbstractQueryDeserializer(Class cl, EntityResolver clientResolver) { 43 super(cl); 44 45 this.clientResolver = clientResolver; 46 } 47 48 public Object readMap(AbstractHessianInput in) throws IOException { 49 Object object = super.readMap(in); 50 51 if (object instanceof AbstractQuery) { 52 53 AbstractQuery abstractClientQuery = (AbstractQuery) object; 54 Object root = abstractClientQuery.getRoot(); 55 if (root instanceof Class ) { 56 ObjEntity entity = clientResolver.lookupObjEntity((Class ) root); 57 if (entity == null) { 58 throw new CayenneRuntimeException("Unmapped client class: " + root); 59 } 60 abstractClientQuery.setRoot(entity.getName()); 61 } 62 } 63 64 return object; 65 } 66 } 67 | Popular Tags |