com.ados.hestia.sdk.session
Class Session

java.lang.Object
  extended by com.ados.hestia.sdk.session.Session
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
InitiationSession, RespondSession

public abstract class Session
extends Object
implements Serializable

Represent session to exchange with partner.

Version:
$Revision: 1413 $ $Date: 2005-11-30 07:49:47 +0900 $
See Also:
Serialized Form

Field Summary
protected  Date m_createDate
           
protected  String m_error
           
protected  List<Container> m_history
           
protected  Date m_lastActivityDate
           
protected  List<SessionListener> m_listeners
           
protected  PayloadContainer m_localMessage
           
protected  PayloadContainer m_partnerMessage
           
protected  String m_rejectReason
           
protected  String m_sessionID
           
protected  int m_state
           
protected  WaitedContainerDescription m_waitedDescription
           
static int NOTIFY_MESSAGE_RECEIVE
           
static int NOTIFY_MESSAGE_SENT
           
static int NOTIFY_STATE_CHANGES
           
static int NOTIFY_STATUS_RECEIVE
           
static int NOTIFY_STATUS_SENT
           
static int SESSION_TYPE_INITIATION
           
static int SESSION_TYPE_RESPOND
           
static int STATE_CREATED
           
static int STATE_ERROR
           
static int STATE_FINISHED
           
static int STATE_IDLE
           
static int STATE_READY_TO_SEND_MESSAGE
           
static int STATE_READY_TO_SEND_STATUS
           
static int STATE_WAIT_ACCEPTANCE
           
static int STATE_WAIT_MESSAGE
           
static int STATE_WAIT_PREPARE_RESPOND
           
static int STATE_WAIT_STATUS
           
 
Constructor Summary
protected Session(String sessionID)
           
 
Method Summary
abstract  void acceptPartnerMessage()
          Accept message from partner.
 void addListener(SessionListener listener)
          Add session listener.
 String getEIS()
          Returns id of eis for current session or null if not set.
 String getError()
          Returns description of error when state of session is STATE_ERROR.
 Container[] getHistory()
          Returns history of this session.
protected  PayloadContainer getInitiatedContainer()
          Returns container wich was first for session.
 Date getLastActivityDate()
          Returns last activity date for session.
 PayloadContainer getLocalMessage()
          Returns local message.
abstract  PayloadContainer getMessageToSend()
          Called by external dispatcher when session prepared message for delivering to partner.
 String getPartner()
          Returns id of partner for current session or null if not set.
 PayloadContainer getPartnerMessage()
          Returns message from partner.
 String getPIPID()
          Returns associated with session pipid.
 String getPipInstanceID()
          Returns associated with session pipinstance id.
 Date getStartDate()
          Returns start date for this session.
 int getState()
          Returns current state of session.
abstract  StatusContainer getStatusToSend()
          Called by external dispatcher when session prepared status for delivering to partner.
abstract  int getType()
          Returns type of session.
 String getVersion()
          Returns associated with session pip version.
abstract  WaitedContainerDescription getWaitedContainerDesc()
          Returns description about which pip, pip instance id and partner are accepted.
 boolean isActive()
          Return true if Session is still active (not finished and not has error).
 boolean isError()
          Return true if Session is finished with error status.
 boolean isFinished()
          Return true if Session is successfully finished.
protected  void notifyEvent(int id, Object object)
          Internal method.
abstract  void pushMessage(PayloadContainer message)
          Called by external dispatcher.
abstract  void pushStatus(StatusContainer status)
          Called by external dispatcher.
abstract  void rejectPartnerMessage(String reason)
          Rejcect partner message whit specific reason.
 void removeListener(SessionListener listener)
          Remove session listener.
 void restore(InputStream instream)
          Restore state of session from external storage.
 void serialize(OutputStream outstream)
          Serialize current state of session to external storage.
abstract  void setLocalMessage(PayloadContainer message)
          Set local message for partner.
 void stop()
          Stop current session.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

STATE_CREATED

public static final int STATE_CREATED
See Also:
Constant Field Values

STATE_READY_TO_SEND_MESSAGE

public static final int STATE_READY_TO_SEND_MESSAGE
See Also:
Constant Field Values

STATE_READY_TO_SEND_STATUS

public static final int STATE_READY_TO_SEND_STATUS
See Also:
Constant Field Values

STATE_WAIT_STATUS

public static final int STATE_WAIT_STATUS
See Also:
Constant Field Values

STATE_WAIT_MESSAGE

public static final int STATE_WAIT_MESSAGE
See Also:
Constant Field Values

STATE_WAIT_ACCEPTANCE

public static final int STATE_WAIT_ACCEPTANCE
See Also:
Constant Field Values

STATE_WAIT_PREPARE_RESPOND

public static final int STATE_WAIT_PREPARE_RESPOND
See Also:
Constant Field Values

STATE_IDLE

public static final int STATE_IDLE
See Also:
Constant Field Values

STATE_FINISHED

public static final int STATE_FINISHED
See Also:
Constant Field Values

STATE_ERROR

public static final int STATE_ERROR
See Also:
Constant Field Values

NOTIFY_STATE_CHANGES

public static final int NOTIFY_STATE_CHANGES
See Also:
Constant Field Values

NOTIFY_MESSAGE_SENT

public static final int NOTIFY_MESSAGE_SENT
See Also:
Constant Field Values

NOTIFY_MESSAGE_RECEIVE

public static final int NOTIFY_MESSAGE_RECEIVE
See Also:
Constant Field Values

NOTIFY_STATUS_SENT

public static final int NOTIFY_STATUS_SENT
See Also:
Constant Field Values

NOTIFY_STATUS_RECEIVE

public static final int NOTIFY_STATUS_RECEIVE
See Also:
Constant Field Values

SESSION_TYPE_INITIATION

public static final int SESSION_TYPE_INITIATION
See Also:
Constant Field Values

SESSION_TYPE_RESPOND

public static final int SESSION_TYPE_RESPOND
See Also:
Constant Field Values

m_state

protected int m_state

m_partnerMessage

protected PayloadContainer m_partnerMessage

m_localMessage

protected PayloadContainer m_localMessage

m_waitedDescription

protected WaitedContainerDescription m_waitedDescription

m_rejectReason

protected String m_rejectReason

m_history

protected List<Container> m_history

m_sessionID

protected String m_sessionID

m_error

protected String m_error

m_listeners

protected List<SessionListener> m_listeners

m_createDate

protected Date m_createDate

m_lastActivityDate

protected Date m_lastActivityDate
Constructor Detail

Session

protected Session(String sessionID)
Method Detail

getStartDate

public Date getStartDate()
Returns start date for this session.

Returns:
start date for this session

getLastActivityDate

public Date getLastActivityDate()
Returns last activity date for session.

Returns:
last activity date for session

addListener

public void addListener(SessionListener listener)
Add session listener.

Parameters:
listener - listener to add

removeListener

public void removeListener(SessionListener listener)
Remove session listener.

Parameters:
listener - listener to remove

notifyEvent

protected void notifyEvent(int id,
                           Object object)
Internal method. Notify all listener about specific event.

Parameters:
id - id of event. See NOTIFY_*
object - object of event. Specific from id

getState

public int getState()
Returns current state of session. See STATE_* constants.

Returns:
current state of session. See STATE_* constants

getPartnerMessage

public PayloadContainer getPartnerMessage()
Returns message from partner. It can be eaither request when remote partner is initiator or a respond from 2 action PIPs when initiator is local partner request when remote partner is initiator or a respond from 2 action PIPs when initiator is local partner.

Returns:
message from partner. It can be eaither

getLocalMessage

public PayloadContainer getLocalMessage()
Returns local message. It can be message for PIP when initiator is local user or response of local partner at 2 action PIP when initiator is local user or response of local partner at 2 action PIP.

Returns:
local message. It can be message for PIP

setLocalMessage

public abstract void setLocalMessage(PayloadContainer message)
Set local message for partner. This is used for 2 action pip to set response.


getError

public String getError()
Returns description of error when state of session is STATE_ERROR.

Returns:
description of error when state of session is STATE_ERROR

acceptPartnerMessage

public abstract void acceptPartnerMessage()
Accept message from partner. This call is available when state is set to STATE_WAIT_ACCEPTANCE.


rejectPartnerMessage

public abstract void rejectPartnerMessage(String reason)
Rejcect partner message whit specific reason. This call is available when state is set to STATE_WAIT_ACCEPTANCE.

Parameters:
reason - reason to reject partner message

stop

public void stop()
Stop current session. State is set to STATE_ERROR and error status indicates that session was stopped.


isActive

public boolean isActive()
Return true if Session is still active (not finished and not has error).

Returns:
true if Session is still active (not finished and not has error).

isFinished

public boolean isFinished()
Return true if Session is successfully finished.

Returns:
true if Session is successfully finished/

isError

public boolean isError()
Return true if Session is finished with error status.

Returns:
true if Session is finished with error status.

getHistory

public Container[] getHistory()
Returns history of this session. contains all sent and incoming messages and containers sent and incoming messages and containers.

Returns:
history of this session. contains all

serialize

public void serialize(OutputStream outstream)
               throws IOException
Serialize current state of session to external storage.

Parameters:
outstream - external storage
Throws:
IOException - if store will fail

restore

public void restore(InputStream instream)
             throws IOException
Restore state of session from external storage.

Parameters:
instream - exernal storage
Throws:
IOException - if session can not be restored

getMessageToSend

public abstract PayloadContainer getMessageToSend()
Called by external dispatcher when session prepared message for delivering to partner. Note! state of session must be STATE_READY_TO_SEND_MESSAGE.

Returns:
prepared for partne message

getStatusToSend

public abstract StatusContainer getStatusToSend()
Called by external dispatcher when session prepared status for delivering to partner. Note! state of session must be STATE_READY_TO_SEND_STATUS.

Returns:
prepared for partner status

getWaitedContainerDesc

public abstract WaitedContainerDescription getWaitedContainerDesc()
Returns description about which pip, pip instance id and partner are accepted. The state of session must be STATE_WAIT_MESSAGE or. STATE_WAIT_STATUS are accepted. The state of session must be STATE_WAIT_MESSAGE or. STATE_WAIT_STATUS.

Returns:
description about which pip, pip instance id and partner

pushMessage

public abstract void pushMessage(PayloadContainer message)
Called by external dispatcher. Dispatch message for this session. State of session must be set to STATE_WAIT_MESSAGE.

Parameters:
message - message to push

pushStatus

public abstract void pushStatus(StatusContainer status)
Called by external dispatcher. Dispatch status for this session. State of session must be set to STATE_WAIT_STATUS.

Parameters:
status - status to push

getType

public abstract int getType()
Returns type of session. See SESSION_TYPE_*

Returns:
type of session. See SESSION_TYPE_*

getInitiatedContainer

protected PayloadContainer getInitiatedContainer()
Returns container wich was first for session.

Returns:
container wich was first for session

getPartner

public String getPartner()
Returns id of partner for current session or null if not set.

Returns:
id of partner for current session or null if not set

getEIS

public String getEIS()
Returns id of eis for current session or null if not set.

Returns:
id of eis for current session or null if not set

getPipInstanceID

public String getPipInstanceID()
Returns associated with session pipinstance id.

Returns:
associated with session pipinstance id

getPIPID

public String getPIPID()
Returns associated with session pipid.

Returns:
associated with session pipid

getVersion

public String getVersion()
Returns associated with session pip version.

Returns:
associated with session pip version

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2005-2006 ADOS Co.,Ltd.. All Rights Reserved.