KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.objectweb.perseus.concurrency.distributed.globallock;
2
3 import org.objectweb.perseus.concurrency.distributed.globallock.api.GlobalLock;
4 import org.objectweb.perseus.concurrency.distributed.globallock.api.GlobalLockException;
5 import org.objectweb.perseus.concurrency.distributed.globallock.lib.BasicGlobalLockManager;
6 import org.objectweb.perseus.concurrency.distributed.globallock.lib.GlobalLockUser;
7 import org.objectweb.perseus.distribution.api.DistResServiceManager;
8 import org.objectweb.perseus.distribution.api.DistResCoordinatorFactory;
9 import org.objectweb.perseus.distribution.util.MessageEventListenerRegistry;
10 import java.io.Serializable JavaDoc;
11
12 /**
13  * Copyright (C) 2003-2004
14  * - France Telecom R&D
15  *
16  * This library is free software; you can redistribute it and/or
17  * modify it under the terms of the GNU Lesser General Public
18  * License as published by the Free Software Foundation; either
19  * version 2 of the License, or (at your option) any later version.
20  *
21  * This library is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24  * Lesser General Public License for more details.
25  *
26  * You should have received a copy of the GNU Lesser General Public
27  * License along with this library; if not, write to the Free Software
28  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29  *
30  * Release: 1.0
31  *
32  * Authors: lobry
33  * Date: 14 juin 2004
34  * Time: 11:08:13
35  */

36 public class GlobalLockManagerInterceptor extends BasicGlobalLockManager {
37     MessageEventListenerRegistry reg;
38     
39     public GlobalLockManagerInterceptor(DistResServiceManager drsm,
40                                         DistResCoordinatorFactory drcf,
41                                         MessageEventListenerRegistry reg) {
42         super(drsm, drcf);
43         this.reg = reg;
44     }
45
46
47     protected GlobalLock createLock(Serializable JavaDoc resId) {
48         GlobalLockUser gl = (GlobalLockUser) super.createLock(resId);
49         GlobalLockInterceptor gli = new GlobalLockInterceptor(gl, reg);
50         return gli;
51     }
52
53     protected void joinUsers(Serializable JavaDoc oid) throws GlobalLockException {
54         GlobalLockInterceptor gli = (GlobalLockInterceptor) distlocks.get(oid);
55         UserInterceptor ui = new UserInterceptor(gli.glu, nodeId);
56         try {
57             drus.joinUsers(oid, ui);
58         } catch (Exception JavaDoc e) {
59             throw new GlobalLockException(e);
60         }
61     }
62
63
64 }
65
Popular Tags