1 56 package org.objectstyle.cayenne.distribution; 57 58 import org.objectstyle.cayenne.client.CayenneClientException; 59 import org.objectstyle.cayenne.util.Util; 60 61 70 public class LocalConnector implements CayenneConnector { 71 72 protected ClientMessageHandler handler; 73 protected boolean serializingMessages; 74 75 public LocalConnector(ClientMessageHandler handler) { 76 this(handler, false); 77 } 78 79 public LocalConnector(ClientMessageHandler handler, boolean serializingMessages) { 80 this.handler = handler; 81 this.serializingMessages = serializingMessages; 82 } 83 84 public boolean isSerializingMessages() { 85 return serializingMessages; 86 } 87 88 public ClientMessageHandler getHandler() { 89 return handler; 90 } 91 92 95 public void connect() throws CayenneClientException { 96 } 97 98 101 public Object sendMessage(ClientMessage message) throws CayenneClientException { 102 if (isSerializingMessages()) { 103 104 try { 105 message = (ClientMessage) Util.cloneViaSerialization(message); 106 } 107 catch (Exception ex) { 108 throw new CayenneClientException("Error serializing message", ex); 109 } 110 } 111 return message.onReceive(handler); 112 } 113 114 } 115 | Popular Tags |