Skip navigation links

Oracle Communications Converged Application Server Java API Reference
5.0

E18767-01


com.bea.wcp.diameter
Class Session

java.lang.Object
  extended by com.bea.wcp.diameter.Session

All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
ClientSession, ClientSession, ShSession, Simulator.ServerSession

public class Session
extends java.lang.Object
implements java.io.Serializable

Base class for Diameter application sessions. Diameter applications extend this class in order to provide application-specific handling of requests or answer messages for the application.

See Also:
Serialized Form

Constructor Summary
Session(Application app)
          Creates a new client Session for the specified Application.
Session(Application app, java.lang.String id)
          Creates a new server Session for the specified Application and session id.

 

Method Summary
 XmlBuffer appendXml(XmlBuffer xb)
           
 Request createRequest(Command cmd)
          Creates a new Request for this session.
 Application getApplication()
          Returns the Application for this Session.
 java.lang.Object getAttribute(java.lang.String name)
          Returns the value of the specified session attribute.
 java.lang.String getId()
          Returns the session identifier.
 SessionListener getListener()
          Returns the SessionListener for this session.
 boolean isTerminated()
          Returns true if this session has been terminated.
protected  void notifyListener(Message msg)
          Deliver specified message to session listener.
protected  void rcvAnswer(Answer ans)
          Called when an answer message has been received for this session.
 void rcvMessage(Message msg)
          Called when a new Request or Answer has been received http://news.com.com/2061-10802_3-6160230.html?tag=nefd.aoffor this session.
protected  void rcvRequest(Request req)
          Called when a new request message has been received for this session.
 void removeAttribute(java.lang.String name)
          Removes the session attribute with the specified name.
 void setAttribute(java.lang.String name, java.lang.Object value)
          Sets the new value of a session attribute, replacing any previous value.
 void setListener(SessionListener listener)
          Sets the SessionListener for this session.
 void sndMessage(Message msg)
          Called by the container when a message is about to be sent but before it has been committed.
 void terminate()
          Terminates the session.
 java.lang.String toString()
           

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

 

Constructor Detail

Session

public Session(Application app,
               java.lang.String id)
Creates a new server Session for the specified Application and session id. This constructor is used by server applications when creating a Session for an existing session id.
Parameters:
app - the Application for the session
id - the session id
Throws:
java.lang.IllegalStateException - if a session with the same id has already been created

Session

public Session(Application app)
Creates a new client Session for the specified Application. The session id will be created by calling @{link Application#createSessionId()}.
Parameters:
app - the Application for the session

Method Detail

setListener

public void setListener(SessionListener listener)
Sets the SessionListener for this session. The listener will be invoked for all messages received by the session.
Parameters:
listener - the new SessionListener

getListener

public SessionListener getListener()
Returns the SessionListener for this session.
Returns:
the SessionListener, or null if none.
Since:
3.1

getId

public final java.lang.String getId()
Returns the session identifier.

getApplication

public final Application getApplication()
Returns the Application for this Session.

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Sets the new value of a session attribute, replacing any previous value.
Parameters:
name - the attribute name
value - the new attribute value

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Returns the value of the specified session attribute.
Parameters:
name - the attribute name
Returns:
the attribute value, or null if not found

removeAttribute

public void removeAttribute(java.lang.String name)
Removes the session attribute with the specified name.
Parameters:
name - the attribute name

terminate

public void terminate()
Terminates the session.

isTerminated

public boolean isTerminated()
Returns true if this session has been terminated.
Returns:
true if the session is terminated, false if not

createRequest

public Request createRequest(Command cmd)
Creates a new Request for this session. If the application has a default destination realm and/or host, then they will be used for the new request.
Parameters:
cmd - the command for the request
Returns:
the new Request

notifyListener

protected void notifyListener(Message msg)
                       throws DiameterException,
                              java.io.IOException
Deliver specified message to session listener. Does nothing if a session listener has not been set. Sessions which override rcvRequest() or rcvAnswer() must use this method to optionally forward the message to the session lisener.
Parameters:
msg - the message to be delivered
Throws:
DiameterException
java.io.IOException

rcvMessage

public void rcvMessage(Message msg)
                throws DiameterException,
                       java.io.IOException
Called when a new Request or Answer has been received http://news.com.com/2061-10802_3-6160230.html?tag=nefd.aoffor this session. The default behavior is to call rcvRequest() for a request or rcvAnswer() for an answer message. Session implementations should not override this method directly but override rcvRequest() or rcvAnswer() instead.
Parameters:
msg - the message that has been received
Throws:
java.io.IOException - if an error occured while processing the message
DiameterException

rcvRequest

protected void rcvRequest(Request req)
                   throws DiameterException,
                          java.io.IOException
Called when a new request message has been received for this session. Session implementations should override this method to provide application specific handling of requests. The default behavior is to send the error answer UNABLE_TO_COMPLY.
Parameters:
req - the request that has been received
Throws:
java.io.IOException - if an error occurred while processing the request
DiameterException

rcvAnswer

protected void rcvAnswer(Answer ans)
                  throws DiameterException,
                         java.io.IOException
Called when an answer message has been received for this session. Session implementations should override this method to provide application specific handling of answer messages. The default behavior is to ignore the answer.
Parameters:
ans - the answer message that has been received
Throws:
java.io.IOException - if an error occured while processing the answer
DiameterException

sndMessage

public void sndMessage(Message msg)
                throws java.io.IOException
Called by the container when a message is about to be sent but before it has been committed. This gives the Session a chance to update any state that may change when a message has been sent out.
Parameters:
msg - the message being sent
Throws:
java.io.IOException - if an I/O error occurred while sending the message

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

appendXml

public XmlBuffer appendXml(XmlBuffer xb)

Skip navigation links

Oracle Communications Converged Application Server Java API Reference
5.0

E18767-01


Copyright © 2005, 2010, Oracle and/or its affiliates. All rights reserved.