Interface WebContext


public interface WebContext
Allows a Rest or WebSocket Service to communicate with NetSwitch.
  • Field Details

  • Method Details

    • getProperties

      Map<String,String> getProperties()
      Returns an unmodifiable map with all the properties of this WebContext.
      Returns:
      an unmodifiable map with all the properties of this WebContext.
    • getProperty

      String getProperty(String name, String defval)
      Returns the value of the property indexed by specified name. If the property is not defined, it returns the supplied default value.
      Parameters:
      name - the name of the required property.
      defval - value returned if property is not defined (can be null).
      Returns:
      the value of the property or default value defval.
      Throws:
      NullPointerException - if name is null.
    • sendMail

      void sendMail(String sessionName, String subject, String text) throws Exception
      Sends a mail message using the specified SMTP mail session.
      Parameters:
      sessionName - the name of the mail session.
      subject - the subject of the mail message.
      text - the text of the mail message.
      Throws:
      NullPointerException - if an argument is null.
      Exception - if another error occurs.
    • sendMulticast

      void sendMulticast(String name, Serializable data) throws Exception
      Sends an multicast message built using the supplied name and data. The message will be dispatched to all client and/or server applications that have enabled the reception of multicast messages with the specified name.
      Parameters:
      name - the name of the multicast message.
      data - data to include in the multicast message (can be null).
      Throws:
      NullPointerException - if name is null.
      Exception - if another error occurs.
    • sendRequest

      Message sendRequest(String destination, Serializable data, int timeout) throws Exception
      Sends a request message to a destination and then blocks waiting for the reply message for at most timeout milliseconds. The value of destination must have the following format:
      [SwitchName:]ServerName[.ServiceName]
      where optional items are shown within "[" and "]" brackets, and the characters ":" and "." stand for themselves. If the optional SwitchName is not specified, the message is sent to the connected switch. ServerName is the name of a server, a listener or a connector. The optional ServiceName is the name of a service provided by the server, or the name of a channel of a listener. The following are examples of valid destinations:
      POS_DEVICE
      NETSWITCH.LOG_ERROR
      HUB:IMSER.ADD_CONTACT
      Argument timeout specifies the amount of time to wait for the synchronous reply message. If timeout is zero (0), the call waits forever for the reply message.
      Parameters:
      destination - the request destination switch:server.service.
      data - the data to include in the request message (can be null).
      timeout - the maximum time to wait for a reply (in milliseconds).
      Returns:
      the reply message returned from the switch server.
      Throws:
      NullPointerException - if destination is null.
      IllegalArgumentException - if timeout is negative.
      IllegalStateException - if already waiting for a reply message.
      SocketTimeoutException - if timeout expired while waiting for reply.
      Exception - if another error occurs.
    • executeSQL

      <T> T executeSQL(String poolName, SQLExecutor<T> executor) throws SQLException, Exception
      Allocates a connection from the specified pool and then executes the supplied SQL executor. If the SQL executor returns normally, the connection is committed. If the SQL executor throws an exception, the connection is rollback. In any event, the connection is returned to the pool.
      Type Parameters:
      T - the type of the value returned by the executor.
      Parameters:
      poolName - the name of the connection pool.
      executor - an SQL statement executor.
      Returns:
      the value returned by the executor.
      Throws:
      NullPointerException - if an argument is null.
      SQLException - if an SQL error occurs.
      Exception - if another error occurs.
    • getSharedBoolean

      SharedBoolean getSharedBoolean(String name, boolean inival)
      Returns the SharedBoolean indexed by specified name. If the SharedBoolean does not exists, a new instance is created with the specified initial value. An exception is thrown if a shared value exists that is not an instance of SharedBoolean.
      Parameters:
      name - the name of the required SharedValue.
      inival - the value used when SharedValue is created.
      Returns:
      the SharedBoolean indexed by supplied name.
      Throws:
      NullPointerException - if name is null.
      ClassCastException - if a shared value exists with wrong type.
    • getSharedInteger

      SharedInteger getSharedInteger(String name, int inival)
      Returns the SharedInteger indexed by specified name. If the SharedInteger does not exists, a new instance is created with the specified initial value. An exception is thrown if a shared value exists that is not an instance of SharedInteger.
      Parameters:
      name - the name of the required SharedValue.
      inival - the value used when SharedValue is created.
      Returns:
      the SharedInteger indexed by supplied name.
      Throws:
      NullPointerException - if name is null.
      ClassCastException - if a shared value exists with wrong type.
    • getSharedLong

      SharedLong getSharedLong(String name, long inival)
      Returns the SharedLong indexed by specified name. If the SharedLong does not exists, a new instance is created with the specified initial value. An exception is thrown if a shared value exists that is not an instance of SharedLong.
      Parameters:
      name - the name of the required SharedValue.
      inival - the value used when SharedValue is created.
      Returns:
      the SharedLong indexed by supplied name.
      Throws:
      NullPointerException - if name is null.
      ClassCastException - if a shared value exists with wrong type.
    • getSharedString

      SharedString getSharedString(String name, String inival)
      Returns the SharedString indexed by specified name. If the SharedString does not exists, a new instance is created with the specified initial value. An exception is thrown if a shared value exists that is not an instance of SharedString.
      Parameters:
      name - the name of the required SharedValue.
      inival - the value used when SharedValue is created.
      Returns:
      the SharedString indexed by supplied name.
      Throws:
      NullPointerException - if name is null.
      ClassCastException - if a shared value exists with wrong type.