/protocols/ss7/sgw/gateway/src/main/java/org/mobicents/ss7/sgw/SignalingGateway.java
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 23package org.mobicents.ss7.sgw; 24 25import java.io.IOException; 26 27import org.apache.log4j.Logger; 28import org.mobicents.ss7.impl.clock.LocalTask; 29import org.mobicents.ss7.impl.clock.Scheduler; 30import org.mobicents.ss7.spi.clock.Task; 31 32public class SignalingGateway implements Task { 33 34 public final static Scheduler scheduler = new Scheduler(); 35 36 private static final Logger logger = Logger.getLogger(SignalingGateway.class); 37 38 private ShellExecutor shellExecutor = null; 39 private NodalInterworkingFunction nodalInterworkingFunction = null; 40 41 private LocalTask task = null; 42 private boolean isActive = false; 43 44 public SignalingGateway() { 45 46 } 47 48 public ShellExecutor getShellExecutor() { 49 return shellExecutor; 50 } 51 52 public void setShellExecutor(ShellExecutor shellExecutor) { 53 this.shellExecutor = shellExecutor; 54 } 55 56 public NodalInterworkingFunction getNodalInterworkingFunction() { 57 return nodalInterworkingFunction; 58 } 59 60 public void setNodalInterworkingFunction(NodalInterworkingFunction nodalInterworkingFunction) { 61 this.nodalInterworkingFunction = nodalInterworkingFunction; 62 } 63 64 /** 65 * Life Cycle methods 66 */ 67 public void create() { 68 69 } 70 71 public void start() throws Exception { 72 scheduler.start(); 73 task = scheduler.execute(this); 74 } 75 76 public void stop() { 77 task.cancel(); 78 } 79 80 public void destroy() { 81 82 } 83 84 public void cancel() { 85 this.isActive = false; 86 } 87 88 public boolean isActive() { 89 return this.isActive; 90 } 91 92 public int perform() { 93 try { 94 this.shellExecutor.perform(); 95 this.nodalInterworkingFunction.perform(); 96 // Management 97 } catch (IOException e) { 98 logger.error("IOException ", e); 99 } 100 101 return 1; 102 } 103 104}