Class Application

java.lang.Object
com.bea.wcp.diameter.Application
Direct Known Subclasses:
ClientApplication, RelayApplication, Simulator

public abstract class Application extends Object
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 Details

    • Application

      public Application()
  • Method Details

    • init

      protected void init() throws DiameterException
      Called by the container to initialize the application. Applications override this method to perform application specific initialization.
      Throws:
      DiameterException - if the initialization failed
    • getName

      public final String getName()
      Returns the name of the application. Each application instance must have a unique name determined by the configuration.
    • getId

      public abstract ApplicationId getId()
      Returns the ApplicationId for the application.
      Returns:
      the application's ApplicationId
    • createSession

      public Session createSession(String id, Object parent)
    • createSession

      public Session createSession(String id)
    • createSession

      public Session createSession()
    • getParameter

      public final String getParameter(String name)
      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

      public final String getParameter(String name, String def)
      Returns the value of the initialization parameter with the specified name, or a default value if not found.
      Parameters:
      name - the parameter name
      def - the default value of the parameter if not found
      Returns:
      the value of the parameter, or default if not found
    • getNode

      public final Node getNode()
      Returns the Diameter Node hosting the application.
    • rcvMessage

      public void rcvMessage(Message msg) throws DiameterException, IOException
      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 message
      IOException - if an I/O error occurred
    • rcvRequest

      protected void rcvRequest(Request req) throws DiameterException, IOException
      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 message
      IOException - if an I/O error occurred
    • rcvAnswer

      protected void rcvAnswer(Answer ans) throws DiameterException, IOException
      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 answer
      IOException - if an I/O error occurred
    • createRequest

      public Request createRequest(Command cmd)
      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

      protected String 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

      public String getOriginRealm()
      Returns the configured realm name for the Diameter entity hosting this application.
      Returns:
      the origin realm for this application
    • getOriginHost

      public String getOriginHost()
      Returns the configured host name for the Diameter entity hosting this application.
      Returns:
      the origin host for this application
    • setDestinationRealm

      public void setDestinationRealm(String realm)
      Sets the default destination realm for requests.
      Parameters:
      realm - the new default destination realm
    • setDestinationHost

      public void setDestinationHost(String host)
      Sets the default destination host for requests.
      Parameters:
      host - the new default destination host
    • getDestinationRealm

      public String getDestinationRealm()
      Returns the default destination realm for requests.
      Returns:
      the default destination realm, or null if none
    • getDestinationHost

      public String getDestinationHost()
      Returns the defautl destination host for requests.
      Returns:
      the default destination host, or null if none
    • log

      public void log(String msg)
      Writes the specified message to the application log.
      Parameters:
      msg - the message to be logged
    • log

      public void log(String msg, Throwable e)
      Writes the specified message and exception to the application log.
      Parameters:
      msg - the message to be logged
      e - the exception to be logged