/protocols/ss7/m3ua/impl/src/main/java/org/mobicents/protocols/ss7/m3ua/impl/sg/RemAspImpl.java
Java | 130 lines | 51 code | 28 blank | 51 comment | 0 complexity | 23e5d7121295f74eb510ca6b83a69a56 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.sg; 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 * 36 * @author amit bhayani 37 */ 38public class RemAspImpl extends Asp { 39 40 public RemAspImpl() { 41 super(); 42 } 43 44 public RemAspImpl(String name, M3UAProvider m3UAProvider, AspFactory aspFactory) { 45 super(name, m3UAProvider, aspFactory); 46 47 // Define states 48 fsm.createState(AspState.DOWN.toString()); 49 fsm.createState(AspState.ACTIVE.toString()); 50 fsm.createState(AspState.INACTIVE.toString()); 51 52 fsm.setStart(AspState.DOWN.toString()); 53 fsm.setEnd(AspState.DOWN.toString()); 54 55 // Define Transitions 56 57 // ******************************************************************/ 58 // STATE DOWN / 59 // ******************************************************************/ 60 fsm.createTransition(TransitionState.COMM_UP, AspState.DOWN.toString(), AspState.DOWN.toString()); 61 fsm.createTransition(TransitionState.COMM_DOWN, AspState.DOWN.toString(), AspState.DOWN.toString()); 62 fsm.createTransition(TransitionState.ASP_UP, AspState.DOWN.toString(), AspState.INACTIVE.toString()); 63 // .setHandler(new RemAspTransDwnToInact(this, fsm)); 64 65 // If the SGP receives any other M3UA messages before an ASP Up message 66 // is received (other than ASP Down; see Section 4.3.4.2), the SGP MAY 67 // discard them. 68 fsm.createTransition(TransitionState.DAUD, AspState.DOWN.toString(), AspState.DOWN.toString()); 69 fsm.createTransition(TransitionState.ASP_ACTIVE, AspState.DOWN.toString(), AspState.DOWN.toString()); 70 fsm.createTransition(TransitionState.ASP_INACTIVE, AspState.DOWN.toString(), AspState.DOWN.toString()); 71 fsm.createTransition(TransitionState.PAYLOAD, AspState.DOWN.toString(), AspState.DOWN.toString()); 72 73 fsm.createTransition(TransitionState.ASP_DOWN, AspState.DOWN.toString(), AspState.DOWN.toString()); 74 // TODO : For REG_REQ/DREG_REQ we don't support dynamic adding of key. 75 // Handle this 76 77 // ******************************************************************/ 78 // STATE INACTIVE / 79 // ******************************************************************/ 80 fsm.createTransition(TransitionState.COMM_DOWN, AspState.INACTIVE.toString(), AspState.DOWN.toString()); 81 // Mo transition needed? .setHandler(new RemAspTransInactToDwn(this, 82 // this.fsm)); 83 84 fsm.createTransition(TransitionState.ASP_UP, AspState.INACTIVE.toString(), AspState.INACTIVE.toString()); 85 86 fsm.createTransition(TransitionState.ASP_DOWN, AspState.INACTIVE.toString(), AspState.DOWN.toString()); 87 88 fsm.createTransition(TransitionState.ASP_ACTIVE, AspState.INACTIVE.toString(), AspState.ACTIVE.toString()); 89 90 // TODO: Ignore payload if Remote ASP is still INACTIVE. may be log it? 91 fsm.createTransition(TransitionState.PAYLOAD, AspState.INACTIVE.toString(), AspState.INACTIVE.toString()); 92 93 // ******************************************************************/ 94 // STATE ACTIVE / 95 // ******************************************************************/ 96 fsm.createTransition(TransitionState.COMM_DOWN, AspState.ACTIVE.toString(), AspState.DOWN.toString()); 97 98 fsm.createTransition(TransitionState.ASP_UP, AspState.ACTIVE.toString(), AspState.INACTIVE.toString()); 99 100 fsm.createTransition(TransitionState.ASP_DOWN, AspState.ACTIVE.toString(), AspState.DOWN.toString()); 101 102 fsm.createTransition(TransitionState.ASP_INACTIVE, AspState.ACTIVE.toString(), AspState.INACTIVE.toString()); 103 // No transition handler .setHandler(new RemAspTransActToInact(this, 104 // this.fsm)); 105 106 fsm.createTransition(TransitionState.PAYLOAD, AspState.ACTIVE.toString(), AspState.ACTIVE.toString()); 107 108 // This transition will be signaled from SGW 109 fsm.createTransition(TransitionState.OTHER_ALTERNATE_ASP_ACTIVE, AspState.ACTIVE.toString(), 110 AspState.INACTIVE.toString()); 111 112 } 113 114 /** 115 * XML Serialization/Deserialization 116 */ 117 protected static final XMLFormat<RemAspImpl> REM_ASP_IMPL_XML = new XMLFormat<RemAspImpl>(RemAspImpl.class) { 118 119 @Override 120 public void read(javolution.xml.XMLFormat.InputElement xml, RemAspImpl remAspImpl) throws XMLStreamException { 121 ASP_XML.read(xml, remAspImpl); 122 } 123 124 @Override 125 public void write(RemAspImpl remAspImpl, javolution.xml.XMLFormat.OutputElement xml) throws XMLStreamException { 126 ASP_XML.write(remAspImpl, xml); 127 } 128 }; 129 130}