KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > transaction > locking > LockException


1 /*
2  * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//transaction/src/java/org/apache/commons/transaction/locking/LockException.java,v 1.2 2005/01/09 15:12:11 ozeigermann Exp $
3 <<<<<<< .mine
4  * $Revision: 1.2 $
5  * $Date: 2005-02-26 14:16:14 +0100 (Sa, 26 Feb 2005) $
6 =======
7  * $Revision$
8  * $Date: 2005-02-26 14:16:14 +0100 (Sa, 26 Feb 2005) $
9 >>>>>>> .r168169
10  *
11  * ====================================================================
12  *
13  * Copyright 1999-2002 The Apache Software Foundation
14  *
15  * Licensed under the Apache License, Version 2.0 (the "License");
16  * you may not use this file except in compliance with the License.
17  * You may obtain a copy of the License at
18  *
19  * http://www.apache.org/licenses/LICENSE-2.0
20  *
21  * Unless required by applicable law or agreed to in writing, software
22  * distributed under the License is distributed on an "AS IS" BASIS,
23  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24  * See the License for the specific language governing permissions and
25  * limitations under the License.
26  *
27  */

28
29 package org.apache.commons.transaction.locking;
30
31 /**
32  * Exception displaying a lock problem.
33  *
34  * @version $Revision$
35  * @since 1.1
36  */

37 public class LockException extends RuntimeException JavaDoc {
38
39     /**
40      * Thread has been interrupted while waiting for lock.
41      */

42     public static final int CODE_INTERRUPTED = 1;
43
44     /**
45      * Maximum wait time for a lock has been exceeded.
46      */

47     public static final int CODE_TIMED_OUT = 2;
48
49     /**
50      * Locking request canceled because of deadlock.
51      */

52     public static final int CODE_DEADLOCK_VICTIM = 3;
53
54     protected Object JavaDoc resourceId;
55
56     protected String JavaDoc reason;
57
58     protected int code;
59
60     public LockException(String JavaDoc reason, int code, Object JavaDoc resourceId) {
61         this.reason = reason;
62         this.code = code;
63         this.resourceId = resourceId;
64     }
65
66     /**
67      * Returns the formal reason for the exception.
68      *
69      * @return one of {@link #CODE_INTERRUPTED},{@link #CODE_TIMED_OUT}or
70      * {@link #CODE_DEADLOCK_VICTIM}.
71      */

72     public int getCode() {
73         return code;
74     }
75
76     /**
77      * Returns the resource the lock was tried on.
78      *
79      * @return the resource or <code>null</code> if not applicable
80      */

81     public Object JavaDoc getResourceId() {
82         return resourceId;
83     }
84
85     /**
86      * Returns the verbose for the exception.
87      *
88      * @return the reason message
89      */

90     public String JavaDoc getReason() {
91         return reason;
92     }
93 }
Popular Tags