01: /*
02: * CoadunationUtil: The coaduntion utility library.
03: * Copyright (C) 2006 Rift IT Contracting
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, write to the Free Software
17: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18: *
19: * LockRef.java
20: */
21:
22: // the package path
23: package com.rift.coad.util.lock;
24:
25: /**
26: * This interface provides access to the lock.
27: *
28: * @author Brett Chaldecott
29: */
30: public interface LockRef {
31: // class constants
32: public final static int READ = 1;
33: public final static int WRITE = 2;
34:
35: /**
36: * This method returns the key that the lock has been created for.
37: *
38: * @return The key the lock has been created for.
39: */
40: public Object getKey();
41:
42: /**
43: * This method returns the id of the thread locking this object.
44: *
45: * @return The id of the thread that has the lock.
46: */
47: public long getThreadId() throws LockException;
48:
49: /**
50: * This method sets the thread id for the lock.
51: *
52: * @param id The new thread id.
53: */
54: public void setThreadId(long id) throws LockException;
55:
56: /**
57: * This method returns the name of the lock for the key.
58: *
59: * @return The string containing the name of the lock.
60: */
61: public Object getLockName() throws LockException;
62:
63: /**
64: * This method sets the name associated with the key lock.
65: *
66: * @param name The name of the lock.
67: */
68: public void setLockName(Object name) throws LockException;
69:
70: /**
71: * This method returns the lock type for this object.
72: *
73: * @return The lock type for this object.
74: * @exception LockException
75: */
76: public int getLockType() throws LockException;
77:
78: /**
79: * This method releases the lock.
80: */
81: public void release() throws LockException;
82: }
|