KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > perseus > concurrency > dbdelegate > DbDelegateConcurrencyManager


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

25
26 package org.objectweb.perseus.concurrency.dbdelegate;
27
28 import org.objectweb.perseus.concurrency.api.ConcurrencyException;
29 import org.objectweb.perseus.concurrency.api.ConcurrencyManager;
30 import org.objectweb.fractal.api.control.BindingController;
31 import org.objectweb.fractal.api.control.IllegalBindingException;
32 import org.objectweb.fractal.api.control.LifeCycleController;
33 import org.objectweb.fractal.api.control.IllegalLifeCycleException;
34 import org.objectweb.fractal.api.NoSuchInterfaceException;
35 import org.objectweb.util.monolog.api.Logger;
36 import org.objectweb.util.monolog.api.BasicLevel;
37
38 /**
39  * @author P. Dechamboux
40  */

41 public abstract class DbDelegateConcurrencyManager
42         implements ConcurrencyManager, BindingController, LifeCycleController {
43     private String JavaDoc state = LifeCycleController.STOPPED;
44
45     protected Logger logger = null;
46
47     public DbDelegateConcurrencyManager() throws ConcurrencyException {
48     }
49
50     /**
51      * @param ctx is the context using the resource
52      * @param resource is the resource
53      * @param thinLock uses to take a thin lock
54      * @return the resource state to use
55      */

56     protected abstract Object JavaDoc getState(Object JavaDoc ctx,
57                                        Object JavaDoc resource,
58                                        Object JavaDoc thinLock) throws ConcurrencyException;
59
60
61     //IMPLEMENTATION OF THE UserBindingControler INTERFACE //
62
//------------------------------------------------------//
63

64     public String JavaDoc[] listFc() {
65         return new String JavaDoc[] {};
66     }
67
68     public Object JavaDoc lookupFc(String JavaDoc s) throws NoSuchInterfaceException {
69 //FIXME: throw new NoSuchInterfaceException(s);
70
return null;
71     }
72
73     public void bindFc(String JavaDoc s, Object JavaDoc o) throws IllegalBindingException,
74             NoSuchInterfaceException {
75         try {
76         } catch (ClassCastException JavaDoc e) {
77             throw new IllegalBindingException(s + ":" + e.getMessage());
78         }
79 //FIXME: throw new NoSuchInterfaceException(s);
80
}
81
82     public void unbindFc(String JavaDoc s) throws NoSuchInterfaceException {
83 //FIXME: throw new NoSuchInterfaceException(s);
84
}
85
86     //IMPLEMENTATION OF THE LifeCycleController INTERFACE //
87
//----------------------------------------------------//
88
public String JavaDoc getFcState() {
89         return state;
90     }
91
92     public void startFc() throws IllegalLifeCycleException {
93         if (state == LifeCycleController.STARTED) return;
94         state = LifeCycleController.STARTED;
95     }
96
97     public void stopFc() throws IllegalLifeCycleException {
98         if (state == LifeCycleController.STOPPED) return;
99         state = LifeCycleController.STOPPED;
100     }
101
102     //IMPLEMENTATION OF THE ConcurrencyManager INTERFACE //
103
//---------------------------------------------------//
104

105     public void begin(Object JavaDoc ctx) {
106     }
107
108     public boolean validate(Object JavaDoc ctx) {
109         return true;
110     }
111
112     public abstract void finalize(Object JavaDoc ctx);
113
114     public void abort(Object JavaDoc ctx) {
115         finalize(ctx);
116     }
117
118     public Object JavaDoc readIntention(Object JavaDoc ctx, Object JavaDoc resourceId, Object JavaDoc hints)
119             throws ConcurrencyException {
120         return getState(ctx, resourceId, hints);
121     }
122
123     public Object JavaDoc writeIntention(Object JavaDoc ctx, Object JavaDoc resourceId, Object JavaDoc hints)
124             throws ConcurrencyException {
125         return getState(ctx, resourceId, hints);
126     }
127 }
128
Popular Tags