KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > perseus > concurrency > distributed > globallock > Downgrade


1 /**
2  * Copyright (C) 2003-2004
3  * - France Telecom R&D
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
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 AE 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Release: 1.0
20  *
21  * Authors: Olivier Lobry (olivier.lobry@rd.francetelecom.com)
22  *
23  */

24
25 package org.objectweb.perseus.concurrency.distributed.globallock;
26
27 import org.objectweb.perseus.concurrency.distributed.AbstractLockingAction;
28 import org.objectweb.perseus.concurrency.distributed.globallock.api.GlobalLock;
29
30
31 public class Downgrade extends AbstractLockingAction {
32     private GlobalLock h;
33
34     /**
35      * Create a new action that can depend on a event or can be executed at
36      * a given time, and can be executed in parallel with other actions.
37      * If parallel is true, the notification of the events (begining and
38      * possibilly ending) can be observed in parallel with previous event(s).
39      * The condition of its execution is the same that the previous event(s).
40      * The time parameter is ignored.
41      * If parallel is false, the notification of the events (begining and
42      * possibilly ending) are expected to be observed after the previous
43      * events have been observed. If positive, time indicates the relative
44      * time to wait for before executing the action. If time is negative,
45      * then its absolute value is used to indicates the time to sleep after the
46      * previous event has been notified (a SleepAction is "inserted" before it).
47      * Note that downgrade never block.
48      *
49      * @param h the holder of the lock for tracing purpose
50      * @param lck lock level of the action
51      */

52     public Downgrade(GlobalLockInterceptor h, byte execMode, byte lck) {
53         super(h.getName(), GRANTED_BYUSER, execMode, lck);
54         this.h = h;
55     }
56     protected void performBlockingAction() throws Exception JavaDoc {
57         h.downgrade(lck);
58     }
59
60
61     protected String JavaDoc getBrief() {
62         return "D";
63     }
64
65     protected String JavaDoc getLockingDescription() {
66         return "downgrade";
67     }
68 }
69
Popular Tags