Class SharedResourcePool


  • @Component("tapirSharedResourcePool")
    public class SharedResourcePool
    extends java.lang.Object
    The SharedResourcePool provides the possibility to lock resources in order to synchronize them. Clients which need to obtain a shared resource can query a lock by calling lockResource(Object).
    Since:
    2.0.0
    Author:
    Oliver Libutzki <[email protected]>
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void lockResource​(java.lang.Object resource)
      Queries a resource.
      void unlockResource​(java.lang.Object resource)
      Unlocks a resource.
      • Methods inherited from class java.lang.Object

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

      • SharedResourcePool

        public SharedResourcePool()
    • Method Detail

      • lockResource

        public void lockResource​(java.lang.Object resource)
        Queries a resource. If the resource is not locked, the lock is acquired for the current thread and the method returns immediately. Otherwise the method waits until the resource is unlocked or a timeout occurred. If the lock cannot be acquired a RuntimeException is thrown. The given resource is compared by its Object.equals(Object) method.
        Parameters:
        resource - the resource to lock
        Throws:
        java.lang.RuntimeException - Thrown if the lock cannot be acquired within the time specified by timeOutInSeconds.
        Since:
        2.0.0
      • unlockResource

        public void unlockResource​(java.lang.Object resource)
        Unlocks a resource. The given resource's Object.equals(Object) method has to return true if it's compared to the locked resource.
        Parameters:
        resource - the resource to unlock
        Since:
        2.0.0