/protocols/jain-megaco/megaco-api/src/main/java/javax/megaco/association/CreateAssocReq.java
Java | 281 lines | 78 code | 23 blank | 180 comment | 6 complexity | 1b6ba85ca958575475a94d50882228ad MD5 | raw file
1/** 2 * Start time:11:45:35 2009-01-30<br> 3 * Project: mobicents-media-server-controllers<br> 4 * 5 * @author <a href="mailto:baranowb@gmail.com">baranowb - Bartosz Baranowski 6 * </a> 7 * @author <a href="mailto:brainslog@gmail.com"> Alexandre Mendonca </a> 8 */ 9package javax.megaco.association; 10 11import java.io.Serializable; 12 13import javax.megaco.AssociationEvent; 14 15 16/** 17 * The class extends JAIN MEGACO Association Events. This would cause the stack 18 * to configure the association with the parameters specified and initiate the 19 * protocol procedures to create an association with the peer. If the 20 * application is MGC, then the stack would expect ServiceChange messages from 21 * MG. And if the application if MG, then the stack would send ServiceChange 22 * command with the specified ServiceChangeMethod and ServiceChangeReason to 23 * MGC. 24 */ 25public class CreateAssocReq extends AssociationEvent implements Serializable { 26 27 protected LocalAddr localAddr = null; 28 protected RemoteAddr[] remoteAddr = null; 29 protected SrvChngReason srvChangeReason = null; 30 protected SrvChngMethod srvChngMethod = null; 31 protected LocalAddr srvChngAddress = null; 32 protected LocalAddr handOffMGCId = null; 33 protected EncodingFormat endcodingFormat = null; 34 35 public CreateAssocReq(Object source, int assocHandle) 36 throws IllegalArgumentException { 37 super(source, assocHandle); 38 39 } 40 41 /* 42 * (non-Javadoc) 43 * 44 * @see javax.megaco.AssociationEvent#getAssocOperIdentifier() 45 */ 46 @Override 47 public int getAssocOperIdentifier() { 48 return AssocEventType.M_CREATE_ASSOC_REQ; 49 } 50 51 /** 52 * Gets the local entity transport address. The local address specifies the 53 * transport address which the stack would use to send MEGACO messages to 54 * peer. 55 * 56 * @return Returns the local entity transport address. If the local address 57 * field is not present, then this method would return NULL. 58 */ 59 public LocalAddr getLocalAddr() { 60 return localAddr; 61 } 62 63 /** 64 * This method sets the local entity identity. The localAddr specifies the 65 * transport address which the stack would use to send transactions to peer. 66 * 67 * @param localAddr 68 * localAddr - The local entity transport address. Since the 69 * format of the message header Id is same as that of the 70 * transport address, the value of this may or may not be 71 * different from the local entity configured in the user Id as 72 * specified in the addMegacoListener method of MegacoProvider 73 * interface. 74 * @throws IllegalArgumentException 75 * This exception is raised if the local transport address 76 * specified is invalid. 77 */ 78 public void setLocalAddr(LocalAddr localAddr) 79 throws IllegalArgumentException { 80 this.localAddr = localAddr; 81 } 82 83 /** 84 * Gets the List of remote entity transport address for the User Id. The 85 * remote address specified in the address to which the stack would send 86 * MEGACO messages. There is one to one correspondence between the list of 87 * remote address specified here and the list of remote entity Ids in the 88 * UserId class. The messages comming from a particular remote entity must 89 * have same message header Id as the corresponding remote entity Id in 90 * UserId class. 91 * 92 * @return Returns the list of remote entity transport address. If the 93 * remote address parameter is not present, then this method would 94 * return NULL. 95 */ 96 public RemoteAddr[] getRemoteAddr() { 97 return remoteAddr; 98 } 99 100 /** 101 * Sets the list of remote entity identities of the user Id. The remote 102 * address specified in the address to which the stack would send MEGACO 103 * messages. There is one to one correspondence between the list of remote 104 * address specified here and the list of remote entity Ids in the UserId 105 * class. The messages comming from a particular remote entity must have 106 * same message header Id as the corresponding remote entity Id in UserId 107 * class. 108 * 109 * @param remoteAddr 110 * -- List of remote entity transport addresses of the MGC/MG. 111 * @throws IllegalArgumentException 112 * This exception is raised if the reference of Remote Address 113 * passed to this method is NULL. 114 */ 115 public void setRemoteAddr(RemoteAddr[] remoteAddr) 116 throws IllegalArgumentException { 117 this.remoteAddr = remoteAddr; 118 } 119 120 /** 121 * Gets the integer value which identifies the service change reason. This 122 * parameter is required on if the application is MG. The MG stack would use 123 * the same ServiceChange Reason in the ServiceChange command request sent 124 * to peer MGC. 125 * 126 * @return Returns the integer value corresponding to the service change 127 * reason. If the ServiceChangeReason is not set, then this method 128 * would return value null. The possible values are field constants 129 * defined for the class {@link SrvChngReason}. 130 */ 131 public SrvChngReason getSrvChangeReason() { 132// return srvChangeReason == null ? 0 : srvChangeReason 133// .getSrvChngReasonId(); 134 return srvChangeReason ; 135 } 136 137 /** 138 * This method sets the service change reason. This parameter is required on 139 * if the application is MG. The MG stack would use the same ServiceChange 140 * Reason in the ServiceChange command request sent to peer MGC. 141 * 142 * @param reason 143 * - The object reference to ServiceChange Reason. 144 * @throws IllegalArgumentException 145 * This exception is raised if the reference of Service Change 146 * Reason passed to this method is NULL. 147 */ 148 public void setSrvChangeReason(SrvChngReason reason) 149 throws IllegalArgumentException { 150 if (reason == null) { 151 throw new IllegalArgumentException("Change reason can not be null"); 152 } 153 this.srvChangeReason = reason; 154 } 155 156 /** 157 * Gets the integer value which identifies the service change method. This 158 * parameter is required on if the application is MG. The MG stack would use 159 * the same ServiceChange Method in ServiceChange command request sent to 160 * peer MGC. 161 * 162 * @return Returns the integer value corresponding to the service change 163 * method. If the ServiceChangeMethod is not set, then this method 164 * would return value null. The possible values are field constants 165 * defined for the class SrvChngMethod. 166 */ 167 public SrvChngMethod getSrvChngMethod() { 168 //return srvChngMethod == null ? 0 : srvChngMethod.getSrvChngReasonId(); 169 return srvChngMethod ; 170 } 171 172 /** 173 * This method sets the service change method. This parameter is required on 174 * if the application is MG. The MG stack would use the same ServiceChange 175 * Method in ServiceChange command request sent to peer MGC. 176 * 177 * @param method 178 * - The object reference to ServiceChange Method. 179 * @throws IllegalArgumentException 180 * This exception is raised if the reference of Service Change 181 * Reason passed to this method is NULL. 182 */ 183 public void setSrvChngMethod(SrvChngMethod method) 184 throws IllegalArgumentException { 185 if (method == null) { 186 throw new IllegalArgumentException("Change method can not be null"); 187 } 188 this.srvChngMethod = method; 189 } 190 191 /** 192 * Gets the service change address. 193 * 194 * @return Returns the service change address. if the service change address 195 * is not set, then this method would return NULL. 196 */ 197 public LocalAddr getSrvChngAddress() { 198 return srvChngAddress; 199 } 200 201 /** 202 * This method sets the service change address. The local entity specfied 203 * earlier is the transport address would be used for initial registration 204 * and then subsequently, the address specified in the serviceChngAddress 205 * field would be used for the local transport address. If the application 206 * is MGC, then on receipt of ServiceChange command (on ROOT termination), 207 * it will reply with ServiceChangeAddress field in 208 * serviceChangeReplyDescriptor descriptor, with value as set using this 209 * method. And If the application is MG, then the stack will send the 210 * ServiceChange command (on ROOT termination) with ServiceChangeAddress 211 * field in serviceChangeDescriptor descriptor, with value as set using this 212 * method. 213 * 214 * @param srvChngAddress 215 * The service change address. 216 * @throws IllegalArgumentException 217 * This exception is raised if the service change address 218 * specified is invalid. 219 */ 220 public void setSrvChngAddress(LocalAddr srvChngAddress) 221 throws IllegalArgumentException { 222 //FIXME: IllegalArgumentException 223 this.srvChngAddress = srvChngAddress; 224 } 225 226 /** 227 * Gets the identity of the MGC to which the association is to be handoffed. 228 * This parameter may be set if the application is MGC. 229 * 230 * @return Returns the identity of the MGC to which the association is to be 231 * handoffed. If the HandedOff MGC Id is missing, then method 232 * returns NULL. 233 */ 234 public LocalAddr getHandOffMGCId() { 235 return handOffMGCId; 236 } 237 238 /** 239 * This method sets the identity of the MGC to which the association is to 240 * be handoffed. This parameter may be set if the application is MGC. If 241 * this parameter is set, then on receipt of service change request from MG 242 * (with ROOT termination), the stack will reply with MgcIdToTry field in 243 * serviceChangeDescriptor descriptor, with value as set using this method. 244 * 245 * @param handOffMGCId 246 * The identity of the MGC to which the association is to be 247 * handoffed. 248 * @throws IllegalArgumentException 249 * This exception is raised if the HandedOffMGCId specified is 250 * invalid. 251 */ 252 public void setHandOffMGCId(LocalAddr handOffMGCId) 253 throws IllegalArgumentException { 254 //FIXME: IllegalArgumentException 255 this.handOffMGCId = handOffMGCId; 256 } 257 258 public int getEndcodingFormat() { 259 //FIXME 0 is valid value == TEXT ? 260 return endcodingFormat==null?0:endcodingFormat.getEncodingFormat(); 261 } 262 263 /** 264 * This method sets the encoding format which is to be configured. 265 * 266 * @param endcodingFormat 267 * The object reference to derived class of EncodingFormat class 268 * which gives value of encoding format. 269 * @throws IllegalArgumentException 270 * This exception is raised if the reference of Encoding Format 271 * passed to this method is NULL. 272 */ 273 public void setEndcodingFormat(EncodingFormat format) 274 throws IllegalArgumentException { 275 if (format == null) { 276 throw new IllegalArgumentException("Encoding format can not be null"); 277 } 278 this.endcodingFormat = format; 279 } 280 281}