PageRenderTime 39ms CodeModel.GetById 32ms RepoModel.GetById 1ms app.codeStats 0ms

/protocols/ss7/m3ua/impl/src/main/java/org/mobicents/protocols/ss7/m3ua/impl/sg/RemAspImpl.java

http://mobicents.googlecode.com/
Java | 130 lines | 51 code | 28 blank | 51 comment | 0 complexity | 23e5d7121295f74eb510ca6b83a69a56 MD5 | raw file
Possible License(s): LGPL-3.0, GPL-3.0, LGPL-2.1, GPL-2.0, CC-BY-SA-3.0, CC0-1.0, Apache-2.0, BSD-3-Clause
  1. /*
  2. * JBoss, Home of Professional Open Source
  3. * Copyright 2011, Red Hat, Inc. and individual contributors
  4. * by the @authors tag. See the copyright.txt in the distribution for a
  5. * full listing of individual contributors.
  6. *
  7. * This is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU Lesser General Public License as
  9. * published by the Free Software Foundation; either version 2.1 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This software is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this software; if not, write to the Free
  19. * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21. */
  22. package org.mobicents.protocols.ss7.m3ua.impl.sg;
  23. import javolution.xml.XMLFormat;
  24. import javolution.xml.stream.XMLStreamException;
  25. import org.mobicents.protocols.ss7.m3ua.M3UAProvider;
  26. import org.mobicents.protocols.ss7.m3ua.impl.Asp;
  27. import org.mobicents.protocols.ss7.m3ua.impl.AspFactory;
  28. import org.mobicents.protocols.ss7.m3ua.impl.AspState;
  29. import org.mobicents.protocols.ss7.m3ua.impl.TransitionState;
  30. /**
  31. *
  32. * @author amit bhayani
  33. */
  34. public class RemAspImpl extends Asp {
  35. public RemAspImpl() {
  36. super();
  37. }
  38. public RemAspImpl(String name, M3UAProvider m3UAProvider, AspFactory aspFactory) {
  39. super(name, m3UAProvider, aspFactory);
  40. // Define states
  41. fsm.createState(AspState.DOWN.toString());
  42. fsm.createState(AspState.ACTIVE.toString());
  43. fsm.createState(AspState.INACTIVE.toString());
  44. fsm.setStart(AspState.DOWN.toString());
  45. fsm.setEnd(AspState.DOWN.toString());
  46. // Define Transitions
  47. // ******************************************************************/
  48. // STATE DOWN /
  49. // ******************************************************************/
  50. fsm.createTransition(TransitionState.COMM_UP, AspState.DOWN.toString(), AspState.DOWN.toString());
  51. fsm.createTransition(TransitionState.COMM_DOWN, AspState.DOWN.toString(), AspState.DOWN.toString());
  52. fsm.createTransition(TransitionState.ASP_UP, AspState.DOWN.toString(), AspState.INACTIVE.toString());
  53. // .setHandler(new RemAspTransDwnToInact(this, fsm));
  54. // If the SGP receives any other M3UA messages before an ASP Up message
  55. // is received (other than ASP Down; see Section 4.3.4.2), the SGP MAY
  56. // discard them.
  57. fsm.createTransition(TransitionState.DAUD, AspState.DOWN.toString(), AspState.DOWN.toString());
  58. fsm.createTransition(TransitionState.ASP_ACTIVE, AspState.DOWN.toString(), AspState.DOWN.toString());
  59. fsm.createTransition(TransitionState.ASP_INACTIVE, AspState.DOWN.toString(), AspState.DOWN.toString());
  60. fsm.createTransition(TransitionState.PAYLOAD, AspState.DOWN.toString(), AspState.DOWN.toString());
  61. fsm.createTransition(TransitionState.ASP_DOWN, AspState.DOWN.toString(), AspState.DOWN.toString());
  62. // TODO : For REG_REQ/DREG_REQ we don't support dynamic adding of key.
  63. // Handle this
  64. // ******************************************************************/
  65. // STATE INACTIVE /
  66. // ******************************************************************/
  67. fsm.createTransition(TransitionState.COMM_DOWN, AspState.INACTIVE.toString(), AspState.DOWN.toString());
  68. // Mo transition needed? .setHandler(new RemAspTransInactToDwn(this,
  69. // this.fsm));
  70. fsm.createTransition(TransitionState.ASP_UP, AspState.INACTIVE.toString(), AspState.INACTIVE.toString());
  71. fsm.createTransition(TransitionState.ASP_DOWN, AspState.INACTIVE.toString(), AspState.DOWN.toString());
  72. fsm.createTransition(TransitionState.ASP_ACTIVE, AspState.INACTIVE.toString(), AspState.ACTIVE.toString());
  73. // TODO: Ignore payload if Remote ASP is still INACTIVE. may be log it?
  74. fsm.createTransition(TransitionState.PAYLOAD, AspState.INACTIVE.toString(), AspState.INACTIVE.toString());
  75. // ******************************************************************/
  76. // STATE ACTIVE /
  77. // ******************************************************************/
  78. fsm.createTransition(TransitionState.COMM_DOWN, AspState.ACTIVE.toString(), AspState.DOWN.toString());
  79. fsm.createTransition(TransitionState.ASP_UP, AspState.ACTIVE.toString(), AspState.INACTIVE.toString());
  80. fsm.createTransition(TransitionState.ASP_DOWN, AspState.ACTIVE.toString(), AspState.DOWN.toString());
  81. fsm.createTransition(TransitionState.ASP_INACTIVE, AspState.ACTIVE.toString(), AspState.INACTIVE.toString());
  82. // No transition handler .setHandler(new RemAspTransActToInact(this,
  83. // this.fsm));
  84. fsm.createTransition(TransitionState.PAYLOAD, AspState.ACTIVE.toString(), AspState.ACTIVE.toString());
  85. // This transition will be signaled from SGW
  86. fsm.createTransition(TransitionState.OTHER_ALTERNATE_ASP_ACTIVE, AspState.ACTIVE.toString(),
  87. AspState.INACTIVE.toString());
  88. }
  89. /**
  90. * XML Serialization/Deserialization
  91. */
  92. protected static final XMLFormat<RemAspImpl> REM_ASP_IMPL_XML = new XMLFormat<RemAspImpl>(RemAspImpl.class) {
  93. @Override
  94. public void read(javolution.xml.XMLFormat.InputElement xml, RemAspImpl remAspImpl) throws XMLStreamException {
  95. ASP_XML.read(xml, remAspImpl);
  96. }
  97. @Override
  98. public void write(RemAspImpl remAspImpl, javolution.xml.XMLFormat.OutputElement xml) throws XMLStreamException {
  99. ASP_XML.write(remAspImpl, xml);
  100. }
  101. };
  102. }