Class CmsLockUtil


  • public final class CmsLockUtil
    extends java.lang.Object
    Locking utility class.

    • Method Detail

      • tryUnlock

        public static void tryUnlock​(CmsObject cms,
                                     CmsResource resource)
        Tries to unlock the given resource.

        Will ignore any failure.

        Parameters:
        cms - the cms context
        resource - the resource to unlock
      • withLockedResources

        public static java.lang.AutoCloseable withLockedResources​(CmsObject cms,
                                                                  CmsResource... resources)
                                                           throws java.lang.Exception
        Utility method for locking and unlocking a set of resources conveniently with the try-with syntax from Java 1.7.

        This method locks a set of resources and returns a Closeable instance that will unlock the locked resources when its close() method is called.

        Parameters:
        cms - the CMS context
        resources - the resources to lock
        Returns:
        the Closeable used to unlock the resources
        Throws:
        java.lang.Exception - if something goes wrong