Revision 93590159
Added by Cherian Mathew over 8 years ago
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/session/CdmEntitySessionManager.java | ||
---|---|---|
38 | 38 |
|
39 | 39 |
private final List<ICdmEntitySessionManagerObserver> sessionObservers = new ArrayList<ICdmEntitySessionManagerObserver>(); |
40 | 40 |
|
41 |
private ICdmEntitySession activeSession; |
|
41 |
//private ICdmEntitySession activeSession; |
|
42 |
|
|
43 |
private final InheritableThreadLocal<ICdmEntitySession> tlActiveSession = new InheritableThreadLocal<ICdmEntitySession>(); |
|
42 | 44 |
|
43 | 45 |
private NullSession nullSession; |
44 | 46 |
|
... | ... | |
76 | 78 |
|
77 | 79 |
@Override |
78 | 80 |
public ICdmEntitySession getActiveSession() { |
79 |
return activeSession;
|
|
81 |
return tlActiveSession.get();
|
|
80 | 82 |
} |
81 | 83 |
|
84 |
|
|
82 | 85 |
private void setActiveSession(ICdmEntitySession activeSession) { |
83 |
this.activeSession = activeSession;
|
|
86 |
this. tlActiveSession.set(activeSession);
|
|
84 | 87 |
notifyObservers(); |
85 | 88 |
} |
86 | 89 |
|
... | ... | |
123 | 126 |
*/ |
124 | 127 |
@Override |
125 | 128 |
public <T extends Object> T load(T obj, boolean update) { |
126 |
if(activeSession == null) {
|
|
129 |
if(tlActiveSession.get() == null) {
|
|
127 | 130 |
return obj; |
128 | 131 |
} else { |
129 |
return activeSession.load(obj, update);
|
|
132 |
return tlActiveSession.get().load(obj, update);
|
|
130 | 133 |
} |
131 | 134 |
} |
132 | 135 |
|
133 | 136 |
|
134 | 137 |
@Override |
135 | 138 |
public <T extends CdmBase> void update() { |
136 |
if(activeSession != null) {
|
|
137 |
activeSession.update();
|
|
139 |
if(tlActiveSession.get() != null) {
|
|
140 |
tlActiveSession.get().update();
|
|
138 | 141 |
} |
139 | 142 |
} |
140 | 143 |
|
... | ... | |
143 | 146 |
*/ |
144 | 147 |
@Override |
145 | 148 |
public <T extends CdmBase> T load(T cdmBase, boolean update) { |
146 |
if(activeSession == null) {
|
|
149 |
if(tlActiveSession.get() == null) {
|
|
147 | 150 |
return cdmBase; |
148 | 151 |
} |
149 |
return activeSession.load(cdmBase, update);
|
|
152 |
return tlActiveSession.get().load(cdmBase, update);
|
|
150 | 153 |
} |
151 | 154 |
|
152 | 155 |
|
... | ... | |
155 | 158 |
*/ |
156 | 159 |
@Override |
157 | 160 |
public UpdateResult load(UpdateResult updateResult, boolean update) { |
158 |
if(activeSession == null) {
|
|
161 |
if(tlActiveSession.get() == null) {
|
|
159 | 162 |
return updateResult; |
160 | 163 |
} |
161 |
return activeSession.load(updateResult, update);
|
|
164 |
return tlActiveSession.get().load(updateResult, update);
|
|
162 | 165 |
} |
163 | 166 |
|
164 | 167 |
|
... | ... | |
167 | 170 |
*/ |
168 | 171 |
@Override |
169 | 172 |
public MergeResult load(MergeResult mergeResult, boolean update) { |
170 |
if(activeSession == null) {
|
|
173 |
if(tlActiveSession.get() == null) {
|
|
171 | 174 |
return mergeResult; |
172 | 175 |
} |
173 |
return activeSession.load(mergeResult, update);
|
|
176 |
return tlActiveSession.get().load(mergeResult, update);
|
|
174 | 177 |
} |
175 | 178 |
|
176 | 179 |
|
... | ... | |
179 | 182 |
*/ |
180 | 183 |
@Override |
181 | 184 |
public <T extends CdmBase> Collection<T> load(Collection<T> cdmBaseList, boolean update) { |
182 |
if(activeSession == null) {
|
|
185 |
if(tlActiveSession.get() == null) {
|
|
183 | 186 |
return cdmBaseList; |
184 | 187 |
} |
185 |
return activeSession.load(cdmBaseList, update);
|
|
188 |
return tlActiveSession.get().load(cdmBaseList, update);
|
|
186 | 189 |
} |
187 | 190 |
|
188 | 191 |
|
... | ... | |
195 | 198 |
logger.info("No Session connected to owner, nothing to do"); |
196 | 199 |
return; |
197 | 200 |
} |
198 |
if(session == activeSession) {
|
|
201 |
if(session == tlActiveSession.get()) {
|
|
199 | 202 |
setActiveSession(null); |
200 | 203 |
} |
201 | 204 |
ownerSessionMap.remove(owner); |
Also available in: Unified diff
#5297 Add remoting progress monitoring
#5297 Change active seesion variable to a inheritable thread local variable and add relevant tests
Add monitered operation
#5297 Add post monitor operation callback, Add report text dialog
#5297 Add progress monitor client manager
#5297 Add file saving to report dialog
#5297 Rename polling method