KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > perseus > StateManagerTestImpl


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 A 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;
26
27 import org.objectweb.perseus.persistence.api.StateManager;
28 import org.objectweb.perseus.persistence.api.State;
29 import org.objectweb.perseus.cache.api.CacheEntry;
30 import org.objectweb.perseus.cache.api.CacheEvent;
31
32 public class StateManagerTestImpl implements StateManager {
33
34         public StateManagerTestImpl() {
35
36         }
37     
38     public State createState(CacheEntry ce) {
39         if (ce.getCeObject() instanceof PString)
40             return new PStringState(ce);
41         if (ce.getCeObject() instanceof PInteger)
42             return new PIntegerState(ce);
43         return null;
44     }
45
46     public State createState(State s) {
47         if (s instanceof PStringState)
48             return new PStringState(s);
49         if (s instanceof PIntegerState)
50             return new PIntegerState(s);
51         return null;
52     }
53
54     public State getReferenceState(CacheEntry ce) {
55         return ((StatefullReplacebleCacheEntry) ce).getRefState();
56     }
57
58     public void setReferenceState(CacheEntry ce, State state) {
59         ((StatefullReplacebleCacheEntry) ce).setRefState(state);
60     }
61
62     public void destroyState(State state) {
63     }
64
65     public void makeUnexported(State state) {
66         ((StatusOwner) state).setStatus((byte)
67                 (((StatusOwner) state).getStatus() | Status.STATUS_UNEXPORTED));
68     }
69
70     public boolean isUnexported(State state) {
71         return (((StatusOwner) state).getStatus() & Status.STATUS_UNEXPORTED) > 0;
72     }
73
74     public void makeExported(State state) {
75         ((StatusOwner) state).setStatus((byte)
76                 (((StatusOwner) state).getStatus() | Status.STATUS_EXPORTED));
77     }
78
79     public boolean isExported(State state) {
80         return (((StatusOwner) state).getStatus() & Status.STATUS_EXPORTED) > 0;
81     }
82
83     public void makeDirty(State state) {
84         byte status = ((StatusOwner) state).getStatus();
85         status = (byte) (status | Status.STATUS_DIRTY);
86         //status = (byte) (status | Status.STATUS_FLUSHED);
87
((StatusOwner) state).setStatus(status);
88     }
89
90     public boolean isDirty(State state) {
91         return (((StatusOwner) state).getStatus() & Status.STATUS_DIRTY) > 0;
92     }
93
94     public void makeClean(State state) {
95         ((StatusOwner) state).setStatus(Status.STATUS_CLEAN);
96     }
97
98     public void makeFlushed(State state) {
99         ((StatusOwner) state).setStatus((byte)
100                 (((StatusOwner) state).getStatus() | Status.STATUS_FLUSHED));
101     }
102
103     public boolean isFlushed(State state) {
104         return (((StatusOwner) state).getStatus() & Status.STATUS_FLUSHED) > 0;
105     }
106
107     public void makeUnbound(CacheEntry ce) {
108 //TODO
109
}
110
111     public boolean isBound(CacheEntry ce) {
112         return true;
113 //TODO
114
}
115
116     public void entryBound(CacheEvent event) {
117 //TODO
118
}
119
120     public void entryUnbound(CacheEvent event) {
121 //TODO
122
}
123 }
124
Popular Tags