1 24 25 package org.objectweb.dream.message; 26 27 import java.util.ArrayList ; 28 import java.util.Iterator ; 29 import java.util.List ; 30 31 35 public class AggregateMessageImpl 36 implements 37 ExtensibleMessage, 38 MessageReferenceCounter 39 { 40 final List subMessages = new ArrayList (); 41 transient short messageManagerId; 42 transient int referenceCounter; 43 44 48 53 public void addChunk(String name, ChunkType chkType, Object chunk) 54 throws ChunkAlreadyExistsException 55 { 56 throw new UnsupportedOperationException (); 57 } 58 59 64 public Object removeChunk(String name) 65 { 66 return null; 67 } 68 69 72 public void addSubMessage(Message message) 73 { 74 subMessages.add(message); 75 } 76 77 80 public boolean removeSubMessage(Message message) 81 { 82 return subMessages.remove(message); 83 } 84 85 88 public void removeSubMessages() 89 { 90 subMessages.clear(); 91 } 92 93 97 100 public short getMessageManagerId() 101 { 102 return messageManagerId; 103 } 104 105 108 public void setMessageManagerId(short id) 109 { 110 messageManagerId = id; 111 } 112 113 116 public Object getChunk(String name) 117 { 118 return null; 119 } 120 121 124 public Iterator getSubMessageIterator() 125 { 126 return subMessages.iterator(); 127 } 128 129 132 public Message[] getSubMessages() 133 { 134 Message[] subMessageArray = new Message[subMessages.size()]; 135 return (Message[]) subMessages.toArray(subMessageArray); 136 } 137 138 143 public MessageType getMessageType() 144 { 145 throw new UnsupportedOperationException (); 146 } 147 148 151 public void transfertChunkStates(Message newInstance) 152 { 153 } 155 156 159 public void recycle() 160 { 161 subMessages.clear(); 162 } 163 164 168 171 public void incrementReferenceCounter() 172 { 173 referenceCounter++; 174 } 175 176 179 public boolean decrementReferenceCounter() 180 { 181 synchronized (this) 182 { 183 referenceCounter--; 184 return (referenceCounter == 0); 185 } 186 } 187 188 } | Popular Tags |