PageRenderTime 23ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/protocols/ss7/m3ua/impl/src/main/java/org/mobicents/protocols/ss7/m3ua/impl/as/AsStateEnterPen.java

http://mobicents.googlecode.com/
Java | 67 lines | 34 code | 10 blank | 23 comment | 4 complexity | 2c2a93e2ec448bfa8c0efdad17472484 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.as;
  23. import javolution.util.FastList;
  24. import org.apache.log4j.Logger;
  25. import org.mobicents.protocols.ss7.m3ua.impl.Asp;
  26. import org.mobicents.protocols.ss7.m3ua.impl.AspState;
  27. import org.mobicents.protocols.ss7.m3ua.impl.TransitionState;
  28. import org.mobicents.protocols.ss7.m3ua.impl.fsm.FSM;
  29. import org.mobicents.protocols.ss7.m3ua.impl.fsm.State;
  30. import org.mobicents.protocols.ss7.m3ua.impl.fsm.StateEventHandler;
  31. import org.mobicents.protocols.ss7.m3ua.impl.fsm.UnknownTransitionException;
  32. public class AsStateEnterPen implements StateEventHandler {
  33. private static final Logger logger = Logger.getLogger(AsStateEnterPen.class);
  34. private AsImpl as = null;
  35. private FSM fsm;
  36. public AsStateEnterPen(AsImpl as, FSM fsm) {
  37. this.as = as;
  38. this.fsm = fsm;
  39. }
  40. public void onEvent(State state) {
  41. // If there is even one ASP in INACTIVE state for this AS, ACTIVATE it
  42. for (FastList.Node<Asp> n = as.getAspList().head(), end = as.getAspList().tail(); (n = n
  43. .getNext()) != end;) {
  44. AspImpl asp = (AspImpl) n.getValue();
  45. if (asp.getState() == AspState.INACTIVE) {
  46. LocalAspFactory localAspFactory = (LocalAspFactory) asp.getAspFactory();
  47. localAspFactory.sendAspActive(this.as);
  48. // Transition the state of ASP to ACTIVE_SENT
  49. try {
  50. asp.getFSM().signal(TransitionState.ASP_ACTIVE_SENT);
  51. } catch (UnknownTransitionException e) {
  52. logger.error(e.getMessage(), e);
  53. }
  54. }
  55. }
  56. }
  57. }