/protocols/ss7/m3ua/impl/src/main/java/org/mobicents/protocols/ss7/m3ua/impl/as/AspImpl.java
Java | 166 lines | 67 code | 38 blank | 61 comment | 0 complexity | 95718ba353a81188fee0cb37e9561801 MD5 | raw file
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 23package org.mobicents.protocols.ss7.m3ua.impl.as; 24 25import javolution.xml.XMLFormat; 26import javolution.xml.stream.XMLStreamException; 27 28import org.mobicents.protocols.ss7.m3ua.M3UAProvider; 29import org.mobicents.protocols.ss7.m3ua.impl.Asp; 30import org.mobicents.protocols.ss7.m3ua.impl.AspFactory; 31import org.mobicents.protocols.ss7.m3ua.impl.AspState; 32import org.mobicents.protocols.ss7.m3ua.impl.TransitionState; 33 34/** 35 * @author amit bhayani 36 */ 37public class AspImpl extends Asp { 38 39 public AspImpl() { 40 41 } 42 43 public AspImpl(String name, M3UAProvider m3UAProvider, AspFactory aspFactory) { 44 super(name, m3UAProvider, aspFactory); 45 46 // Define states 47 fsm.createState(AspState.DOWN_SENT.toString()); 48 fsm.createState(AspState.DOWN.toString()); 49 fsm.createState(AspState.UP_SENT.toString()); 50 fsm.createState(AspState.INACTIVE.toString()); 51 fsm.createState(AspState.ACTIVE_SENT.toString()); 52 fsm.createState(AspState.ACTIVE.toString()); 53 fsm.createState(AspState.INACTIVE_SENT.toString()); 54 55 fsm.setStart(AspState.DOWN.toString()); 56 fsm.setEnd(AspState.DOWN.toString()); 57 58 // Define Transitions 59 60 // ******************************************************************/ 61 // DOWN / 62 // ******************************************************************/ 63 fsm.createTransition(TransitionState.COMM_UP, AspState.DOWN.toString(), AspState.UP_SENT.toString()); 64 // .setHandler(new AspTransDwnToAspUpSnt(this, this.fsm)); 65 66 fsm.createTransition(TransitionState.COMM_DOWN, AspState.DOWN.toString(), AspState.DOWN.toString()); 67 68 // ******************************************************************/ 69 // UP_SENT/ 70 // ******************************************************************/ 71 // TODO Keep sending ASP_UP. Also wrong logic here, every ASP will send 72 // ASP_UP ? 73 fsm.createTimeoutTransition(AspState.UP_SENT.toString(), AspState.UP_SENT.toString(), 2000).setHandler( 74 new AspTransDwnToAspUpSnt(this, this.fsm)); 75 76 fsm.createTransition(TransitionState.ASP_INACTIVE, AspState.UP_SENT.toString(), AspState.INACTIVE.toString()); 77 78 fsm.createTransition(TransitionState.ASP_ACTIVE_SENT, AspState.UP_SENT.toString(), 79 AspState.ACTIVE_SENT.toString()); 80 81 fsm.createTransition(TransitionState.ASP_DOWN_SENT, AspState.UP_SENT.toString(), AspState.DOWN_SENT.toString()); 82 83 fsm.createTransition(TransitionState.COMM_DOWN, AspState.UP_SENT.toString(), AspState.DOWN.toString()); 84 85 // ******************************************************************/ 86 // ACTIVE_SENT/ 87 // ******************************************************************/ 88 // TODO Keep sending ASP_ACTIVE ? 89 fsm.createTimeoutTransition(AspState.ACTIVE_SENT.toString(), AspState.ACTIVE_SENT.toString(), 2000); 90 91 fsm.createTransition(TransitionState.ASP_ACTIVE_ACK, AspState.ACTIVE_SENT.toString(), 92 AspState.ACTIVE.toString()); 93 // .setHandler(new AspTransActSntToAct(this, this.fsm)); 94 95 fsm.createTransition(TransitionState.ASP_DOWN_SENT, AspState.ACTIVE_SENT.toString(), 96 AspState.DOWN_SENT.toString()); 97 98 fsm.createTransition(TransitionState.COMM_DOWN, AspState.ACTIVE_SENT.toString(), AspState.DOWN.toString()); 99 100 // ******************************************************************/ 101 // ACTIVE/ 102 // ******************************************************************/ 103 fsm.createTransition(TransitionState.ASP_INACTIVE_SENT, AspState.ACTIVE.toString(), 104 AspState.INACTIVE_SENT.toString()); 105 // .setHandler(new AspTransActToInactSnt(this, this.fsm)); 106 107 fsm.createTransition(TransitionState.OTHER_ALTERNATE_ASP_ACTIVE, AspState.ACTIVE.toString(), 108 AspState.INACTIVE.toString()); 109 110 fsm.createTransition(TransitionState.ASP_DOWN_SENT, AspState.ACTIVE.toString(), AspState.DOWN_SENT.toString()); 111 112 fsm.createTransition(TransitionState.COMM_DOWN, AspState.ACTIVE.toString(), AspState.DOWN.toString()); 113 // .setHandler(new AspTransActToDwn(this, this.fsm)); 114 115 // ******************************************************************/ 116 // INACTIVE/ 117 // ******************************************************************/ 118 fsm.createTransition(TransitionState.COMM_DOWN, AspState.INACTIVE.toString(), AspState.DOWN.toString()); 119 // .setHandler(new AspTransInactToDwn(this, this.fsm)); 120 121 fsm.createTransition(TransitionState.ASP_ACTIVE_SENT, AspState.INACTIVE.toString(), 122 AspState.ACTIVE_SENT.toString()); 123 124 fsm.createTransition(TransitionState.ASP_DOWN_SENT, AspState.INACTIVE.toString(), AspState.DOWN_SENT.toString()); 125 126 // ******************************************************************/ 127 // INACTIVE_SENT/ 128 // ******************************************************************/ 129 // TODO keep sending INACTIVE ASP ? 130 fsm.createTimeoutTransition(AspState.INACTIVE_SENT.toString(), AspState.INACTIVE_SENT.toString(), 2000); 131 // TODO Take care of this .setHandler(new AspTransActToInactSnt(this, 132 // this.fsm)); 133 134 fsm.createTransition(TransitionState.ASP_INACTIVE_ACK, AspState.INACTIVE_SENT.toString(), 135 AspState.INACTIVE.toString()); 136 137 fsm.createTransition(TransitionState.ASP_DOWN_SENT, AspState.INACTIVE_SENT.toString(), 138 AspState.DOWN_SENT.toString()); 139 140 fsm.createTransition(TransitionState.COMM_DOWN, AspState.INACTIVE_SENT.toString(), AspState.DOWN.toString()); 141 142 // ******************************************************************/ 143 // DOWN_SENT/ 144 // ******************************************************************/ 145 fsm.createTransition(TransitionState.ASP_DOWN_ACK, AspState.DOWN_SENT.toString(), AspState.DOWN.toString()); 146 147 fsm.createTransition(TransitionState.COMM_DOWN, AspState.DOWN_SENT.toString(), AspState.DOWN.toString()); 148 149 } 150 151 /** 152 * XML Serialization/Deserialization 153 */ 154 protected static final XMLFormat<AspImpl> ASP_IMPL_XML = new XMLFormat<AspImpl>(AspImpl.class) { 155 156 @Override 157 public void read(javolution.xml.XMLFormat.InputElement xml, AspImpl aspImpl) throws XMLStreamException { 158 ASP_XML.read(xml, aspImpl); 159 } 160 161 @Override 162 public void write(AspImpl aspImpl, javolution.xml.XMLFormat.OutputElement xml) throws XMLStreamException { 163 ASP_XML.write(aspImpl, xml); 164 } 165 }; 166}