/protocols/ss7/sgw/gateway/src/main/java/org/mobicents/ss7/sgw/SignalingGateway.java

http://mobicents.googlecode.com/ · Java · 104 lines · 54 code · 25 blank · 25 comment · 0 complexity · 7f2b0ce94dae057c876fdbbffa1ec4fb 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. package org.mobicents.ss7.sgw;
  23. import java.io.IOException;
  24. import org.apache.log4j.Logger;
  25. import org.mobicents.ss7.impl.clock.LocalTask;
  26. import org.mobicents.ss7.impl.clock.Scheduler;
  27. import org.mobicents.ss7.spi.clock.Task;
  28. public class SignalingGateway implements Task {
  29. public final static Scheduler scheduler = new Scheduler();
  30. private static final Logger logger = Logger.getLogger(SignalingGateway.class);
  31. private ShellExecutor shellExecutor = null;
  32. private NodalInterworkingFunction nodalInterworkingFunction = null;
  33. private LocalTask task = null;
  34. private boolean isActive = false;
  35. public SignalingGateway() {
  36. }
  37. public ShellExecutor getShellExecutor() {
  38. return shellExecutor;
  39. }
  40. public void setShellExecutor(ShellExecutor shellExecutor) {
  41. this.shellExecutor = shellExecutor;
  42. }
  43. public NodalInterworkingFunction getNodalInterworkingFunction() {
  44. return nodalInterworkingFunction;
  45. }
  46. public void setNodalInterworkingFunction(NodalInterworkingFunction nodalInterworkingFunction) {
  47. this.nodalInterworkingFunction = nodalInterworkingFunction;
  48. }
  49. /**
  50. * Life Cycle methods
  51. */
  52. public void create() {
  53. }
  54. public void start() throws Exception {
  55. scheduler.start();
  56. task = scheduler.execute(this);
  57. }
  58. public void stop() {
  59. task.cancel();
  60. }
  61. public void destroy() {
  62. }
  63. public void cancel() {
  64. this.isActive = false;
  65. }
  66. public boolean isActive() {
  67. return this.isActive;
  68. }
  69. public int perform() {
  70. try {
  71. this.shellExecutor.perform();
  72. this.nodalInterworkingFunction.perform();
  73. // Management
  74. } catch (IOException e) {
  75. logger.error("IOException ", e);
  76. }
  77. return 1;
  78. }
  79. }