Interface ServerContext


public interface ServerContext
Allows a ServerChannel to communicate with its container.
  • Method Details

    • getProcessID

      int getProcessID()
      Returns the unique process identification of the server channel.
      Returns:
      the unique process identification of the server channel.
    • getExecutionStats

      ExecutionStats getExecutionStats(String serviceName)
      Returns the execution statistics of the specified service.
      Parameters:
      serviceName - the name of the service.
      Returns:
      the execution statistics of the specified service.
      Throws:
      NullPointerException - if serviceName is null.
    • removeExecutionStats

      void removeExecutionStats(String serviceName)
      Removes the execution statistics of the specified service.
      Parameters:
      serviceName - the name of the service.
      Throws:
      NullPointerException - if serviceName is null.
    • getProperties

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

      String getProperty(String name)
      Returns the value of the property indexed by specified name. If the property is not defined, it returns null.
      Parameters:
      name - the name of the required property.
      Returns:
      the value of the property or null if not defined.
      Throws:
      NullPointerException - if name is null.
    • runAsyncTask

      void runAsyncTask(Runnable task)
      Executes the given task asynchronously in a separate thread.
      Parameters:
      task - the task to be executed in a separate thread.
      Throws:
      NullPointerException - if task is null.
      IllegalStateException - if the thread pool is not available.
      RejectedExecutionException - if the task cannot be executed.
    • allocateWaiter

      Waiter allocateWaiter()
      Returns next available Waiter creating one if necessary.
      Returns:
      the next available Waiter creating one if necessary.
    • releaseWaiter

      void releaseWaiter(Waiter waiter)
      Release the supplied Waiter and add it back to the pool.
      Parameters:
      waiter - the Waiter to be returned back to the pool.
      Throws:
      NullPointerException - if waiter is null.
    • executeSQL

      <T> T executeSQL(String poolName, String serverName, String execName, 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.
      serverName - the name of the server of the executor.
      execName - the name of the executor (can be null).
      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.
    • executeJsch

      <T> T executeJsch(String poolName, String serverName, String execName, JschExecutor<T> executor) throws Exception
      Allocates a connected Jsch (Java Secure Channel) session from the specified pool and then executes the supplied executor. If the Jsch executor throws an exception, the Jsch session is closed and not returned to the pool.
      Type Parameters:
      T - the type of the value returned by the executor.
      Parameters:
      poolName - the name of the Jsch (Java Secure Channel) pool.
      serverName - the name of the server of the executor.
      execName - the name of the executor (can be null).
      executor - the Jsch executor to be executed.
      Returns:
      the value returned by the executor.
      Throws:
      NullPointerException - if an argument is null.
      Exception - if another error occurs.
    • executeSocket

      <T> T executeSocket(String poolName, String serverName, String execName, SocketExecutor<T> executor) throws IOException, Exception
      Allocates a socket from the specified pool and then executes the supplied socket executor. If the socket executor throws an IOException, the socket is closed and not returned to the pool. If the socket executor terminates successfully, or if it throws any other exception, the socket is returned to the pool.
      Type Parameters:
      T - the type of the value returned by the executor.
      Parameters:
      poolName - the name of the socket pool.
      serverName - the name of the server of the executor.
      execName - the name of the executor (can be null).
      executor - the socket executor to be executed.
      Returns:
      the value returned by the executor.
      Throws:
      NullPointerException - if an argument is null.
      IOException - if an I/O error occurs.
      Exception - if another error occurs.
    • executeTask

      <T> T executeTask(String serverName, String taskName, Callable<T> task) throws Exception
      Executes supplied task mantaining statistics indexed by tag.
      Type Parameters:
      T - the type of the value returned by the task.
      Parameters:
      serverName - the name of the server of the task.
      taskName - the name of the task (can be null).
      task - the task callable to be executed.
      Returns:
      the value returned by the task.
      Throws:
      NullPointerException - if an argument is null.
      Exception - if an error occurs executing task.
    • addPendingReply

      void addPendingReply(PendingReply pendingReply)
      Adds the supplied pending reply to a shared table that is accessible to all threads controlled by the server context of this channel.
      Parameters:
      pendingReply - the pending reply to be added to the table.
      Throws:
      NullPointerException - if pendingReply is null.
      IllegalArgumentException - if pending reply key is already defined.
    • removePendingReply

      PendingReply removePendingReply(String replyKey)
      Removes and returns the pending reply indexed by given key. The returned pending reply is removed from a shared table that is accessible to all threads controlled by this context.
      Parameters:
      replyKey - the globally unique identifier of the required reply.
      Returns:
      a pending reply or null if none registered.
      Throws:
      NullPointerException - if replyKey is null.
    • addDelayedEvent

      void addDelayedEvent(DeplayedEvent event)
      Adds a delayed event to this queue of delayed events.
      Parameters:
      event - the delayed event to be added to the event queue.
      Throws:
      NullPointerException - if entry is null.
    • removeDelayedEvent

      boolean removeDelayedEvent(DeplayedEvent event)
      Removes a delayed event from this queue of delayed events.
      Parameters:
      event - the delayed event to be removed to the event queue.
      Returns:
      true if the event was removed from the queue.
      Throws:
      NullPointerException - if event is null.
    • sendMail

      void sendMail(String serverName, String sessionName, String subject, String text) throws Exception
      Sends a mail message using the specified SMTP mail session.
      Parameters:
      serverName - the name of the server sending mail.
      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.
    • decodePassword

      String decodePassword(String encoded, String username, String context) throws Exception
      Decodes an encoded password using supplied arguments.
      Parameters:
      encoded - the password to be decoded.
      username - the username of the password.
      context - the name of context using password.
      Returns:
      the password decoded using supplied arguments.
      Throws:
      NullPointerException - if an argument is null.
      Exception - if another error occurs.