1 18 package org.apache.activemq.transport.udp; 19 20 import org.apache.activemq.command.Command; 21 import org.apache.activemq.openwire.OpenWireFormat; 22 import org.apache.activemq.transport.reliable.ReplayBuffer; 23 import org.apache.activemq.util.IntSequenceGenerator; 24 25 import java.io.IOException ; 26 import java.net.SocketAddress ; 27 28 32 public abstract class CommandChannelSupport implements CommandChannel { 33 34 protected OpenWireFormat wireFormat; 35 protected int datagramSize = 4 * 1024; 36 protected SocketAddress targetAddress; 37 protected SocketAddress replayAddress; 38 protected final String name; 39 protected final IntSequenceGenerator sequenceGenerator; 40 protected DatagramHeaderMarshaller headerMarshaller; 41 private ReplayBuffer replayBuffer; 42 43 public CommandChannelSupport(UdpTransport transport, OpenWireFormat wireFormat, int datagramSize, SocketAddress targetAddress, 44 DatagramHeaderMarshaller headerMarshaller) { 45 this.wireFormat = wireFormat; 46 this.datagramSize = datagramSize; 47 this.targetAddress = targetAddress; 48 this.headerMarshaller = headerMarshaller; 49 this.name = transport.toString(); 50 this.sequenceGenerator = transport.getSequenceGenerator(); 51 this.replayAddress = targetAddress; 52 if (sequenceGenerator == null) { 53 throw new IllegalArgumentException ("No sequenceGenerator on the given transport: " + transport); 54 } 55 } 56 57 public void write(Command command) throws IOException { 58 write(command, targetAddress); 59 } 60 61 62 65 public int getDatagramSize() { 66 return datagramSize; 67 } 68 69 72 public void setDatagramSize(int datagramSize) { 73 this.datagramSize = datagramSize; 74 } 75 76 public SocketAddress getTargetAddress() { 77 return targetAddress; 78 } 79 80 public void setTargetAddress(SocketAddress targetAddress) { 81 this.targetAddress = targetAddress; 82 } 83 84 public SocketAddress getReplayAddress() { 85 return replayAddress; 86 } 87 88 public void setReplayAddress(SocketAddress replayAddress) { 89 this.replayAddress = replayAddress; 90 } 91 92 public String toString() { 93 return "CommandChannel#" + name; 94 } 95 96 public DatagramHeaderMarshaller getHeaderMarshaller() { 97 return headerMarshaller; 98 } 99 100 public void setHeaderMarshaller(DatagramHeaderMarshaller headerMarshaller) { 101 this.headerMarshaller = headerMarshaller; 102 } 103 104 public ReplayBuffer getReplayBuffer() { 105 return replayBuffer; 106 } 107 108 public void setReplayBuffer(ReplayBuffer replayBuffer) { 109 this.replayBuffer = replayBuffer; 110 } 111 112 } 113 | Popular Tags |