001    package railo.runtime.lock;
002    
003    
004    /**
005     * Lock Timeout
006     */
007    public final class LockTimeoutException extends Exception {
008    
009            /**
010             * @param type type of the log
011             * @param name name of the Lock
012             * @param timeout 
013             */
014            public LockTimeoutException(int type, String name, int timeout) {
015                //A timeout occurred while attempting to lock lockname
016                    super("a timeout occurred on a "+toString(type)+" lock with name ["+name+"] after "+getTime(timeout));
017            }
018    
019        private static String getTime(int timeout) {
020                    if(timeout/1000*1000==timeout) {
021                            int s = timeout/1000;
022                            return s+(s>1?" seconds":" second");
023                    }
024                    return timeout+(timeout>1?" milliseconds":" millisecond");
025            }
026    
027            private static String toString(int type) {
028            if(LockManager.TYPE_EXCLUSIVE==type)return "exclusive";
029            return "read-only";
030        }
031    
032    }