All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.smpp.smscsim.PDUProcessor Maven / Gradle / Ivy

There is a newer version: 3.0.2
Show newest version
/*
 * Copyright (c) 1996-2001
 * Logica Mobile Networks Limited
 * All rights reserved.
 *
 * This software is distributed under Logica Open Source License Version 1.0
 * ("Licence Agreement"). You shall use it and distribute only in accordance
 * with the terms of the License Agreement.
 *
 */
package org.smpp.smscsim;

import java.io.IOException;

import org.smpp.pdu.PDUException;
import org.smpp.pdu.Request;
import org.smpp.pdu.Response;

/**
 * PDUProcessor is abstract class which defines interface
 * functions for processing PDUs received by SMSCSession
 * from client as well as functions for the server side sending of PDU.
 * The actual implementation of the abstract functions of the class
 * defines the behaviour of the particular simulator.
* The implementations of this class are ment to be generated by * descendant of PDUProcessorFactory class whenewer * new connection is accepted by SMSCListener. * * @author Logica Mobile Networks SMPP Open Source Team * @version $Revision: 1.2 $ * @see PDUProcessorFactory * @see SMSCSession * @see SMSCListener */ public abstract class PDUProcessor { /** * The group the processor belongs to. It's good for having overall control * over specific group of processors, e.g. for those generated * for particular listener. */ private PDUProcessorGroup group = null; /** * If the processor is still processing, i.e. wasn't exited. * @see #exit() */ private boolean active = true; /** * Private variables initialsed to default values. */ public PDUProcessor() { } /** * Initialises the processor with the given group. * The group is basicaly intended to be a group of active * processors. * @param group the group this processor belongs to */ public PDUProcessor(PDUProcessorGroup group) { setGroup(group); } /** * Meant to process requests received from client. * @param request the request received from client */ public abstract void clientRequest(Request request); /** * Meant to process responses received from client. * @param response the response received from client */ public abstract void clientResponse(Response response); /** * Meant to process requests sent on behalf of the server. * This method is called by server and typically only sends the PDU * to the client. * @param request the request which has to be sent to client */ public abstract void serverRequest(Request request) throws IOException, PDUException; /** * Meant to process responses sent on behalf of the server. * This method is called by server and typically only sends the PDU * to the client. * @param response the response which has to be sent to client */ public abstract void serverResponse(Response response) throws IOException, PDUException; /** * Stop the processor */ public abstract void stop(); /** * Sets the group which the pdu processor belongs to. * Processor can belong to only one group. * @param g the new group for the processor */ public void setGroup(PDUProcessorGroup g) { if (group != null) { group.remove(this); } group = g; if (group != null) { group.add(this); } } /** * Returns the group of this pdu processor. * @return the current group of the processor * @see #setGroup(PDUProcessorGroup) */ public PDUProcessorGroup getGroup() { return group; } /** * Returns if this pdu processor is still active. * @return the activity status of the processor * @see #exit() */ public boolean isActive() { return active; } /** * Sets the processor to inactive state. * Removes the processor from the group it belonged to. * Called from SMSCSession. * @see SMSCSession#run() */ public void exit() { if (group != null) { group.remove(this); } active = false; stop(); } } /* * $Log: not supported by cvs2svn $ * Revision 1.1 2003/07/23 00:28:39 sverkera * Imported * */




© 2015 - 2024 Weber Informatics LLC | Privacy Policy