1 package net.walend.somnifugi; 2 3 import java.io.Serializable ; 4 5 import javax.jms.ObjectMessage ; 6 import javax.jms.JMSException ; 7 8 13 14 public class SomniObjectMessage 15 extends SomniMessage 16 implements ObjectMessage 17 { 18 private Serializable gut = null; 19 20 protected SomniObjectMessage() 21 { 22 super(); 23 } 24 25 28 protected SomniObjectMessage(SomniObjectMessage message,boolean deep) 29 throws JMSException 30 { 31 super(message,deep); 32 if(deep) 33 { 34 gut = (Serializable )serializedCopy(message.getObject()); 35 } 36 else 37 { 38 gut = message.getObject(); 39 } 40 } 41 42 56 public void setObject(Serializable object) 57 throws JMSException 58 { 59 synchronized(guard) 60 { 61 checkWritable(); 62 gut = object; 63 } 64 } 65 66 75 public Serializable getObject() 76 throws JMSException 77 { 78 synchronized(guard) 79 { 80 return gut; 81 } 82 } 83 84 95 public void clearBody() 96 throws JMSException 97 { 98 synchronized(guard) 99 { 100 super.clearBody(); 101 gut = null; 102 } 103 } 104 105 108 protected SomniMessage shallowCopy() 109 throws JMSException 110 { 111 synchronized(guard) 112 { 113 return new SomniObjectMessage(this,false); 114 } 115 } 116 117 120 protected SomniMessage deepCopy() 121 throws JMSException 122 { 123 synchronized(guard) 124 { 125 return new SomniObjectMessage(this,true); 126 } 127 } 128 129 public String toString() 130 { 131 StringBuffer buffy = new StringBuffer (); 132 buffy.append(super.toString()); 133 buffy.append(" contains:"); 134 135 if(gut!=null) 136 { 137 buffy.append(gut.toString()); 138 } 139 else 140 { 141 buffy.append("null"); 142 } 143 144 return buffy.toString(); 145 } 146 } 147 148 168 | Popular Tags |