KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > perseus > concurrency > distributed > globallock > lib > GlobalLockMessage


1 package org.objectweb.perseus.concurrency.distributed.globallock.lib;
2
3 /**
4  * Copyright (C) 2003-2004
5  * - France Telecom R&D
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR AE PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  *
21  * Release: 1.0
22  *
23  * Authors: Olivier Lobry (olivier.lobry@rd.francetelecom.com)
24  *
25  */

26
27
28 import java.io.Serializable JavaDoc;
29
30 /**
31  * This class is used to send messages between the user and the coordinator(s) of a resource
32  */

33
34 public class GlobalLockMessage implements Serializable JavaDoc {
35
36     // From user to coordinator
37
static final byte UPGRADE_REQUEST = 0;
38     static final byte DOWNGRADE_NOTIFY = 1;
39     static final byte UPGRADE_CANCEL = 2;
40
41     // From coordinator to user
42
static final byte UPGRADE_NOTIFY = 2;
43     static final byte DOWNGRADE_REQUEST = 3;
44     // static final byte DOWNGRADE_CANCEL = 4;
45

46     byte type;
47     byte lck;
48     long timeout;
49     Object JavaDoc requester; // may not be really required
50
int serialNumber;
51     //byte auxLck;
52

53     GlobalLockMessage(byte type, byte lck, long timeout, Object JavaDoc requester,
54                       int serialNumber) {
55         this(type, lck, timeout, requester);
56         this.serialNumber = serialNumber;
57     }
58
59     GlobalLockMessage(byte type, byte lck, long timeout, Object JavaDoc requester) {
60         this.type = type;
61         this.lck = lck;
62         this.timeout = timeout;
63         this.requester = requester;
64         //this.auxLck = LockValue.UNDEFINED;
65
}
66
67     /* GlobalLockMessage(byte type, byte lck, byte auxLck, long timeout,
68                       Object requester) {
69         this.type = type;
70         this.lck = lck;
71         this.auxLck = auxLck;
72         this.timeout = timeout;
73         this.requester = requester;
74
75     }
76 */

77     private static String JavaDoc typeToString(byte type) {
78         switch (type) {
79         case UPGRADE_NOTIFY: return "UPGRADE_NOTIFY";
80         case UPGRADE_REQUEST: return "UPGRADE_REQUEST";
81         case DOWNGRADE_NOTIFY: return "DOWNGRADE_NOTIFY";
82         case DOWNGRADE_REQUEST: return "DOWNGRADE_REQUEST";
83         }
84         return "";
85     }
86
87     public String JavaDoc toString() {
88         return "Dist RWLockValue Message (" + typeToString(type) +
89                 ", lck=" + lck + ", req=" + requester + ", SN="
90                 + serialNumber + ")";
91     }
92
93 }
94
Popular Tags