KickJava   Java API By Example, From Geeks To Geeks.

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


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

27
28
29 import org.objectweb.perseus.distribution.api.DistResCoordinator;
30 import org.objectweb.perseus.distribution.api.DistResCoordinatorService;
31 import org.objectweb.perseus.distribution.api.DistResCoordinatorFactory;
32 import org.objectweb.perseus.concurrency.distributed.globallock.lib.GlobalLockCoordinator;
33 import org.objectweb.perseus.concurrency.lib.LockValue;
34 import org.objectweb.perseus.concurrency.lib.RWLockValue;
35
36 import java.io.Serializable JavaDoc;
37
38 /**
39  * This class creates one coordinator per each global lock
40  */

41
42 public class GlobalLockCoordinatorFactory implements DistResCoordinatorFactory {
43     LockValue lockValue;
44     public GlobalLockCoordinatorFactory() {
45         this(new RWLockValue());
46     }
47     public GlobalLockCoordinatorFactory(LockValue lockValue) {
48         this.lockValue = lockValue;
49     }
50     public DistResCoordinator newCoordinator(DistResCoordinatorService drcs,
51                                              Serializable JavaDoc nodeId, Object JavaDoc copy,
52                                              Object JavaDoc resId) {
53         GlobalLockCoordinator glc;
54
55         if (copy == null) {
56             glc = new GlobalLockCoordinator(resId, drcs, lockValue);
57         } else {
58             glc = (GlobalLockCoordinator) copy;
59             glc.initCopy(resId, drcs, lockValue);
60         }
61
62         return glc;
63     }
64 }
65
Popular Tags