1 18 package org.apache.activemq.transport.xstream; 19 20 import java.io.Reader ; 21 22 import org.apache.activemq.command.Command; 23 import org.apache.activemq.transport.util.TextWireFormat; 24 import org.apache.activemq.wireformat.WireFormat; 25 26 import com.thoughtworks.xstream.XStream; 27 28 35 public class XStreamWireFormat extends TextWireFormat { 36 private XStream xStream; 37 private int version; 38 39 public int getVersion() { 40 return version; 41 } 42 43 public void setVersion(int version) { 44 this.version = version; 45 } 46 47 48 public WireFormat copy() { 49 return new XStreamWireFormat(); 50 } 51 52 53 public Object unmarshalText(String text) { 54 return (Command) getXStream().fromXML(text); 55 } 56 57 public Object unmarshalText(Reader reader) { 58 return (Command) getXStream().fromXML(reader); 59 } 60 61 public String marshalText(Object command) { 62 return getXStream().toXML(command); 63 } 64 65 72 public boolean canProcessWireFormatVersion(int version) { 73 return true; 74 } 75 76 79 public int getCurrentWireFormatVersion() { 80 return 1; 81 } 82 83 public XStream getXStream() { 86 if (xStream == null) { 87 xStream = createXStream(); 88 } 89 return xStream; 90 } 91 92 public void setXStream(XStream xStream) { 93 this.xStream = xStream; 94 } 95 96 protected XStream createXStream() { 99 return new XStream(); 100 } 101 102 103 } 104 | Popular Tags |