SMSLib 3.5.3

org.smslib.smsserver.interfaces
Class Interface<T>

java.lang.Object
  extended by org.smslib.smsserver.interfaces.Interface<T>
Direct Known Subclasses:
Database, SimpleInboundFileLogger

public class Interface<T>
extends java.lang.Object

The base class of all implemented SMSServer interfaces.

An SMSServer interface can be thought of as a message producer or a message consumer.

SMSServer comes with a couple of ready-made interfaces. If you wish to extend SMSServer with new interface functionality, create your own interface by implementing the current class.


Nested Class Summary
static class Interface.InterfaceTypes
          Class representing SMSServer interface types.
 
Constructor Summary
Interface(java.lang.String myInfId, java.util.Properties myProps, SMSServer myServer, Interface.InterfaceTypes myType)
           
 
Method Summary
 void callReceived(java.lang.String gtwId, java.lang.String callerId)
          This method is called by SMSServer every time an inbound call is received.
 java.lang.String getDescription()
          Returns the interface description.
 java.lang.String getId()
           
 java.util.Map<java.lang.Long,T> getMessageCache()
           
 java.util.Collection<OutboundMessage> getMessagesToSend()
          SMSServer calls this method in order to query the interface for messages that need to be send out.
 int getPendingMessagesToSend()
          This method returns the number of outbound queued messages identified by this interface.
 java.lang.String getProperty(java.lang.String key)
          Reads the property key of this interface.
 java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
          Reads the property key of this interface.
 SMSServer getServer()
           
 Interface.InterfaceTypes getType()
          Returns the interface type.
 boolean isInbound()
          Returns true if the interface is for inbound messaging.
 boolean isOutbound()
          Returns true if the interface is for outbound messaging.
 void markMessage(OutboundMessage msg)
          After a successful or unsuccessful attempt to send a message, SMSServer calls this method.
 void markMessages(java.util.Collection<OutboundMessage> msgList)
           
 void messagesReceived(java.util.Collection<InboundMessage> msgList)
          This method is called by SMSServer every time a message (or more messages) is received.
 void setDescription(java.lang.String myDescription)
          Sets the interface description.
 void start()
          Called once before SMSServer starts its operation.
 void stop()
          Called once after SMSServer has finished.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Interface

public Interface(java.lang.String myInfId,
                 java.util.Properties myProps,
                 SMSServer myServer,
                 Interface.InterfaceTypes myType)
Method Detail

getServer

public final SMSServer getServer()

getId

public java.lang.String getId()

callReceived

public void callReceived(java.lang.String gtwId,
                         java.lang.String callerId)
                  throws java.lang.Exception
This method is called by SMSServer every time an inbound call is received. SMSServer calls this method for all available/active interfaces.

Override this call if you wish to implement your own functionality.

Parameters:
gtwId - The Id of the gateway which received the call.
callerId - The caller id.
Throws:
java.lang.Exception

getDescription

public final java.lang.String getDescription()
Returns the interface description.

Returns:
The interface description.

setDescription

public final void setDescription(java.lang.String myDescription)
Sets the interface description.

Parameters:
myDescription - The interface description.

getMessageCache

public final java.util.Map<java.lang.Long,T> getMessageCache()

getMessagesToSend

public java.util.Collection<OutboundMessage> getMessagesToSend()
                                                        throws java.lang.Exception
SMSServer calls this method in order to query the interface for messages that need to be send out.

Override this call if you wish to implement your own functionality.

Returns:
A list of Outbound messages to be sent. Return an empty list if the interface has no messages for dispatch.
Throws:
java.lang.Exception

getPendingMessagesToSend

public int getPendingMessagesToSend()
                             throws java.lang.Exception
This method returns the number of outbound queued messages identified by this interface. Should return (-1) if this method is not implemented or if the number cannot be determined.

Returns:
The number of pending messages to be sent via this interface.
Throws:
java.lang.Exception

getProperty

public final java.lang.String getProperty(java.lang.String key)
Reads the property key of this interface.

Parameters:
key - The key of the property to read.
Returns:
The value of the property or null if not set

getProperty

public final java.lang.String getProperty(java.lang.String key,
                                          java.lang.String defaultValue)
Reads the property key of this interface.
The defaultValue is returned if the key is not defined in the properties.

Parameters:
key - The key of the property to read.
defaultValue - The defaultValue if key is not defined.
Returns:
The value of the property or defaultValue if not set.

getType

public final Interface.InterfaceTypes getType()
Returns the interface type.

Returns:
The interface type.
See Also:
Interface.InterfaceTypes

isInbound

public final boolean isInbound()
Returns true if the interface is for inbound messaging.

Returns:
True if the interface is for inbound messaging.

isOutbound

public final boolean isOutbound()
Returns true if the interface is for outbound messaging.

Returns:
True if the interface is for outbound messaging.

markMessage

public void markMessage(OutboundMessage msg)
                 throws java.lang.Exception
After a successful or unsuccessful attempt to send a message, SMSServer calls this method. The interface can then decide what to do with the message. Note that the message status and errors member fields are updated, so you should examine them in order to determine whether the message has been sent out, etc.

Override this call if you wish to implement your own functionality.

Parameters:
msg - The Outbound message.
Throws:
java.lang.Exception

markMessages

public void markMessages(java.util.Collection<OutboundMessage> msgList)
                  throws java.lang.Exception
Throws:
java.lang.Exception

messagesReceived

public void messagesReceived(java.util.Collection<InboundMessage> msgList)
                      throws java.lang.Exception
This method is called by SMSServer every time a message (or more messages) is received. SMSServer calls this method for all available/active interfaces.

Override this call if you wish to implement your own functionality.

Parameters:
msgList - A message list of all received messages.
Throws:
java.lang.Exception

start

public void start()
           throws java.lang.Exception
Called once before SMSServer starts its operation. Use this method for initialization.

Override this call if you wish to implement your own functionality.

Throws:
java.lang.Exception - An exception thrown will stop SMSServer from starting its processing.

stop

public void stop()
          throws java.lang.Exception
Called once after SMSServer has finished. Use this method for cleaning up your interface.

Override this call if you wish to implement your own functionality.

Throws:
java.lang.Exception

SMSLib 3.5.3

(c) 2002-2011, http://smslib.org