org.jsmpp.session
Class AbstractSession

java.lang.Object
  extended by org.jsmpp.session.AbstractSession
All Implemented Interfaces:
Session
Direct Known Subclasses:
SMPPServerSession, SMPPSession

public abstract class AbstractSession
extends java.lang.Object
implements Session

Author:
uudashr

Constructor Summary
AbstractSession(PDUSender pduSender)
           
 
Method Summary
 void addSessionStateListener(SessionStateListener l)
           
 void close()
          Forced close connection without sending UNBIND command to Message Center.
protected abstract  Connection connection()
           
 DataSmResult dataShortMessage(java.lang.String serviceType, TypeOfNumber sourceAddrTon, NumberingPlanIndicator sourceAddrNpi, java.lang.String sourceAddr, TypeOfNumber destAddrTon, NumberingPlanIndicator destAddrNpi, java.lang.String destinationAddr, ESMClass esmClass, RegisteredDelivery registeredDelivery, DataCoding dataCoding, OptionalParameter... optionalParameters)
          Send the data_sm command.
protected  Command executeSendCommand(SendCommandTask task, long timeout)
          Execute send command command task.
protected  DataSmResult fireAcceptDataSm(DataSm dataSm)
           
 int getEnquireLinkTimer()
           
 long getLastActivityTimestamp()
          Get the last reading valid PDU from remote host.
 int getPduProcessorDegree()
          Get the total of thread that can handle read and process PDU parallely.
 java.lang.String getSessionId()
          Get session id.
 SessionState getSessionState()
           
 long getTransactionTimer()
           
protected abstract  GenericMessageReceiverListener messageReceiverListener()
           
protected  PDUSender pduSender()
           
protected  PendingResponse<Command> removePendingResponse(int sequenceNumber)
           
 void removeSessionStateListener(SessionStateListener l)
           
protected  void sendEnquireLink()
          Ensure we have proper link.
protected  Sequence sequence()
           
protected abstract  AbstractSessionContext sessionContext()
           
 void setEnquireLinkTimer(int enquireLinkTimer)
           
 void setPduProcessorDegree(int pduProcessorDegree)
          Set total thread can read PDU and process it parallely.
 void setTransactionTimer(long transactionTimer)
           
 void unbindAndClose()
          Sending UNBIND and close connection immediately.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractSession

public AbstractSession(PDUSender pduSender)
Method Detail

sessionContext

protected abstract AbstractSessionContext sessionContext()

connection

protected abstract Connection connection()

messageReceiverListener

protected abstract GenericMessageReceiverListener messageReceiverListener()

pduSender

protected PDUSender pduSender()

sequence

protected Sequence sequence()

removePendingResponse

protected PendingResponse<Command> removePendingResponse(int sequenceNumber)

getSessionId

public java.lang.String getSessionId()
Description copied from interface: Session
Get session id.

Specified by:
getSessionId in interface Session
Returns:
the session id.

setEnquireLinkTimer

public void setEnquireLinkTimer(int enquireLinkTimer)
Specified by:
setEnquireLinkTimer in interface Session

getEnquireLinkTimer

public int getEnquireLinkTimer()
Specified by:
getEnquireLinkTimer in interface Session

setTransactionTimer

public void setTransactionTimer(long transactionTimer)
Specified by:
setTransactionTimer in interface Session

getTransactionTimer

public long getTransactionTimer()
Specified by:
getTransactionTimer in interface Session

getSessionState

public SessionState getSessionState()
Specified by:
getSessionState in interface Session

addSessionStateListener

public void addSessionStateListener(SessionStateListener l)
Specified by:
addSessionStateListener in interface Session

removeSessionStateListener

public void removeSessionStateListener(SessionStateListener l)
Specified by:
removeSessionStateListener in interface Session

getLastActivityTimestamp

public long getLastActivityTimestamp()
Description copied from interface: Session
Get the last reading valid PDU from remote host.

Specified by:
getLastActivityTimestamp in interface Session
Returns:
the last reading valid PDU from remote host.

setPduProcessorDegree

public void setPduProcessorDegree(int pduProcessorDegree)
                           throws java.lang.IllegalStateException
Set total thread can read PDU and process it parallely. It's defaulted to 3.

Parameters:
pduProcessorDegree - is the total thread can handle read and process PDU parallely.
Throws:
java.lang.IllegalStateException - if the PDU Reader has been started.

getPduProcessorDegree

public int getPduProcessorDegree()
Get the total of thread that can handle read and process PDU parallely.

Returns:
the total of thread that can handle read and process PDU parallely.

dataShortMessage

public DataSmResult dataShortMessage(java.lang.String serviceType,
                                     TypeOfNumber sourceAddrTon,
                                     NumberingPlanIndicator sourceAddrNpi,
                                     java.lang.String sourceAddr,
                                     TypeOfNumber destAddrTon,
                                     NumberingPlanIndicator destAddrNpi,
                                     java.lang.String destinationAddr,
                                     ESMClass esmClass,
                                     RegisteredDelivery registeredDelivery,
                                     DataCoding dataCoding,
                                     OptionalParameter... optionalParameters)
                              throws PDUException,
                                     ResponseTimeoutException,
                                     InvalidResponseException,
                                     NegativeResponseException,
                                     java.io.IOException
Send the data_sm command.

Specified by:
dataShortMessage in interface Session
Parameters:
serviceType - is the service_type parameter.
sourceAddrTon - is the source_addr_ton parameter.
sourceAddrNpi - is the source_addr_npi parameter.
sourceAddr - is the source_addr parameter.
destAddrTon - is the dest_addr_ton parameter.
destAddrNpi - is the dest_addr_npi parameter.
destinationAddr - is the destination_addr parameter.
esmClass - is the esm_class parameter.
registeredDelivery - is the registered_delivery parameter.
dataCoding - is the data_coding parameter.
optionalParameters - is the optional parameters.
Returns:
the result of data_sm (data_sm_resp).
Throws:
PDUException - if there is an invalid PDU parameter found.
ResponseTimeoutException - if the response take time too long.
InvalidResponseException - if the response is invalid.
NegativeResponseException - if the response return NON-OK command_status.
java.io.IOException - if there is an IO error found.

close

public void close()
Description copied from interface: Session
Forced close connection without sending UNBIND command to Message Center.

Specified by:
close in interface Session

fireAcceptDataSm

protected DataSmResult fireAcceptDataSm(DataSm dataSm)
                                 throws ProcessRequestException
Throws:
ProcessRequestException

executeSendCommand

protected Command executeSendCommand(SendCommandTask task,
                                     long timeout)
                              throws PDUException,
                                     ResponseTimeoutException,
                                     InvalidResponseException,
                                     NegativeResponseException,
                                     java.io.IOException
Execute send command command task.

Parameters:
task - is the task.
timeout - is the timeout in millisecond.
Returns:
the command response.
Throws:
PDUException - if there is invalid PDU parameter found.
ResponseTimeoutException - if the response has reach it timeout.
InvalidResponseException - if invalid response found.
NegativeResponseException - if the negative response found.
java.io.IOException - if there is an IO error found.

sendEnquireLink

protected void sendEnquireLink()
                        throws ResponseTimeoutException,
                               InvalidResponseException,
                               java.io.IOException
Ensure we have proper link.

Throws:
ResponseTimeoutException - if there is no valid response after defined millisecond.
InvalidResponseException - if there is invalid response found.
java.io.IOException - if there is an IO error found.

unbindAndClose

public void unbindAndClose()
Description copied from interface: Session
Sending UNBIND and close connection immediately.

Specified by:
unbindAndClose in interface Session