1 19 20 package org.apache.cayenne.remote.service; 21 22 import org.apache.cayenne.CayenneRuntimeException; 23 import org.apache.cayenne.DataChannel; 24 import org.apache.cayenne.remote.BootstrapMessage; 25 import org.apache.cayenne.remote.ClientMessage; 26 import org.apache.cayenne.remote.QueryMessage; 27 import org.apache.cayenne.remote.SyncMessage; 28 29 35 class DispatchHelper { 36 37 static Object dispatch(DataChannel channel, ClientMessage message) { 38 if (message instanceof QueryMessage) { 40 return channel.onQuery(null, ((QueryMessage) message).getQuery()); 41 } 42 else if (message instanceof SyncMessage) { 43 SyncMessage sync = (SyncMessage) message; 44 return channel.onSync(null, sync.getSenderChanges(), sync.getType()); 45 } 46 else if (message instanceof BootstrapMessage) { 47 return channel.getEntityResolver().getClientEntityResolver(); 48 } 49 else { 50 throw new CayenneRuntimeException( 51 "Message dispatch error. Unsupported message: " + message); 52 } 53 } 54 } 55 | Popular Tags |