Class SessionLock


  • public class SessionLock
    extends Object
    • Constructor Summary

      Constructors 
      Constructor Description
      SessionLock()
      Creates a new instance of SessionLock
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void decrementForegroundRefCount()
      decrement the foregroundRefCount
      int getForegroundRefCount()
      get the foregroundRefCount
      String getLockType()
      get the lock type
      boolean hasNonHttpLockOccurred()  
      void incrementForegroundRefCount()
      increment the foregroundRefCount
      boolean isBackgroundLocked()
      return whether lock is background locked
      boolean isForegroundLocked()
      return whether lock is foreground locked
      boolean isLocked()
      return whether lock is locked (either foreground or background)
      boolean lockBackground()
      if possible, the lock will be background locked if the lock is already foreground locked the method will return false and the lock remains foreground locked (i.e.
      boolean lockForeground()
      if possible, the lock will be foreground locked if it was already foreground locked; it will remain so and the foregroundRefCount will be incremented if the lock is already background locked the method will return false and the lock remains background locked (i.e.
      boolean lockForeground​(boolean isHttp)  
      void setForegroundRefCount​(int foregroundRefCount)
      set the foregroundRefCount
      void setLockType​(String lockType)
      set the lock type - lockType must be BACKGROUND_LOCK or FOREGROUND_LOCK
      String toString()
      returns String representation of the state of the lock
      void unlock()
      unlock the lock if background locked the lock will become fully unlocked if foreground locked the lock will become fully unlocked if foregroundRefCount was 1; otherwise it will decrement the foregroundRefCount and the lock will remain foreground locked
      void unlockBackground()
      unlock the lock for the background locked case the lock will be unlocked
      void unlockForeground()
      unlock the lock for the foreground locked case the lock will be unlocked if foregroundRefCount was 1; otherwise it will decrement the foregroundRefCount and the lock will remain foreground locked
      void unlockForegroundCompletely()
      unlock the lock this is a force unlock; foregroundRefCount is ignored
    • Constructor Detail

      • SessionLock

        public SessionLock()
        Creates a new instance of SessionLock
    • Method Detail

      • getLockType

        public String getLockType()
        get the lock type
      • setLockType

        public void setLockType​(String lockType)
        set the lock type - lockType must be BACKGROUND_LOCK or FOREGROUND_LOCK
        Parameters:
        lockType - the type of the lock
      • getForegroundRefCount

        public int getForegroundRefCount()
        get the foregroundRefCount
      • setForegroundRefCount

        public void setForegroundRefCount​(int foregroundRefCount)
        set the foregroundRefCount
        Parameters:
        foregroundRefCount -
      • incrementForegroundRefCount

        public void incrementForegroundRefCount()
        increment the foregroundRefCount
      • decrementForegroundRefCount

        public void decrementForegroundRefCount()
        decrement the foregroundRefCount
      • isBackgroundLocked

        public boolean isBackgroundLocked()
        return whether lock is background locked
      • isForegroundLocked

        public boolean isForegroundLocked()
        return whether lock is foreground locked
      • isLocked

        public boolean isLocked()
        return whether lock is locked (either foreground or background)
      • hasNonHttpLockOccurred

        public boolean hasNonHttpLockOccurred()
        Returns:
        true if lock has been locked by non-http request, false otherwise
      • unlock

        public void unlock()
        unlock the lock if background locked the lock will become fully unlocked if foreground locked the lock will become fully unlocked if foregroundRefCount was 1; otherwise it will decrement the foregroundRefCount and the lock will remain foreground locked
      • unlockForeground

        public void unlockForeground()
        unlock the lock for the foreground locked case the lock will be unlocked if foregroundRefCount was 1; otherwise it will decrement the foregroundRefCount and the lock will remain foreground locked
      • unlockForegroundCompletely

        public void unlockForegroundCompletely()
        unlock the lock this is a force unlock; foregroundRefCount is ignored
      • unlockBackground

        public void unlockBackground()
        unlock the lock for the background locked case the lock will be unlocked
      • lockForeground

        public boolean lockForeground()
        if possible, the lock will be foreground locked if it was already foreground locked; it will remain so and the foregroundRefCount will be incremented if the lock is already background locked the method will return false and the lock remains background locked (i.e. lock failed) otherwise it will return true (lock succeeded)
      • lockForeground

        public boolean lockForeground​(boolean isHttp)
      • lockBackground

        public boolean lockBackground()
        if possible, the lock will be background locked if the lock is already foreground locked the method will return false and the lock remains foreground locked (i.e. lock failed) otherwise it will return true (lock succeeded)
      • toString

        public String toString()
        returns String representation of the state of the lock
        Overrides:
        toString in class Object