* Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
     void lock(String resourceName, String lockRequester, int lockTimeout /* Seconds */);
 
+    void lock(String resourceName, String lockRequester, int lockTimeout /* Seconds */, int lockWait /* Seconds */, int retryCount);
+
     void unlock(String resourceName, boolean force);
 
     void lock(Collection<String> resourceNameList, String lockRequester, int lockTimeout /* Seconds */);
 
+    void lock(Collection<String> resourceNameList, String lockRequester, int lockTimeout /* Seconds */, int lockWait /* Seconds */, int retryCount);
+
     void unlock(Collection<String> resourceNameList, boolean force);
 }
 
 
     @Override
     public void lock(String resourceName, String lockRequester, int lockTimeout /* Seconds */) {
-        lock(Collections.singleton(resourceName), lockRequester, lockTimeout);
+        lock(resourceName, lockRequester, lockTimeout, lockWait, retryCount);
+    }
+
+    @Override
+    public void lock(String resourceName, String lockRequester, int lockTimeout /* Seconds */, int lockWait /* Seconds */, int retryCount) {
+        lock(Collections.singleton(resourceName), lockRequester, lockTimeout, lockWait, retryCount);
     }
 
     @Override
 
     @Override
     public void lock(Collection<String> resourceNameList, String lockRequester, int lockTimeout /* Seconds */) {
+        lock(resourceNameList, lockRequester, lockTimeout, lockWait, retryCount);
+    }
+
+    @Override
+    public void lock(Collection<String> resourceNameList, String lockRequester, int lockTimeout /* Seconds */, int lockWait /* Seconds */, int retryCount) {
         for (int i = 0; true; i++) {
             try {
                 tryLock(resourceNameList, lockRequester, lockTimeout);
                 log.info("Resources locked: " + resourceNameList);
                 return;
             } catch (ResourceLockedException e) {
-                if (i > retryCount) {
+                if (i >= retryCount) {
                     throw e;
                 }
                 try {
 
         String lockRequester = getParam(paramMap, "lock-requester", false, generateLockRequester());
         String lockTimeoutStr = getParam(paramMap, "lock-timeout", false, "600"); // Default lock timeout: 10 min
         int lockTimeout = Integer.parseInt(lockTimeoutStr);
+        String lockWaitStr = getParam(paramMap, "lock-wait", false, "5"); // Time waiting before next retry. Default: 5 sec
+        int lockWait = Integer.parseInt(lockWaitStr);
+        String lockRetryCountStr = getParam(paramMap, "lock-retry-count", false, "10"); // Default: 10 retries
+        int lockRetryCount = Integer.parseInt(lockRetryCountStr);
 
-        lockHelper.lock(resourceName, lockRequester, lockTimeout);
+        lockHelper.lock(resourceName, lockRequester, lockTimeout, lockWait, lockRetryCount);
     }
 
     public void unlockResource(Map<String, String> paramMap, SvcLogicContext ctx) throws SvcLogicException {
     }
 
     public void lockResource(String resourceName, String lockRequester, int lockTimeout /* sec */) {
+        lockResource(resourceName, lockRequester, lockTimeout, 5, 10);
+    }
+
+    public void lockResource(String resourceName, String lockRequester, int lockTimeout /* sec */, int lockWait /* Seconds */, int retryCount) {
         if (lockRequester == null) {
             lockRequester = generateLockRequester();
         }
             lockTimeout = 600;
         }
 
-        lockHelper.lock(resourceName, lockRequester, lockTimeout);
+        lockHelper.lock(resourceName, lockRequester, lockTimeout, lockWait, retryCount);
     }
 
     public void unlockResource(String resourceName) {