Package com.bea.wcp.diameter
Class Application
java.lang.Object
com.bea.wcp.diameter.Application
- Direct Known Subclasses:
ClientApplication,RelayApplication,Simulator
Base class for all Diameter applications. A Diameter application must
extend this class to return the application identifier as well as
provide optional handling for messages received without an associated
session. The application class is also used as the factory for creating
new Diameter session objects.
- Author:
- Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateRequest(Command cmd) Creates a new Request for this application but with no associated session.createSession(String id) createSession(String id, Object parent) protected StringCalled by Session constructor when creating new session ids.Returns the defautl destination host for requests.Returns the default destination realm for requests.abstract ApplicationIdgetId()Returns the ApplicationId for the application.final StringgetName()Returns the name of the application.final NodegetNode()Returns the Diameter Node hosting the application.Returns the configured host name for the Diameter entity hosting this application.Returns the configured realm name for the Diameter entity hosting this application.final StringgetParameter(String name) Returns the value of the initialization parameter with the specified name.final StringgetParameter(String name, String def) Returns the value of the initialization parameter with the specified name, or a default value if not found.protected voidinit()Called by the container to initialize the application.voidWrites the specified message to the application log.voidWrites the specified message and exception to the application log.protected voidCalled by the container when a new Answer has been received for this application.voidrcvMessage(Message msg) Called by the container when a new Message has been received for this application.protected voidrcvRequest(Request req) Called by the container when a new Request has been received for this application.voidsetDestinationHost(String host) Sets the default destination host for requests.voidsetDestinationRealm(String realm) Sets the default destination realm for requests.
-
Constructor Details
-
Application
public Application()
-
-
Method Details
-
init
Called by the container to initialize the application. Applications override this method to perform application specific initialization.- Throws:
DiameterException- if the initialization failed
-
getName
Returns the name of the application. Each application instance must have a unique name determined by the configuration. -
getId
Returns the ApplicationId for the application.- Returns:
- the application's ApplicationId
-
createSession
-
createSession
-
createSession
-
getParameter
Returns the value of the initialization parameter with the specified name.- Parameters:
name- the parameter name- Returns:
- the value of the parameter, or null if not found
-
getParameter
Returns the value of the initialization parameter with the specified name, or a default value if not found.- Parameters:
name- the parameter namedef- the default value of the parameter if not found- Returns:
- the value of the parameter, or default if not found
-
getNode
Returns the Diameter Node hosting the application. -
rcvMessage
Called by the container when a new Message has been received for this application. The default behavior is to call @{link #rcvRequest()} for a Request and @{link #rcvAnswer()} for an Answer message.- Parameters:
msg- the Message that has been received- Throws:
DiameterException- if an error occurred while processing the messageIOException- if an I/O error occurred
-
rcvRequest
Called by the container when a new Request has been received for this application. The default behavior is to respond with the Answer UNKNOWN_SESSION_ID for requests with a Session-Id AVP or otherwise the Answer UNABLE_TO_COMPLY. Requests are first delivered to a matching Session object if found, so overriding this method is only necessary if the application does not use sessions or is a server application which will be creating new Session objects for received requests.- Parameters:
req- the Request that was received- Throws:
DiameterException- if an error occurred while processing the messageIOException- if an I/O error occurred
-
rcvAnswer
Called by the container when a new Answer has been received for this application. The default behavior is to ignore the answer. Overriding this method is only necessary if the application is sending requests with no associated session, as otherwise the answer will be delivered to the associated Session object directly.- Parameters:
ans- the Answer that was received- Throws:
DiameterException- if an error occurred while processing the answerIOException- if an I/O error occurred
-
createRequest
Creates a new Request for this application but with no associated session. Use #Session.createRequest() instead on an existing session if the request should have an associated session.- Parameters:
cmd- the Command for the request- Returns:
- the new Request
-
createSessionId
Called by Session constructor when creating new session ids. Applications can optionally override this class for encoding additional application specified information in session ids.- Returns:
- the new id for the session
-
getOriginRealm
Returns the configured realm name for the Diameter entity hosting this application.- Returns:
- the origin realm for this application
-
getOriginHost
Returns the configured host name for the Diameter entity hosting this application.- Returns:
- the origin host for this application
-
setDestinationRealm
Sets the default destination realm for requests.- Parameters:
realm- the new default destination realm
-
setDestinationHost
Sets the default destination host for requests.- Parameters:
host- the new default destination host
-
getDestinationRealm
Returns the default destination realm for requests.- Returns:
- the default destination realm, or null if none
-
getDestinationHost
Returns the defautl destination host for requests.- Returns:
- the default destination host, or null if none
-
log
Writes the specified message to the application log.- Parameters:
msg- the message to be logged
-
log
Writes the specified message and exception to the application log.- Parameters:
msg- the message to be loggede- the exception to be logged
-