Class ServerBusyHandler


  • public class ServerBusyHandler
    extends java.lang.Object
    Class which controls how long a client will wait for a busy server to become free again. It also has hooks to perform any action on the client side before starting to wait and just after stopping to wait.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private long timeOut
      The time-out.
    • Constructor Summary

      Constructors 
      Constructor Description
      ServerBusyHandler()
      Creates a server busy handler which waits for the server to be free without any time-out.
      ServerBusyHandler​(long timeOut)
      Creates a server busy handler which waits for the server to be free.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long getTimeOut()  
      void postWaitForServer​(boolean serverStillBusy)
      Hook to perform any action right after waiting for the server to become free.
      void preWaitForServer​(java.lang.String hostName, java.lang.String userName)
      Hook to perform any action before beginning to wait for the server to become free.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • timeOut

        private final long timeOut
        The time-out.
    • Constructor Detail

      • ServerBusyHandler

        public ServerBusyHandler()
        Creates a server busy handler which waits for the server to be free without any time-out.
      • ServerBusyHandler

        public ServerBusyHandler​(long timeOut)
        Creates a server busy handler which waits for the server to be free. If the server has not become free within the specified time-out, an exception is thrown.
        Parameters:
        timeOut - The amount of time to wait in milliseconds. If the server is still busy after this amount of time, an exception is thrown.
    • Method Detail

      • getTimeOut

        public final long getTimeOut()
        Returns:
        The amount of time in milliseconds to wait before throwing an exception, if the server is still busy.
      • preWaitForServer

        public void preWaitForServer​(java.lang.String hostName,
                                     java.lang.String userName)
        Hook to perform any action before beginning to wait for the server to become free. The default implementation does nothing.
        Parameters:
        hostName - The host name of the client currently using the server.
        userName - The name of the user currently using the server.
      • postWaitForServer

        public void postWaitForServer​(boolean serverStillBusy)
        Hook to perform any action right after waiting for the server to become free. If the server is free, this method is called just before continuing the operation. If the server is still busy this method is called just before throwing the exception. The default implementation of this method does nothing.
        Parameters:
        serverStillBusy - true if the server is still busy, false is it is free.