/protocols/jain-megaco/megaco-api/src/main/java/javax/megaco/association/CreateAssocReq.java

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