1 13 package info.magnolia.cms.exchange.simple; 14 15 import info.magnolia.exchange.Packet; 16 import info.magnolia.exchange.PacketBody; 17 import info.magnolia.exchange.PacketHeader; 18 import info.magnolia.exchange.PacketType; 19 20 import java.util.Iterator ; 21 22 import org.apache.log4j.Logger; 23 import org.doomdark.uuid.UUIDGenerator; 24 25 26 30 public class PacketImpl implements Packet { 31 32 private static Logger log = Logger.getLogger(PacketImpl.class); 33 34 private String id; 35 36 private PacketHeader header; 37 38 private PacketBody body; 39 40 public PacketImpl() { 41 this.header = new PacketHeaderImpl(); 42 this.body = new PacketBodyImpl(); 43 } 44 45 public String getID() { 46 return this.id; 47 } 48 49 public void assignID() { 50 this.id = UUIDGenerator.getInstance().generateTimeBasedUUID().toString(); 51 this.getHeaders().addHeader("id", id); } 53 54 public void assignID(String id) { 55 this.id = id; 56 this.getHeaders().addHeader("ID", id); } 58 59 public void setChannelID(String id) { 60 log.debug("Method not implemented (setChannelID)"); } 62 63 public String getChannelID() { 64 log.debug("Method not implemented (getChannelID)"); return null; 66 } 67 68 public PacketHeader getHeaders() { 69 return this.header; 70 } 71 72 public void setHeaders(PacketHeader header) { 73 76 Iterator keys = header.getKeys().iterator(); 77 while (keys.hasNext()) { 78 String key = (String ) keys.next(); 79 this.header.addHeader(key, header.getValueByName(key)); 80 } 81 } 82 83 public void setBody(PacketBody body) { 84 this.body = body; 85 this.getHeaders().addHeader("Type", PacketType.getNameByType(this.body.getType())); } 87 88 public PacketBody getBody() { 89 return this.body; 90 } 91 } 92
| Popular Tags
|