1 56 package org.objectstyle.cayenne.distribution; 57 58 import org.apache.commons.lang.builder.ToStringBuilder; 59 import org.objectstyle.cayenne.client.CayenneClientException; 60 61 67 public abstract class AbstractMessage implements ClientMessage { 68 69 public abstract Object onReceive(ClientMessageHandler handler); 70 71 78 protected Object send(CayenneConnector connector, Class resultClass) { 79 Object result = connector.sendMessage(this); 80 81 if (result != null && !resultClass.isInstance(result)) { 82 String resultString = new ToStringBuilder(result).toString(); 83 throw new CayenneClientException("Expected result type: " 84 + resultClass.getName() 85 + ", actual: " 86 + resultString); 87 } 88 89 return result; 90 } 91 } 92 | Popular Tags |