001 package railo.commons.lock; 002 003 import railo.runtime.exp.ApplicationException; 004 import railo.runtime.lock.LockManager; 005 006 007 /** 008 * Lock Timeout 009 */ 010 public final class LockException extends ApplicationException { 011 012 private static final long serialVersionUID = 9132132031478280069L; 013 014 /** 015 * @param type type of the log 016 * @param name name of the Lock 017 * @param timeout 018 */ 019 public LockException(int type, String name, long timeout) { 020 //A timeout occurred while attempting to lock lockname 021 super("a timeout occurred on a "+toString(type)+" lock with name ["+name+"] after "+(timeout/1000)+" seconds"); 022 } 023 024 025 public LockException(Long timeout) { 026 027 super("a timeout occurred after "+toTime(timeout)); 028 } 029 030 031 public LockException(String text) { 032 super(text); 033 } 034 035 private static String toTime(long timeout) { 036 037 if(timeout>=1000 && (((timeout/1000))*1000)==timeout) 038 return (timeout/1000)+" seconds"; 039 return timeout+" milliseconds"; 040 } 041 042 043 private static String toString(int type) { 044 if(LockManager.TYPE_EXCLUSIVE==type)return "exclusive"; 045 return "read-only"; 046 } 047 048 }