Package com.bea.wcp.diameter
Class Session
java.lang.Object
com.bea.wcp.diameter.Session
- All Implemented Interfaces:
Externalizable,Serializable
- Direct Known Subclasses:
ClientSession,ClientSession,ShSession,Simulator.ServerSession,SyClientSession
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.
- Author:
- Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSession()Used by Externalizable.Session(Application app) Creates a new client Session for the specified Application.Session(Application app, String id) Creates a new server Session for the specified Application and session id.Session(Application app, String id, Object parent) Creates a new server Session for the specified Application and session id. -
Method Summary
Modifier and TypeMethodDescriptioncreateRequest(Command cmd) Creates a new Request for this session.final ApplicationReturns the Application for this Session.getAttribute(String name) Returns the value of the specified session attribute.final StringgetId()Returns the session identifier.Returns the SessionListener for this session.booleanReturns true if this session has been terminated.protected voidnotifyListener(Message msg) Delivers the specified message to the session listener.protected voidCalled when an answer message has been received for this session.voidrcvMessage(Message msg) Called when a new Request or Answer has been received for this session.protected voidrcvRequest(Request req) Called when a new request message has been received for this session.voidvoidremoveAttribute(String name) Removes the session attribute with the specified name.voidsetAdapter(Object adapter) voidsetAttribute(String name, Object value) Sets the new value of a session attribute, replacing any previous value.voidsetListener(SessionListener listener) Sets the SessionListener for this session.voidsndMessage(Message msg) Called by the container when a message is about to be sent but before it has been committed.voidTerminates the session.toString()void
-
Constructor Details
-
Session
public Session()Used by Externalizable. -
Session
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 sessionid- the session idparent- the Parent Session of this session- Throws:
IllegalStateException- if a session with the same id has already been created
-
Session
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 sessionid- the session id- Throws:
IllegalStateException- if a session with the same id has already been created
-
Session
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 Details
-
setListener
Sets the SessionListener for this session. The listener will be invoked for all messages received by the session.- Parameters:
listener- the new SessionListener
-
getListener
Returns the SessionListener for this session.- Returns:
- the SessionListener, or null if none.
- Since:
- 3.1
-
getAdapter
-
setAdapter
-
getId
Returns the session identifier. -
getApplication
Returns the Application for this Session. -
setAttribute
Sets the new value of a session attribute, replacing any previous value.- Parameters:
name- the attribute namevalue- the new attribute value
-
getAttribute
Returns the value of the specified session attribute.- Parameters:
name- the attribute name- Returns:
- the attribute value, or null if not found
-
removeAttribute
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
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
Delivers the specified message to the 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 listener.- Parameters:
msg- the message to be delivered- Throws:
DiameterExceptionIOException
-
rcvMessage
Called when a new Request or Answer has been received for 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:
IOException- if an error occured while processing the messageDiameterException
-
rcvRequest
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:
IOException- if an error occurred while processing the requestDiameterException
-
rcvAnswer
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:
IOException- if an error occured while processing the answerDiameterException
-
sndMessage
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:
IOException- if an I/O error occurred while sending the message
-
toString
-
appendXml
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-