|
Lines 95-1606
Link Here
|
| 95 |
/** |
95 |
/** |
| 96 |
* @author Eike Stepper |
96 |
* @author Eike Stepper |
| 97 |
*/ |
97 |
*/ |
| 98 |
public abstract class CDOSessionImpl extends Container<CDOView> implements InternalCDOSession |
98 |
public abstract class CDOSessionImpl extends Container<CDOView> implements |
| 99 |
{ |
99 |
InternalCDOSession { |
| 100 |
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_SESSION, CDOSessionImpl.class); |
100 |
private static final ContextTracer TRACER = new ContextTracer( |
| 101 |
|
101 |
OM.DEBUG_SESSION, CDOSessionImpl.class); |
| 102 |
private static final long NO_TIMEOUT = -1; |
102 |
|
| 103 |
|
103 |
private static final long NO_TIMEOUT = -1; |
| 104 |
private InternalCDOSessionConfiguration configuration; |
104 |
|
| 105 |
|
105 |
private InternalCDOSessionConfiguration configuration; |
| 106 |
private ExceptionHandler exceptionHandler; |
106 |
|
| 107 |
|
107 |
private ExceptionHandler exceptionHandler; |
| 108 |
private CDOSessionProtocol sessionProtocol; |
108 |
|
| 109 |
|
109 |
private CDOSessionProtocol sessionProtocol; |
| 110 |
@ExcludeFromDump |
110 |
|
| 111 |
private IListener sessionProtocolListener = new LifecycleEventAdapter() |
111 |
@ExcludeFromDump |
| 112 |
{ |
112 |
private IListener sessionProtocolListener = new LifecycleEventAdapter() { |
| 113 |
@Override |
113 |
@Override |
| 114 |
protected void onDeactivated(ILifecycle lifecycle) |
114 |
protected void onDeactivated(ILifecycle lifecycle) { |
| 115 |
{ |
115 |
CDOSessionImpl.this.deactivate(); |
| 116 |
CDOSessionImpl.this.deactivate(); |
116 |
} |
| 117 |
} |
117 |
}; |
| 118 |
}; |
118 |
|
| 119 |
|
119 |
private int sessionID; |
| 120 |
private int sessionID; |
120 |
|
| 121 |
|
121 |
private String userID; |
| 122 |
private String userID; |
122 |
|
| 123 |
|
123 |
private long lastUpdateTime; |
| 124 |
private long lastUpdateTime; |
124 |
|
| 125 |
|
125 |
@ExcludeFromDump |
| 126 |
@ExcludeFromDump |
126 |
private Object lastUpdateTimeLock = new Object(); |
| 127 |
private Object lastUpdateTimeLock = new Object(); |
127 |
|
| 128 |
|
128 |
private CDOSession.Options options = createOptions(); |
| 129 |
private CDOSession.Options options = createOptions(); |
129 |
|
| 130 |
|
130 |
private CDORepositoryInfo repositoryInfo; |
| 131 |
private CDORepositoryInfo repositoryInfo; |
131 |
|
| 132 |
|
132 |
private CDOFetchRuleManager ruleManager = CDOFetchRuleManager.NOOP; |
| 133 |
private CDOFetchRuleManager ruleManager = CDOFetchRuleManager.NOOP; |
133 |
|
| 134 |
|
134 |
private IRWLockManager<CDOSessionImpl, Object> lockmanager = new RWLockManager<CDOSessionImpl, Object>(); |
| 135 |
private IRWLockManager<CDOSessionImpl, Object> lockmanager = new RWLockManager<CDOSessionImpl, Object>(); |
135 |
|
| 136 |
|
136 |
public IRWLockManager<CDOSessionImpl, Object> getLockmanager() { |
| 137 |
@ExcludeFromDump |
137 |
return lockmanager; |
| 138 |
private Set<CDOSessionImpl> singletonCollection = Collections.singleton(this); |
138 |
} |
| 139 |
|
139 |
|
| 140 |
private CDOAuthenticator authenticator; |
140 |
@ExcludeFromDump |
| 141 |
|
141 |
private Set<CDOSessionImpl> singletonCollection = Collections |
| 142 |
private InternalCDORemoteSessionManager remoteSessionManager; |
142 |
.singleton(this); |
| 143 |
|
143 |
|
| 144 |
private Set<InternalCDOView> views = new HashSet<InternalCDOView>(); |
144 |
private CDOAuthenticator authenticator; |
| 145 |
|
145 |
|
| 146 |
/** |
146 |
private InternalCDORemoteSessionManager remoteSessionManager; |
| 147 |
* Fixes a threading problem between a committing thread and the Net4j thread that delivers incoming commit |
147 |
|
| 148 |
* notifications. TODO This is a workaround, see Bug 294700 |
148 |
private Set<InternalCDOView> views = new HashSet<InternalCDOView>(); |
| 149 |
*/ |
149 |
|
| 150 |
private Object commitLock = new Object(); |
150 |
/** |
| 151 |
|
151 |
* Fixes a threading problem between a committing thread and the Net4j |
| 152 |
@ExcludeFromDump |
152 |
* thread that delivers incoming commit notifications. TODO This is a |
| 153 |
private QueueRunner invalidationRunner; |
153 |
* workaround, see Bug 294700 |
| 154 |
|
154 |
*/ |
| 155 |
@ExcludeFromDump |
155 |
private Object commitLock = new Object(); |
| 156 |
private Object invalidationRunnerLock = new Object(); |
156 |
|
| 157 |
|
157 |
@ExcludeFromDump |
| 158 |
@ExcludeFromDump |
158 |
private QueueRunner invalidationRunner; |
| 159 |
private static ThreadLocal<Boolean> invalidationRunnerActive = new InheritableThreadLocal<Boolean>(); |
159 |
|
| 160 |
|
160 |
@ExcludeFromDump |
| 161 |
@ExcludeFromDump |
161 |
private Object invalidationRunnerLock = new Object(); |
| 162 |
private int lastViewID; |
162 |
|
| 163 |
|
163 |
@ExcludeFromDump |
| 164 |
public CDOSessionImpl(InternalCDOSessionConfiguration configuration) |
164 |
private static ThreadLocal<Boolean> invalidationRunnerActive = new InheritableThreadLocal<Boolean>(); |
| 165 |
{ |
165 |
|
| 166 |
this.configuration = configuration; |
166 |
@ExcludeFromDump |
| 167 |
} |
167 |
private int lastViewID; |
| 168 |
|
168 |
|
| 169 |
public InternalCDOSessionConfiguration getConfiguration() |
169 |
public CDOSessionImpl(InternalCDOSessionConfiguration configuration) { |
| 170 |
{ |
170 |
this.configuration = configuration; |
| 171 |
return configuration; |
171 |
} |
| 172 |
} |
172 |
|
| 173 |
|
173 |
public InternalCDOSessionConfiguration getConfiguration() { |
| 174 |
public CDORepositoryInfo getRepositoryInfo() |
174 |
return configuration; |
| 175 |
{ |
175 |
} |
| 176 |
return repositoryInfo; |
176 |
|
| 177 |
} |
177 |
public CDORepositoryInfo getRepositoryInfo() { |
| 178 |
|
178 |
return repositoryInfo; |
| 179 |
public void setRepositoryInfo(CDORepositoryInfo repositoryInfo) |
179 |
} |
| 180 |
{ |
180 |
|
| 181 |
this.repositoryInfo = repositoryInfo; |
181 |
public void setRepositoryInfo(CDORepositoryInfo repositoryInfo) { |
| 182 |
} |
182 |
this.repositoryInfo = repositoryInfo; |
| 183 |
|
183 |
} |
| 184 |
public int getSessionID() |
184 |
|
| 185 |
{ |
185 |
public int getSessionID() { |
| 186 |
return sessionID; |
186 |
return sessionID; |
| 187 |
} |
187 |
} |
| 188 |
|
188 |
|
| 189 |
public void setSessionID(int sessionID) |
189 |
public void setSessionID(int sessionID) { |
| 190 |
{ |
190 |
this.sessionID = sessionID; |
| 191 |
this.sessionID = sessionID; |
191 |
} |
| 192 |
} |
192 |
|
| 193 |
|
193 |
public String getUserID() { |
| 194 |
public String getUserID() |
194 |
return userID; |
| 195 |
{ |
195 |
} |
| 196 |
return userID; |
196 |
|
| 197 |
} |
197 |
public void setUserID(String userID) { |
| 198 |
|
198 |
this.userID = userID; |
| 199 |
public void setUserID(String userID) |
199 |
} |
| 200 |
{ |
200 |
|
| 201 |
this.userID = userID; |
201 |
public ExceptionHandler getExceptionHandler() { |
| 202 |
} |
202 |
return exceptionHandler; |
| 203 |
|
203 |
} |
| 204 |
public ExceptionHandler getExceptionHandler() |
204 |
|
| 205 |
{ |
205 |
public void setExceptionHandler(ExceptionHandler exceptionHandler) { |
| 206 |
return exceptionHandler; |
206 |
checkInactive(); |
| 207 |
} |
207 |
this.exceptionHandler = exceptionHandler; |
| 208 |
|
208 |
} |
| 209 |
public void setExceptionHandler(ExceptionHandler exceptionHandler) |
209 |
|
| 210 |
{ |
210 |
/** |
| 211 |
checkInactive(); |
211 |
* @since 2.0 |
| 212 |
this.exceptionHandler = exceptionHandler; |
212 |
*/ |
| 213 |
} |
213 |
public CDOSession.Options options() { |
| 214 |
|
214 |
return options; |
| 215 |
/** |
215 |
} |
| 216 |
* @since 2.0 |
216 |
|
| 217 |
*/ |
217 |
/** |
| 218 |
public CDOSession.Options options() |
218 |
* @since 2.0 |
| 219 |
{ |
219 |
*/ |
| 220 |
return options; |
220 |
protected CDOSession.Options createOptions() { |
| 221 |
} |
221 |
return new OptionsImpl(); |
| 222 |
|
222 |
} |
| 223 |
/** |
223 |
|
| 224 |
* @since 2.0 |
224 |
public CDOSessionProtocol getSessionProtocol() { |
| 225 |
*/ |
225 |
return sessionProtocol; |
| 226 |
protected CDOSession.Options createOptions() |
226 |
} |
| 227 |
{ |
227 |
|
| 228 |
return new OptionsImpl(); |
228 |
public void setSessionProtocol(CDOSessionProtocol sessionProtocol) { |
| 229 |
} |
229 |
this.sessionProtocol = sessionProtocol; |
| 230 |
|
230 |
} |
| 231 |
public CDOSessionProtocol getSessionProtocol() |
231 |
|
| 232 |
{ |
232 |
public void close() { |
| 233 |
return sessionProtocol; |
233 |
LifecycleUtil.deactivate(this, OMLogger.Level.DEBUG); |
| 234 |
} |
234 |
} |
| 235 |
|
235 |
|
| 236 |
public void setSessionProtocol(CDOSessionProtocol sessionProtocol) |
236 |
/** |
| 237 |
{ |
237 |
* @since 2.0 |
| 238 |
this.sessionProtocol = sessionProtocol; |
238 |
*/ |
| 239 |
} |
239 |
public boolean isClosed() { |
| 240 |
|
240 |
return !isActive(); |
| 241 |
public void close() |
241 |
} |
| 242 |
{ |
242 |
|
| 243 |
LifecycleUtil.deactivate(this, OMLogger.Level.DEBUG); |
243 |
public Object processPackage(Object value) { |
| 244 |
} |
244 |
CDOFactoryImpl.prepareDynamicEPackage(value); |
| 245 |
|
245 |
return value; |
| 246 |
/** |
246 |
} |
| 247 |
* @since 2.0 |
247 |
|
| 248 |
*/ |
248 |
public EPackage[] loadPackages(CDOPackageUnit packageUnit) { |
| 249 |
public boolean isClosed() |
249 |
if (packageUnit.getOriginalType().isGenerated()) { |
| 250 |
{ |
250 |
if (!options().isGeneratedPackageEmulationEnabled()) { |
| 251 |
return !isActive(); |
251 |
throw new CDOException(MessageFormat.format(Messages |
| 252 |
} |
252 |
.getString("CDOSessionImpl.0"), packageUnit)); |
| 253 |
|
253 |
} |
| 254 |
public Object processPackage(Object value) |
254 |
} |
| 255 |
{ |
255 |
|
| 256 |
CDOFactoryImpl.prepareDynamicEPackage(value); |
256 |
return getSessionProtocol().loadPackages(packageUnit); |
| 257 |
return value; |
257 |
} |
| 258 |
} |
258 |
|
| 259 |
|
259 |
public void acquireAtomicRequestLock(Object key) { |
| 260 |
public EPackage[] loadPackages(CDOPackageUnit packageUnit) |
260 |
try { |
| 261 |
{ |
261 |
lockmanager.lock(LockType.WRITE, key, this, RWLockManager.WAIT); |
| 262 |
if (packageUnit.getOriginalType().isGenerated()) |
262 |
} catch (InterruptedException ex) { |
| 263 |
{ |
263 |
throw WrappedException.wrap(ex); |
| 264 |
if (!options().isGeneratedPackageEmulationEnabled()) |
264 |
} |
| 265 |
{ |
265 |
} |
| 266 |
throw new CDOException(MessageFormat.format(Messages.getString("CDOSessionImpl.0"), packageUnit)); |
266 |
|
| 267 |
} |
267 |
public void releaseAtomicRequestLock(Object key) { |
| 268 |
} |
268 |
lockmanager.unlock(LockType.WRITE, key, singletonCollection); |
| 269 |
|
269 |
} |
| 270 |
return getSessionProtocol().loadPackages(packageUnit); |
270 |
|
| 271 |
} |
271 |
/** |
| 272 |
|
272 |
* @since 3.0 |
| 273 |
public void acquireAtomicRequestLock(Object key) |
273 |
*/ |
| 274 |
{ |
274 |
public CDOFetchRuleManager getFetchRuleManager() { |
| 275 |
try |
275 |
return ruleManager; |
| 276 |
{ |
276 |
} |
| 277 |
lockmanager.lock(LockType.WRITE, key, this, RWLockManager.WAIT); |
277 |
|
| 278 |
} |
278 |
/** |
| 279 |
catch (InterruptedException ex) |
279 |
* @since 3.0 |
| 280 |
{ |
280 |
*/ |
| 281 |
throw WrappedException.wrap(ex); |
281 |
public void setFetchRuleManager(CDOFetchRuleManager fetchRuleManager) { |
| 282 |
} |
282 |
ruleManager = fetchRuleManager; |
| 283 |
} |
283 |
} |
| 284 |
|
284 |
|
| 285 |
public void releaseAtomicRequestLock(Object key) |
285 |
public CDOAuthenticator getAuthenticator() { |
| 286 |
{ |
286 |
return authenticator; |
| 287 |
lockmanager.unlock(LockType.WRITE, key, singletonCollection); |
287 |
} |
| 288 |
} |
288 |
|
| 289 |
|
289 |
public void setAuthenticator(CDOAuthenticator authenticator) { |
| 290 |
/** |
290 |
this.authenticator = authenticator; |
| 291 |
* @since 3.0 |
291 |
} |
| 292 |
*/ |
292 |
|
| 293 |
public CDOFetchRuleManager getFetchRuleManager() |
293 |
public InternalCDORemoteSessionManager getRemoteSessionManager() { |
| 294 |
{ |
294 |
return remoteSessionManager; |
| 295 |
return ruleManager; |
295 |
} |
| 296 |
} |
296 |
|
| 297 |
|
297 |
public void setRemoteSessionManager( |
| 298 |
/** |
298 |
InternalCDORemoteSessionManager remoteSessionManager) { |
| 299 |
* @since 3.0 |
299 |
this.remoteSessionManager = remoteSessionManager; |
| 300 |
*/ |
300 |
} |
| 301 |
public void setFetchRuleManager(CDOFetchRuleManager fetchRuleManager) |
301 |
|
| 302 |
{ |
302 |
/** |
| 303 |
ruleManager = fetchRuleManager; |
303 |
* @since 2.0 |
| 304 |
} |
304 |
*/ |
| 305 |
|
305 |
public InternalCDOTransaction openTransaction(ResourceSet resourceSet) { |
| 306 |
public CDOAuthenticator getAuthenticator() |
306 |
checkActive(); |
| 307 |
{ |
307 |
InternalCDOTransaction transaction = createTransaction(); |
| 308 |
return authenticator; |
308 |
initView(transaction, resourceSet); |
| 309 |
} |
309 |
return transaction; |
| 310 |
|
310 |
} |
| 311 |
public void setAuthenticator(CDOAuthenticator authenticator) |
311 |
|
| 312 |
{ |
312 |
/** |
| 313 |
this.authenticator = authenticator; |
313 |
* @since 2.0 |
| 314 |
} |
314 |
*/ |
| 315 |
|
315 |
public InternalCDOTransaction openTransaction() { |
| 316 |
public InternalCDORemoteSessionManager getRemoteSessionManager() |
316 |
return openTransaction(createResourceSet()); |
| 317 |
{ |
317 |
} |
| 318 |
return remoteSessionManager; |
318 |
|
| 319 |
} |
319 |
/** |
| 320 |
|
320 |
* @since 2.0 |
| 321 |
public void setRemoteSessionManager(InternalCDORemoteSessionManager remoteSessionManager) |
321 |
*/ |
| 322 |
{ |
322 |
protected InternalCDOTransaction createTransaction() { |
| 323 |
this.remoteSessionManager = remoteSessionManager; |
323 |
return new CDOTransactionImpl(); |
| 324 |
} |
324 |
} |
| 325 |
|
325 |
|
| 326 |
/** |
326 |
/** |
| 327 |
* @since 2.0 |
327 |
* @since 2.0 |
| 328 |
*/ |
328 |
*/ |
| 329 |
public InternalCDOTransaction openTransaction(ResourceSet resourceSet) |
329 |
public InternalCDOView openView(ResourceSet resourceSet) { |
| 330 |
{ |
330 |
checkActive(); |
| 331 |
checkActive(); |
331 |
InternalCDOView view = createView(); |
| 332 |
InternalCDOTransaction transaction = createTransaction(); |
332 |
initView(view, resourceSet); |
| 333 |
initView(transaction, resourceSet); |
333 |
return view; |
| 334 |
return transaction; |
334 |
} |
| 335 |
} |
335 |
|
| 336 |
|
336 |
/** |
| 337 |
/** |
337 |
* @since 2.0 |
| 338 |
* @since 2.0 |
338 |
*/ |
| 339 |
*/ |
339 |
public InternalCDOView openView() { |
| 340 |
public InternalCDOTransaction openTransaction() |
340 |
return openView(createResourceSet()); |
| 341 |
{ |
341 |
} |
| 342 |
return openTransaction(createResourceSet()); |
342 |
|
| 343 |
} |
343 |
/** |
| 344 |
|
344 |
* @since 2.0 |
| 345 |
/** |
345 |
*/ |
| 346 |
* @since 2.0 |
346 |
protected InternalCDOView createView() { |
| 347 |
*/ |
347 |
return new CDOViewImpl(); |
| 348 |
protected InternalCDOTransaction createTransaction() |
348 |
} |
| 349 |
{ |
349 |
|
| 350 |
return new CDOTransactionImpl(); |
350 |
public CDOAuditImpl openAudit(ResourceSet resourceSet, long timeStamp) { |
| 351 |
} |
351 |
checkActive(); |
| 352 |
|
352 |
CDOAuditImpl audit = createAudit(timeStamp); |
| 353 |
/** |
353 |
initView(audit, resourceSet); |
| 354 |
* @since 2.0 |
354 |
return audit; |
| 355 |
*/ |
355 |
} |
| 356 |
public InternalCDOView openView(ResourceSet resourceSet) |
356 |
|
| 357 |
{ |
357 |
public CDOAuditImpl openAudit(long timeStamp) { |
| 358 |
checkActive(); |
358 |
return openAudit(createResourceSet(), timeStamp); |
| 359 |
InternalCDOView view = createView(); |
359 |
} |
| 360 |
initView(view, resourceSet); |
360 |
|
| 361 |
return view; |
361 |
/** |
| 362 |
} |
362 |
* @since 2.0 |
| 363 |
|
363 |
*/ |
| 364 |
/** |
364 |
protected CDOAuditImpl createAudit(long timeStamp) { |
| 365 |
* @since 2.0 |
365 |
return new CDOAuditImpl(timeStamp); |
| 366 |
*/ |
366 |
} |
| 367 |
public InternalCDOView openView() |
367 |
|
| 368 |
{ |
368 |
/** |
| 369 |
return openView(createResourceSet()); |
369 |
* @since 2.0 |
| 370 |
} |
370 |
*/ |
| 371 |
|
371 |
public void viewDetached(InternalCDOView view) { |
| 372 |
/** |
372 |
// Detach viewset from the view |
| 373 |
* @since 2.0 |
373 |
view.getViewSet().remove(view); |
| 374 |
*/ |
374 |
synchronized (views) { |
| 375 |
protected InternalCDOView createView() |
375 |
if (!views.remove(view)) { |
| 376 |
{ |
376 |
return; |
| 377 |
return new CDOViewImpl(); |
377 |
} |
| 378 |
} |
378 |
} |
| 379 |
|
379 |
|
| 380 |
public CDOAuditImpl openAudit(ResourceSet resourceSet, long timeStamp) |
380 |
if (isActive()) { |
| 381 |
{ |
381 |
try { |
| 382 |
checkActive(); |
382 |
LifecycleUtil.deactivate(view); |
| 383 |
CDOAuditImpl audit = createAudit(timeStamp); |
383 |
} catch (Exception ex) { |
| 384 |
initView(audit, resourceSet); |
384 |
throw WrappedException.wrap(ex); |
| 385 |
return audit; |
385 |
} |
| 386 |
} |
386 |
} |
| 387 |
|
387 |
|
| 388 |
public CDOAuditImpl openAudit(long timeStamp) |
388 |
fireElementRemovedEvent(view); |
| 389 |
{ |
389 |
} |
| 390 |
return openAudit(createResourceSet(), timeStamp); |
390 |
|
| 391 |
} |
391 |
public CDOView getView(int viewID) { |
| 392 |
|
392 |
checkActive(); |
| 393 |
/** |
393 |
for (InternalCDOView view : getViews()) { |
| 394 |
* @since 2.0 |
394 |
if (view.getViewID() == viewID) { |
| 395 |
*/ |
395 |
return view; |
| 396 |
protected CDOAuditImpl createAudit(long timeStamp) |
396 |
} |
| 397 |
{ |
397 |
} |
| 398 |
return new CDOAuditImpl(timeStamp); |
398 |
|
| 399 |
} |
399 |
return null; |
| 400 |
|
400 |
} |
| 401 |
/** |
401 |
|
| 402 |
* @since 2.0 |
402 |
/** |
| 403 |
*/ |
403 |
* @since 2.0 |
| 404 |
public void viewDetached(InternalCDOView view) |
404 |
*/ |
| 405 |
{ |
405 |
public InternalCDOView[] getViews() { |
| 406 |
// Detach viewset from the view |
406 |
checkActive(); |
| 407 |
view.getViewSet().remove(view); |
407 |
synchronized (views) { |
| 408 |
synchronized (views) |
408 |
return views.toArray(new InternalCDOView[views.size()]); |
| 409 |
{ |
409 |
} |
| 410 |
if (!views.remove(view)) |
410 |
} |
| 411 |
{ |
411 |
|
| 412 |
return; |
412 |
public CDOView[] getElements() { |
| 413 |
} |
413 |
return getViews(); |
| 414 |
} |
414 |
} |
| 415 |
|
415 |
|
| 416 |
if (isActive()) |
416 |
@Override |
| 417 |
{ |
417 |
public boolean isEmpty() { |
| 418 |
try |
418 |
checkActive(); |
| 419 |
{ |
419 |
return views.isEmpty(); |
| 420 |
LifecycleUtil.deactivate(view); |
420 |
} |
| 421 |
} |
421 |
|
| 422 |
catch (Exception ex) |
422 |
/** |
| 423 |
{ |
423 |
* @since 2.0 |
| 424 |
throw WrappedException.wrap(ex); |
424 |
*/ |
| 425 |
} |
425 |
public Collection<CDOTimeStampContext> refresh() { |
| 426 |
} |
426 |
// If passive update is turned on we don`t need to refresh. |
| 427 |
|
427 |
// We do not throw an exception since the client could turn |
| 428 |
fireElementRemovedEvent(view); |
428 |
// that feature on or off without affecting their code. |
| 429 |
} |
429 |
checkActive(); |
| 430 |
|
430 |
if (!options().isPassiveUpdateEnabled()) { |
| 431 |
public CDOView getView(int viewID) |
431 |
Map<CDOID, CDOIDAndVersion> allRevisions = getAllCDOIDAndVersion(); |
| 432 |
{ |
432 |
|
| 433 |
checkActive(); |
433 |
try { |
| 434 |
for (InternalCDOView view : getViews()) |
434 |
if (!allRevisions.isEmpty()) { |
| 435 |
{ |
435 |
int initialChunkSize = options() |
| 436 |
if (view.getViewID() == viewID) |
436 |
.getCollectionLoadingPolicy().getInitialChunkSize(); |
| 437 |
{ |
437 |
return getSessionProtocol().syncRevisions(allRevisions, |
| 438 |
return view; |
438 |
initialChunkSize); |
| 439 |
} |
439 |
} |
| 440 |
} |
440 |
} catch (Exception ex) { |
| 441 |
|
441 |
throw WrappedException.wrap(ex); |
| 442 |
return null; |
442 |
} |
| 443 |
} |
443 |
} |
| 444 |
|
444 |
|
| 445 |
/** |
445 |
return Collections.emptyList(); |
| 446 |
* @since 2.0 |
446 |
} |
| 447 |
*/ |
447 |
|
| 448 |
public InternalCDOView[] getViews() |
448 |
public long getLastUpdateTime() { |
| 449 |
{ |
449 |
synchronized (lastUpdateTimeLock) { |
| 450 |
checkActive(); |
450 |
return lastUpdateTime; |
| 451 |
synchronized (views) |
451 |
} |
| 452 |
{ |
452 |
} |
| 453 |
return views.toArray(new InternalCDOView[views.size()]); |
453 |
|
| 454 |
} |
454 |
public void setLastUpdateTime(long lastUpdateTime) { |
| 455 |
} |
455 |
synchronized (lastUpdateTimeLock) { |
| 456 |
|
456 |
this.lastUpdateTime = lastUpdateTime; |
| 457 |
public CDOView[] getElements() |
457 |
lastUpdateTimeLock.notifyAll(); |
| 458 |
{ |
458 |
} |
| 459 |
return getViews(); |
459 |
} |
| 460 |
} |
460 |
|
| 461 |
|
461 |
public void waitForUpdate(long updateTime) { |
| 462 |
@Override |
462 |
waitForUpdate(updateTime, NO_TIMEOUT); |
| 463 |
public boolean isEmpty() |
463 |
} |
| 464 |
{ |
464 |
|
| 465 |
checkActive(); |
465 |
public boolean waitForUpdate(long updateTime, long timeoutMillis) { |
| 466 |
return views.isEmpty(); |
466 |
long end = timeoutMillis == NO_TIMEOUT ? Long.MAX_VALUE : System |
| 467 |
} |
467 |
.currentTimeMillis() |
| 468 |
|
468 |
+ timeoutMillis; |
| 469 |
/** |
469 |
for (;;) { |
| 470 |
* @since 2.0 |
470 |
synchronized (lastUpdateTimeLock) { |
| 471 |
*/ |
471 |
if (lastUpdateTime >= updateTime) { |
| 472 |
public Collection<CDOTimeStampContext> refresh() |
472 |
return true; |
| 473 |
{ |
473 |
} |
| 474 |
// If passive update is turned on we don`t need to refresh. |
474 |
|
| 475 |
// We do not throw an exception since the client could turn |
475 |
long now = System.currentTimeMillis(); |
| 476 |
// that feature on or off without affecting their code. |
476 |
if (now >= end) { |
| 477 |
checkActive(); |
477 |
return false; |
| 478 |
if (!options().isPassiveUpdateEnabled()) |
478 |
} |
| 479 |
{ |
479 |
|
| 480 |
Map<CDOID, CDOIDAndVersion> allRevisions = getAllCDOIDAndVersion(); |
480 |
try { |
| 481 |
|
481 |
lastUpdateTimeLock.wait(end - now); |
| 482 |
try |
482 |
} catch (InterruptedException ex) { |
| 483 |
{ |
483 |
throw WrappedException.wrap(ex); |
| 484 |
if (!allRevisions.isEmpty()) |
484 |
} |
| 485 |
{ |
485 |
} |
| 486 |
int initialChunkSize = options().getCollectionLoadingPolicy().getInitialChunkSize(); |
486 |
} |
| 487 |
return getSessionProtocol().syncRevisions(allRevisions, initialChunkSize); |
487 |
} |
| 488 |
} |
488 |
|
| 489 |
} |
489 |
/** |
| 490 |
catch (Exception ex) |
490 |
* @since 3.0 |
| 491 |
{ |
491 |
*/ |
| 492 |
throw WrappedException.wrap(ex); |
492 |
public Object resolveElementProxy(CDORevision revision, |
| 493 |
} |
493 |
EStructuralFeature feature, int accessIndex, int serverIndex) { |
| 494 |
} |
494 |
CDOCollectionLoadingPolicy policy = options() |
| 495 |
|
495 |
.getCollectionLoadingPolicy(); |
| 496 |
return Collections.emptyList(); |
496 |
return policy.resolveProxy(this, revision, feature, accessIndex, |
| 497 |
} |
497 |
serverIndex); |
| 498 |
|
498 |
} |
| 499 |
public long getLastUpdateTime() |
499 |
|
| 500 |
{ |
500 |
/** |
| 501 |
synchronized (lastUpdateTimeLock) |
501 |
* @since 2.0 |
| 502 |
{ |
502 |
*/ |
| 503 |
return lastUpdateTime; |
503 |
public void handleSyncResponse(long timestamp, |
| 504 |
} |
504 |
Collection<CDOPackageUnit> newPackageUnits, |
| 505 |
} |
505 |
Set<CDOIDAndVersion> dirtyOIDs, Collection<CDOID> detachedObjects) { |
| 506 |
|
506 |
handleCommitNotification(timestamp, newPackageUnits, dirtyOIDs, |
| 507 |
public void setLastUpdateTime(long lastUpdateTime) |
507 |
detachedObjects, null, null, true, false); |
| 508 |
{ |
508 |
} |
| 509 |
synchronized (lastUpdateTimeLock) |
509 |
|
| 510 |
{ |
510 |
/** |
| 511 |
this.lastUpdateTime = lastUpdateTime; |
511 |
* @since 2.0 |
| 512 |
lastUpdateTimeLock.notifyAll(); |
512 |
*/ |
| 513 |
} |
513 |
public void handleCommitNotification(final long timeStamp, |
| 514 |
} |
514 |
final Collection<CDOPackageUnit> newPackageUnits, |
| 515 |
|
515 |
Set<CDOIDAndVersion> dirtyOIDs, |
| 516 |
public void waitForUpdate(long updateTime) |
516 |
final Collection<CDOID> detachedObjects, |
| 517 |
{ |
517 |
final Collection<CDORevisionDelta> deltas, |
| 518 |
waitForUpdate(updateTime, NO_TIMEOUT); |
518 |
InternalCDOView excludedView) { |
| 519 |
} |
519 |
handleCommitNotification(timeStamp, newPackageUnits, dirtyOIDs, |
| 520 |
|
520 |
detachedObjects, deltas, excludedView, options() |
| 521 |
public boolean waitForUpdate(long updateTime, long timeoutMillis) |
521 |
.isPassiveUpdateEnabled(), true); |
| 522 |
{ |
522 |
} |
| 523 |
long end = timeoutMillis == NO_TIMEOUT ? Long.MAX_VALUE : System.currentTimeMillis() + timeoutMillis; |
523 |
|
| 524 |
for (;;) |
524 |
private void handleCommitNotification(final long timeStamp, |
| 525 |
{ |
525 |
final Collection<CDOPackageUnit> newPackageUnits, |
| 526 |
synchronized (lastUpdateTimeLock) |
526 |
Set<CDOIDAndVersion> dirtyOIDs, |
| 527 |
{ |
527 |
final Collection<CDOID> detachedObjects, |
| 528 |
if (lastUpdateTime >= updateTime) |
528 |
final Collection<CDORevisionDelta> deltas, |
| 529 |
{ |
529 |
InternalCDOView excludedView, final boolean passiveUpdate, |
| 530 |
return true; |
530 |
final boolean async) { |
| 531 |
} |
531 |
try { |
| 532 |
|
532 |
synchronized (commitLock) { |
| 533 |
long now = System.currentTimeMillis(); |
533 |
if (passiveUpdate) { |
| 534 |
if (now >= end) |
534 |
reviseRevisions(timeStamp, dirtyOIDs, detachedObjects, |
| 535 |
{ |
535 |
excludedView); |
| 536 |
return false; |
536 |
} |
| 537 |
} |
537 |
|
| 538 |
|
538 |
final Set<CDOIDAndVersion> finalDirtyOIDs = Collections |
| 539 |
try |
539 |
.unmodifiableSet(dirtyOIDs); |
| 540 |
{ |
540 |
final Collection<CDOID> finalDetachedObjects = Collections |
| 541 |
lastUpdateTimeLock.wait(end - now); |
541 |
.unmodifiableCollection(detachedObjects); |
| 542 |
} |
542 |
final boolean skipChangeSubscription = (deltas == null || deltas |
| 543 |
catch (InterruptedException ex) |
543 |
.size() <= 0) |
| 544 |
{ |
544 |
&& (detachedObjects == null || detachedObjects.size() <= 0); |
| 545 |
throw WrappedException.wrap(ex); |
545 |
|
| 546 |
} |
546 |
for (final InternalCDOView view : getViews()) { |
| 547 |
} |
547 |
if (view != excludedView) { |
| 548 |
} |
548 |
final Runnable runnable = new Runnable() { |
| 549 |
} |
549 |
public void run() { |
| 550 |
|
550 |
try { |
| 551 |
/** |
551 |
Set<CDOObject> conflicts = null; |
| 552 |
* @since 3.0 |
552 |
if (passiveUpdate) { |
| 553 |
*/ |
553 |
conflicts = view.handleInvalidation( |
| 554 |
public Object resolveElementProxy(CDORevision revision, EStructuralFeature feature, int accessIndex, int serverIndex) |
554 |
timeStamp, finalDirtyOIDs, |
| 555 |
{ |
555 |
finalDetachedObjects); |
| 556 |
CDOCollectionLoadingPolicy policy = options().getCollectionLoadingPolicy(); |
556 |
} |
| 557 |
return policy.resolveProxy(this, revision, feature, accessIndex, serverIndex); |
557 |
|
| 558 |
} |
558 |
if (!skipChangeSubscription) { |
| 559 |
|
559 |
view.handleChangeSubscription(deltas, |
| 560 |
/** |
560 |
detachedObjects); |
| 561 |
* @since 2.0 |
561 |
} |
| 562 |
*/ |
562 |
|
| 563 |
public void handleSyncResponse(long timestamp, Collection<CDOPackageUnit> newPackageUnits, |
563 |
if (conflicts != null) { |
| 564 |
Set<CDOIDAndVersion> dirtyOIDs, Collection<CDOID> detachedObjects) |
564 |
((InternalCDOTransaction) view) |
| 565 |
{ |
565 |
.handleConflicts(conflicts); |
| 566 |
handleCommitNotification(timestamp, newPackageUnits, dirtyOIDs, detachedObjects, null, null, true, false); |
566 |
} |
| 567 |
} |
567 |
|
| 568 |
|
568 |
view.fireAdaptersNotifiedEvent(timeStamp); |
| 569 |
/** |
569 |
} catch (RuntimeException ex) { |
| 570 |
* @since 2.0 |
570 |
if (!async) { |
| 571 |
*/ |
571 |
throw ex; |
| 572 |
public void handleCommitNotification(final long timeStamp, final Collection<CDOPackageUnit> newPackageUnits, |
572 |
} |
| 573 |
Set<CDOIDAndVersion> dirtyOIDs, final Collection<CDOID> detachedObjects, |
573 |
|
| 574 |
final Collection<CDORevisionDelta> deltas, InternalCDOView excludedView) |
574 |
if (view.isActive()) { |
| 575 |
{ |
575 |
OM.LOG.error(ex); |
| 576 |
handleCommitNotification(timeStamp, newPackageUnits, dirtyOIDs, detachedObjects, deltas, excludedView, options() |
576 |
} else { |
| 577 |
.isPassiveUpdateEnabled(), true); |
577 |
OM.LOG.info(Messages |
| 578 |
} |
578 |
.getString("CDOSessionImpl.1")); |
| 579 |
|
579 |
} |
| 580 |
private void handleCommitNotification(final long timeStamp, final Collection<CDOPackageUnit> newPackageUnits, |
580 |
} |
| 581 |
Set<CDOIDAndVersion> dirtyOIDs, final Collection<CDOID> detachedObjects, |
581 |
} |
| 582 |
final Collection<CDORevisionDelta> deltas, InternalCDOView excludedView, final boolean passiveUpdate, |
582 |
}; |
| 583 |
final boolean async) |
583 |
|
| 584 |
{ |
584 |
if (async) { |
| 585 |
try |
585 |
QueueRunner runner = getInvalidationRunner(); |
| 586 |
{ |
586 |
runner.addWork(new Runnable() { |
| 587 |
synchronized (commitLock) |
587 |
public void run() { |
| 588 |
{ |
588 |
try { |
| 589 |
if (passiveUpdate) |
589 |
invalidationRunnerActive.set(true); |
| 590 |
{ |
590 |
runnable.run(); |
| 591 |
reviseRevisions(timeStamp, dirtyOIDs, detachedObjects, excludedView); |
591 |
} finally { |
| 592 |
} |
592 |
invalidationRunnerActive.set(false); |
| 593 |
|
593 |
} |
| 594 |
final Set<CDOIDAndVersion> finalDirtyOIDs = Collections.unmodifiableSet(dirtyOIDs); |
594 |
} |
| 595 |
final Collection<CDOID> finalDetachedObjects = Collections.unmodifiableCollection(detachedObjects); |
595 |
}); |
| 596 |
final boolean skipChangeSubscription = (deltas == null || deltas.size() <= 0) |
596 |
} else { |
| 597 |
&& (detachedObjects == null || detachedObjects.size() <= 0); |
597 |
runnable.run(); |
| 598 |
|
598 |
} |
| 599 |
for (final InternalCDOView view : getViews()) |
599 |
} |
| 600 |
{ |
600 |
} |
| 601 |
if (view != excludedView) |
601 |
} |
| 602 |
{ |
602 |
} catch (RuntimeException ex) { |
| 603 |
final Runnable runnable = new Runnable() |
603 |
if (!async) { |
| 604 |
{ |
604 |
throw ex; |
| 605 |
public void run() |
605 |
} |
| 606 |
{ |
606 |
|
| 607 |
try |
607 |
if (isActive()) { |
| 608 |
{ |
608 |
OM.LOG.error(ex); |
| 609 |
Set<CDOObject> conflicts = null; |
609 |
} else { |
| 610 |
if (passiveUpdate) |
610 |
OM.LOG.info(Messages.getString("CDOSessionImpl.2")); |
| 611 |
{ |
611 |
} |
| 612 |
conflicts = view.handleInvalidation(timeStamp, finalDirtyOIDs, finalDetachedObjects); |
612 |
} |
| 613 |
} |
613 |
|
| 614 |
|
614 |
setLastUpdateTime(timeStamp); |
| 615 |
if (!skipChangeSubscription) |
615 |
fireInvalidationEvent(timeStamp, newPackageUnits, dirtyOIDs, |
| 616 |
{ |
616 |
detachedObjects, excludedView); |
| 617 |
view.handleChangeSubscription(deltas, detachedObjects); |
617 |
} |
| 618 |
} |
618 |
|
| 619 |
|
619 |
public void reviseRevisions(final long timeStamp, |
| 620 |
if (conflicts != null) |
620 |
Set<CDOIDAndVersion> dirtyOIDs, Collection<CDOID> detachedObjects, |
| 621 |
{ |
621 |
InternalCDOView excludedView) { |
| 622 |
((InternalCDOTransaction)view).handleConflicts(conflicts); |
622 |
InternalCDORevisionManager revisionManager = getRevisionManager(); |
| 623 |
} |
623 |
if (excludedView == null || timeStamp == CDORevision.UNSPECIFIED_DATE) { |
| 624 |
|
624 |
for (CDOIDAndVersion dirtyOID : dirtyOIDs) { |
| 625 |
view.fireAdaptersNotifiedEvent(timeStamp); |
625 |
CDOID id = dirtyOID.getID(); |
| 626 |
} |
626 |
int version = dirtyOID.getVersion(); |
| 627 |
catch (RuntimeException ex) |
627 |
revisionManager.reviseVersion(id, version, timeStamp); |
| 628 |
{ |
628 |
} |
| 629 |
if (!async) |
629 |
} |
| 630 |
{ |
630 |
|
| 631 |
throw ex; |
631 |
for (CDOID id : detachedObjects) { |
| 632 |
} |
632 |
revisionManager.reviseLatest(id); |
| 633 |
|
633 |
} |
| 634 |
if (view.isActive()) |
634 |
} |
| 635 |
{ |
635 |
|
| 636 |
OM.LOG.error(ex); |
636 |
public Object getCommitLock() { |
| 637 |
} |
637 |
return commitLock; |
| 638 |
else |
638 |
} |
| 639 |
{ |
639 |
|
| 640 |
OM.LOG.info(Messages.getString("CDOSessionImpl.1")); |
640 |
private QueueRunner getInvalidationRunner() { |
| 641 |
} |
641 |
synchronized (invalidationRunnerLock) { |
| 642 |
} |
642 |
if (invalidationRunner == null) { |
| 643 |
} |
643 |
invalidationRunner = createInvalidationRunner(); |
| 644 |
}; |
644 |
invalidationRunner.activate(); |
| 645 |
|
645 |
} |
| 646 |
if (async) |
646 |
} |
| 647 |
{ |
647 |
|
| 648 |
QueueRunner runner = getInvalidationRunner(); |
648 |
return invalidationRunner; |
| 649 |
runner.addWork(new Runnable() |
649 |
} |
| 650 |
{ |
650 |
|
| 651 |
public void run() |
651 |
protected QueueRunner createInvalidationRunner() { |
| 652 |
{ |
652 |
return new QueueRunner() { |
| 653 |
try |
653 |
@Override |
| 654 |
{ |
654 |
protected String getThreadName() { |
| 655 |
invalidationRunnerActive.set(true); |
655 |
return "InvalidationRunner"; |
| 656 |
runnable.run(); |
656 |
} |
| 657 |
} |
657 |
|
| 658 |
finally |
658 |
@Override |
| 659 |
{ |
659 |
public String toString() { |
| 660 |
invalidationRunnerActive.set(false); |
660 |
return getThreadName(); |
| 661 |
} |
661 |
} |
| 662 |
} |
662 |
}; |
| 663 |
}); |
663 |
} |
| 664 |
} |
664 |
|
| 665 |
else |
665 |
/** |
| 666 |
{ |
666 |
* @param packageUnits |
| 667 |
runnable.run(); |
667 |
* @since 2.0 |
| 668 |
} |
668 |
*/ |
| 669 |
} |
669 |
public void fireInvalidationEvent(long timeStamp, |
| 670 |
} |
670 |
Collection<CDOPackageUnit> packageUnits, |
| 671 |
} |
671 |
Set<CDOIDAndVersion> dirtyOIDs, Collection<CDOID> detachedObjects, |
| 672 |
} |
672 |
InternalCDOView excludedView) { |
| 673 |
catch (RuntimeException ex) |
673 |
fireEvent(new InvalidationEvent(excludedView, timeStamp, packageUnits, |
| 674 |
{ |
674 |
dirtyOIDs, detachedObjects)); |
| 675 |
if (!async) |
675 |
} |
| 676 |
{ |
676 |
|
| 677 |
throw ex; |
677 |
@Override |
| 678 |
} |
678 |
public String toString() { |
| 679 |
|
679 |
String name = repositoryInfo == null ? "?" : repositoryInfo.getName(); |
| 680 |
if (isActive()) |
680 |
return MessageFormat.format("CDOSession[{0}, {1}]", name, sessionID); |
| 681 |
{ |
681 |
} |
| 682 |
OM.LOG.error(ex); |
682 |
|
| 683 |
} |
683 |
protected ResourceSet createResourceSet() { |
| 684 |
else |
684 |
return new ResourceSetImpl(); |
| 685 |
{ |
685 |
} |
| 686 |
OM.LOG.info(Messages.getString("CDOSessionImpl.2")); |
686 |
|
| 687 |
} |
687 |
/** |
| 688 |
} |
688 |
* @since 2.0 |
| 689 |
|
689 |
*/ |
| 690 |
setLastUpdateTime(timeStamp); |
690 |
protected void initView(InternalCDOView view, ResourceSet resourceSet) { |
| 691 |
fireInvalidationEvent(timeStamp, newPackageUnits, dirtyOIDs, detachedObjects, excludedView); |
691 |
if (TRACER.isEnabled()) { |
| 692 |
} |
692 |
TRACER.format("Initializing new {0} view", view.getViewType()); |
| 693 |
|
693 |
} |
| 694 |
public void reviseRevisions(final long timeStamp, Set<CDOIDAndVersion> dirtyOIDs, Collection<CDOID> detachedObjects, |
694 |
|
| 695 |
InternalCDOView excludedView) |
695 |
InternalCDOViewSet viewSet = SessionUtil |
| 696 |
{ |
696 |
.prepareResourceSet(resourceSet); |
| 697 |
InternalCDORevisionManager revisionManager = getRevisionManager(); |
697 |
synchronized (views) { |
| 698 |
if (excludedView == null || timeStamp == CDORevision.UNSPECIFIED_DATE) |
698 |
view.setSession(this); |
| 699 |
{ |
699 |
view.setViewID(++lastViewID); |
| 700 |
for (CDOIDAndVersion dirtyOID : dirtyOIDs) |
700 |
views.add(view); |
| 701 |
{ |
701 |
} |
| 702 |
CDOID id = dirtyOID.getID(); |
702 |
|
| 703 |
int version = dirtyOID.getVersion(); |
703 |
// Link ViewSet with View |
| 704 |
revisionManager.reviseVersion(id, version, timeStamp); |
704 |
view.setViewSet(viewSet); |
| 705 |
} |
705 |
viewSet.add(view); |
| 706 |
} |
706 |
|
| 707 |
|
707 |
try { |
| 708 |
for (CDOID id : detachedObjects) |
708 |
view.activate(); |
| 709 |
{ |
709 |
fireElementAddedEvent(view); |
| 710 |
revisionManager.reviseLatest(id); |
710 |
} catch (RuntimeException ex) { |
| 711 |
} |
711 |
synchronized (views) { |
| 712 |
} |
712 |
views.remove(view); |
| 713 |
|
713 |
} |
| 714 |
public Object getCommitLock() |
714 |
|
| 715 |
{ |
715 |
viewSet.remove(view); |
| 716 |
return commitLock; |
716 |
throw ex; |
| 717 |
} |
717 |
} |
| 718 |
|
718 |
} |
| 719 |
private QueueRunner getInvalidationRunner() |
719 |
|
| 720 |
{ |
720 |
@Override |
| 721 |
synchronized (invalidationRunnerLock) |
721 |
protected void doActivate() throws Exception { |
| 722 |
{ |
722 |
super.doActivate(); |
| 723 |
if (invalidationRunner == null) |
723 |
getConfiguration().activateSession(this); |
| 724 |
{ |
724 |
checkState(sessionProtocol, "sessionProtocol"); |
| 725 |
invalidationRunner = createInvalidationRunner(); |
725 |
checkState(remoteSessionManager, "remoteSessionManager"); |
| 726 |
invalidationRunner.activate(); |
726 |
if (exceptionHandler != null) { |
| 727 |
} |
727 |
sessionProtocol = new DelegatingSessionProtocol(sessionProtocol); |
| 728 |
} |
728 |
} |
| 729 |
|
729 |
|
| 730 |
return invalidationRunner; |
730 |
EventUtil.addListener(sessionProtocol, sessionProtocolListener); |
| 731 |
} |
731 |
} |
| 732 |
|
732 |
|
| 733 |
protected QueueRunner createInvalidationRunner() |
733 |
@Override |
| 734 |
{ |
734 |
protected void doDeactivate() throws Exception { |
| 735 |
return new QueueRunner() |
735 |
for (InternalCDOView view : views.toArray(new InternalCDOView[views |
| 736 |
{ |
736 |
.size()])) { |
| 737 |
@Override |
737 |
try { |
| 738 |
protected String getThreadName() |
738 |
view.close(); |
| 739 |
{ |
739 |
} catch (RuntimeException ignore) { |
| 740 |
return "InvalidationRunner"; |
740 |
} |
| 741 |
} |
741 |
} |
| 742 |
|
742 |
|
| 743 |
@Override |
743 |
views.clear(); |
| 744 |
public String toString() |
744 |
|
| 745 |
{ |
745 |
if (invalidationRunner != null) { |
| 746 |
return getThreadName(); |
746 |
LifecycleUtil.deactivate(invalidationRunner, OMLogger.Level.WARN); |
| 747 |
} |
747 |
invalidationRunner = null; |
| 748 |
}; |
748 |
} |
| 749 |
} |
749 |
|
| 750 |
|
750 |
EventUtil.removeListener(sessionProtocol, sessionProtocolListener); |
| 751 |
/** |
751 |
getConfiguration().deactivateSession(this); |
| 752 |
* @param packageUnits |
752 |
super.doDeactivate(); |
| 753 |
* @since 2.0 |
753 |
} |
| 754 |
*/ |
754 |
|
| 755 |
public void fireInvalidationEvent(long timeStamp, Collection<CDOPackageUnit> packageUnits, |
755 |
private Map<CDOID, CDOIDAndVersion> getAllCDOIDAndVersion() { |
| 756 |
Set<CDOIDAndVersion> dirtyOIDs, Collection<CDOID> detachedObjects, InternalCDOView excludedView) |
756 |
Map<CDOID, CDOIDAndVersion> uniqueObjects = new HashMap<CDOID, CDOIDAndVersion>(); |
| 757 |
{ |
757 |
for (InternalCDOView view : getViews()) { |
| 758 |
fireEvent(new InvalidationEvent(excludedView, timeStamp, packageUnits, dirtyOIDs, detachedObjects)); |
758 |
view.getCDOIDAndVersion(uniqueObjects, Arrays.asList(view |
| 759 |
} |
759 |
.getObjectsArray())); |
| 760 |
|
760 |
} |
| 761 |
@Override |
761 |
|
| 762 |
public String toString() |
762 |
// Need to add Revision from revisionManager since we do not have all |
| 763 |
{ |
763 |
// objects in view. |
| 764 |
String name = repositoryInfo == null ? "?" : repositoryInfo.getName(); |
764 |
for (CDORevision revision : getRevisionManager().getCache() |
| 765 |
return MessageFormat.format("CDOSession[{0}, {1}]", name, sessionID); |
765 |
.getRevisions()) { |
| 766 |
} |
766 |
if (!uniqueObjects.containsKey(revision.getID())) { |
| 767 |
|
767 |
uniqueObjects.put(revision.getID(), CDOIDUtil |
| 768 |
protected ResourceSet createResourceSet() |
768 |
.createIDAndVersion(revision.getID(), revision |
| 769 |
{ |
769 |
.getVersion())); |
| 770 |
return new ResourceSetImpl(); |
770 |
} |
| 771 |
} |
771 |
} |
| 772 |
|
772 |
|
| 773 |
/** |
773 |
return uniqueObjects; |
| 774 |
* @since 2.0 |
774 |
} |
| 775 |
*/ |
775 |
|
| 776 |
protected void initView(InternalCDOView view, ResourceSet resourceSet) |
776 |
public static boolean isInvalidationRunnerActive() { |
| 777 |
{ |
777 |
return invalidationRunnerActive.get(); |
| 778 |
if (TRACER.isEnabled()) |
778 |
} |
| 779 |
{ |
779 |
|
| 780 |
TRACER.format("Initializing new {0} view", view.getViewType()); |
780 |
/** |
| 781 |
} |
781 |
* @author Eike Stepper |
| 782 |
|
782 |
* @since 2.0 |
| 783 |
InternalCDOViewSet viewSet = SessionUtil.prepareResourceSet(resourceSet); |
783 |
*/ |
| 784 |
synchronized (views) |
784 |
protected class OptionsImpl extends Notifier implements Options { |
| 785 |
{ |
785 |
private boolean generatedPackageEmulationEnabled = false; |
| 786 |
view.setSession(this); |
786 |
|
| 787 |
view.setViewID(++lastViewID); |
787 |
private boolean passiveUpdateEnabled = true; |
| 788 |
views.add(view); |
788 |
|
| 789 |
} |
789 |
private CDOCollectionLoadingPolicy collectionLoadingPolicy; |
| 790 |
|
790 |
|
| 791 |
// Link ViewSet with View |
791 |
public OptionsImpl() { |
| 792 |
view.setViewSet(viewSet); |
792 |
// TODO Remove preferences from core |
| 793 |
viewSet.add(view); |
793 |
int value = OM.PREF_COLLECTION_LOADING_CHUNK_SIZE.getValue(); |
| 794 |
|
794 |
collectionLoadingPolicy = CDOUtil.createCollectionLoadingPolicy( |
| 795 |
try |
795 |
value, value); |
| 796 |
{ |
796 |
} |
| 797 |
view.activate(); |
797 |
|
| 798 |
fireElementAddedEvent(view); |
798 |
public IOptionsContainer getContainer() { |
| 799 |
} |
799 |
return CDOSessionImpl.this; |
| 800 |
catch (RuntimeException ex) |
800 |
} |
| 801 |
{ |
801 |
|
| 802 |
synchronized (views) |
802 |
public boolean isGeneratedPackageEmulationEnabled() { |
| 803 |
{ |
803 |
return generatedPackageEmulationEnabled; |
| 804 |
views.remove(view); |
804 |
} |
| 805 |
} |
805 |
|
| 806 |
|
806 |
public synchronized void setGeneratedPackageEmulationEnabled( |
| 807 |
viewSet.remove(view); |
807 |
boolean generatedPackageEmulationEnabled) { |
| 808 |
throw ex; |
808 |
this.generatedPackageEmulationEnabled = generatedPackageEmulationEnabled; |
| 809 |
} |
809 |
if (this.generatedPackageEmulationEnabled != generatedPackageEmulationEnabled) { |
| 810 |
} |
810 |
this.generatedPackageEmulationEnabled = generatedPackageEmulationEnabled; |
| 811 |
|
811 |
// TODO Check inconsistent state if switching off? |
| 812 |
@Override |
812 |
|
| 813 |
protected void doActivate() throws Exception |
813 |
IListener[] listeners = getListeners(); |
| 814 |
{ |
814 |
if (listeners != null) { |
| 815 |
super.doActivate(); |
815 |
fireEvent(new GeneratedPackageEmulationEventImpl(), |
| 816 |
getConfiguration().activateSession(this); |
816 |
listeners); |
| 817 |
checkState(sessionProtocol, "sessionProtocol"); |
817 |
} |
| 818 |
checkState(remoteSessionManager, "remoteSessionManager"); |
818 |
} |
| 819 |
if (exceptionHandler != null) |
819 |
} |
| 820 |
{ |
820 |
|
| 821 |
sessionProtocol = new DelegatingSessionProtocol(sessionProtocol); |
821 |
public boolean isPassiveUpdateEnabled() { |
| 822 |
} |
822 |
return passiveUpdateEnabled; |
| 823 |
|
823 |
} |
| 824 |
EventUtil.addListener(sessionProtocol, sessionProtocolListener); |
824 |
|
| 825 |
} |
825 |
public synchronized void setPassiveUpdateEnabled( |
| 826 |
|
826 |
boolean passiveUpdateEnabled) { |
| 827 |
@Override |
827 |
if (this.passiveUpdateEnabled != passiveUpdateEnabled) { |
| 828 |
protected void doDeactivate() throws Exception |
828 |
this.passiveUpdateEnabled = passiveUpdateEnabled; |
| 829 |
{ |
829 |
|
| 830 |
for (InternalCDOView view : views.toArray(new InternalCDOView[views.size()])) |
830 |
// Need to refresh if we change state |
| 831 |
{ |
831 |
Map<CDOID, CDOIDAndVersion> allRevisions = getAllCDOIDAndVersion(); |
| 832 |
try |
832 |
if (!allRevisions.isEmpty()) { |
| 833 |
{ |
833 |
int initialChunkSize = collectionLoadingPolicy |
| 834 |
view.close(); |
834 |
.getInitialChunkSize(); |
| 835 |
} |
835 |
getSessionProtocol().setPassiveUpdate(allRevisions, |
| 836 |
catch (RuntimeException ignore) |
836 |
initialChunkSize, passiveUpdateEnabled); |
| 837 |
{ |
837 |
} |
| 838 |
} |
838 |
|
| 839 |
} |
839 |
IListener[] listeners = getListeners(); |
| 840 |
|
840 |
if (listeners != null) { |
| 841 |
views.clear(); |
841 |
fireEvent(new PassiveUpdateEventImpl(), listeners); |
| 842 |
|
842 |
} |
| 843 |
if (invalidationRunner != null) |
843 |
} |
| 844 |
{ |
844 |
} |
| 845 |
LifecycleUtil.deactivate(invalidationRunner, OMLogger.Level.WARN); |
845 |
|
| 846 |
invalidationRunner = null; |
846 |
public CDOCollectionLoadingPolicy getCollectionLoadingPolicy() { |
| 847 |
} |
847 |
return collectionLoadingPolicy; |
| 848 |
|
848 |
} |
| 849 |
EventUtil.removeListener(sessionProtocol, sessionProtocolListener); |
849 |
|
| 850 |
getConfiguration().deactivateSession(this); |
850 |
public synchronized void setCollectionLoadingPolicy( |
| 851 |
super.doDeactivate(); |
851 |
CDOCollectionLoadingPolicy policy) { |
| 852 |
} |
852 |
if (policy == null) { |
| 853 |
|
853 |
policy = CDOCollectionLoadingPolicy.DEFAULT; |
| 854 |
private Map<CDOID, CDOIDAndVersion> getAllCDOIDAndVersion() |
854 |
} |
| 855 |
{ |
855 |
|
| 856 |
Map<CDOID, CDOIDAndVersion> uniqueObjects = new HashMap<CDOID, CDOIDAndVersion>(); |
856 |
if (collectionLoadingPolicy != policy) { |
| 857 |
for (InternalCDOView view : getViews()) |
857 |
collectionLoadingPolicy = policy; |
| 858 |
{ |
858 |
IListener[] listeners = getListeners(); |
| 859 |
view.getCDOIDAndVersion(uniqueObjects, Arrays.asList(view.getObjectsArray())); |
859 |
if (listeners != null) { |
| 860 |
} |
860 |
fireEvent(new CollectionLoadingPolicyEventImpl(), listeners); |
| 861 |
|
861 |
} |
| 862 |
// Need to add Revision from revisionManager since we do not have all objects in view. |
862 |
} |
| 863 |
for (CDORevision revision : getRevisionManager().getCache().getRevisions()) |
863 |
} |
| 864 |
{ |
864 |
|
| 865 |
if (!uniqueObjects.containsKey(revision.getID())) |
865 |
/** |
| 866 |
{ |
866 |
* @author Eike Stepper |
| 867 |
uniqueObjects.put(revision.getID(), CDOIDUtil.createIDAndVersion(revision.getID(), revision.getVersion())); |
867 |
*/ |
| 868 |
} |
868 |
private final class GeneratedPackageEmulationEventImpl extends |
| 869 |
} |
869 |
OptionsEvent implements GeneratedPackageEmulationEvent { |
| 870 |
|
870 |
private static final long serialVersionUID = 1L; |
| 871 |
return uniqueObjects; |
871 |
|
| 872 |
} |
872 |
public GeneratedPackageEmulationEventImpl() { |
| 873 |
|
873 |
super(OptionsImpl.this); |
| 874 |
public static boolean isInvalidationRunnerActive() |
874 |
} |
| 875 |
{ |
875 |
} |
| 876 |
return invalidationRunnerActive.get(); |
876 |
|
| 877 |
} |
877 |
/** |
| 878 |
|
878 |
* @author Eike Stepper |
| 879 |
/** |
879 |
*/ |
| 880 |
* @author Eike Stepper |
880 |
private final class PassiveUpdateEventImpl extends OptionsEvent |
| 881 |
* @since 2.0 |
881 |
implements PassiveUpdateEvent { |
| 882 |
*/ |
882 |
private static final long serialVersionUID = 1L; |
| 883 |
protected class OptionsImpl extends Notifier implements Options |
883 |
|
| 884 |
{ |
884 |
public PassiveUpdateEventImpl() { |
| 885 |
private boolean generatedPackageEmulationEnabled = false; |
885 |
super(OptionsImpl.this); |
| 886 |
|
886 |
} |
| 887 |
private boolean passiveUpdateEnabled = true; |
887 |
} |
| 888 |
|
888 |
|
| 889 |
private CDOCollectionLoadingPolicy collectionLoadingPolicy; |
889 |
/** |
| 890 |
|
890 |
* @author Eike Stepper |
| 891 |
public OptionsImpl() |
891 |
*/ |
| 892 |
{ |
892 |
private final class CollectionLoadingPolicyEventImpl extends |
| 893 |
// TODO Remove preferences from core |
893 |
OptionsEvent implements CollectionLoadingPolicyEvent { |
| 894 |
int value = OM.PREF_COLLECTION_LOADING_CHUNK_SIZE.getValue(); |
894 |
private static final long serialVersionUID = 1L; |
| 895 |
collectionLoadingPolicy = CDOUtil.createCollectionLoadingPolicy(value, value); |
895 |
|
| 896 |
} |
896 |
public CollectionLoadingPolicyEventImpl() { |
| 897 |
|
897 |
super(OptionsImpl.this); |
| 898 |
public IOptionsContainer getContainer() |
898 |
} |
| 899 |
{ |
899 |
} |
| 900 |
return CDOSessionImpl.this; |
900 |
} |
| 901 |
} |
901 |
|
| 902 |
|
902 |
/** |
| 903 |
public boolean isGeneratedPackageEmulationEnabled() |
903 |
* @author Eike Stepper |
| 904 |
{ |
904 |
*/ |
| 905 |
return generatedPackageEmulationEnabled; |
905 |
private final class InvalidationEvent extends Event implements |
| 906 |
} |
906 |
CDOSessionInvalidationEvent { |
| 907 |
|
907 |
private static final long serialVersionUID = 1L; |
| 908 |
public synchronized void setGeneratedPackageEmulationEnabled(boolean generatedPackageEmulationEnabled) |
908 |
|
| 909 |
{ |
909 |
private InternalCDOView view; |
| 910 |
this.generatedPackageEmulationEnabled = generatedPackageEmulationEnabled; |
910 |
|
| 911 |
if (this.generatedPackageEmulationEnabled != generatedPackageEmulationEnabled) |
911 |
private long timeStamp; |
| 912 |
{ |
912 |
|
| 913 |
this.generatedPackageEmulationEnabled = generatedPackageEmulationEnabled; |
913 |
private Set<CDOIDAndVersion> dirtyOIDs; |
| 914 |
// TODO Check inconsistent state if switching off? |
914 |
|
| 915 |
|
915 |
private Collection<CDOID> detachedObjects; |
| 916 |
IListener[] listeners = getListeners(); |
916 |
|
| 917 |
if (listeners != null) |
917 |
private Collection<CDOPackageUnit> newPackageUnits; |
| 918 |
{ |
918 |
|
| 919 |
fireEvent(new GeneratedPackageEmulationEventImpl(), listeners); |
919 |
public InvalidationEvent(InternalCDOView view, long timeStamp, |
| 920 |
} |
920 |
Collection<CDOPackageUnit> packageUnits, |
| 921 |
} |
921 |
Set<CDOIDAndVersion> dirtyOIDs, |
| 922 |
} |
922 |
Collection<CDOID> detachedObjects) { |
| 923 |
|
923 |
super(CDOSessionImpl.this); |
| 924 |
public boolean isPassiveUpdateEnabled() |
924 |
this.view = view; |
| 925 |
{ |
925 |
this.timeStamp = timeStamp; |
| 926 |
return passiveUpdateEnabled; |
926 |
newPackageUnits = packageUnits; |
| 927 |
} |
927 |
this.dirtyOIDs = dirtyOIDs; |
| 928 |
|
928 |
this.detachedObjects = detachedObjects; |
| 929 |
public synchronized void setPassiveUpdateEnabled(boolean passiveUpdateEnabled) |
929 |
} |
| 930 |
{ |
930 |
|
| 931 |
if (this.passiveUpdateEnabled != passiveUpdateEnabled) |
931 |
@Override |
| 932 |
{ |
932 |
public CDOSession getSource() { |
| 933 |
this.passiveUpdateEnabled = passiveUpdateEnabled; |
933 |
return (CDOSession) super.getSource(); |
| 934 |
|
934 |
} |
| 935 |
// Need to refresh if we change state |
935 |
|
| 936 |
Map<CDOID, CDOIDAndVersion> allRevisions = getAllCDOIDAndVersion(); |
936 |
public InternalCDOView getView() { |
| 937 |
if (!allRevisions.isEmpty()) |
937 |
return view; |
| 938 |
{ |
938 |
} |
| 939 |
int initialChunkSize = collectionLoadingPolicy.getInitialChunkSize(); |
939 |
|
| 940 |
getSessionProtocol().setPassiveUpdate(allRevisions, initialChunkSize, passiveUpdateEnabled); |
940 |
public boolean isRemote() { |
| 941 |
} |
941 |
return view == null; |
| 942 |
|
942 |
} |
| 943 |
IListener[] listeners = getListeners(); |
943 |
|
| 944 |
if (listeners != null) |
944 |
public long getTimeStamp() { |
| 945 |
{ |
945 |
return timeStamp; |
| 946 |
fireEvent(new PassiveUpdateEventImpl(), listeners); |
946 |
} |
| 947 |
} |
947 |
|
| 948 |
} |
948 |
public Set<CDOIDAndVersion> getDirtyOIDs() { |
| 949 |
} |
949 |
return dirtyOIDs; |
| 950 |
|
950 |
} |
| 951 |
public CDOCollectionLoadingPolicy getCollectionLoadingPolicy() |
951 |
|
| 952 |
{ |
952 |
public Collection<CDOID> getDetachedObjects() { |
| 953 |
return collectionLoadingPolicy; |
953 |
return detachedObjects; |
| 954 |
} |
954 |
} |
| 955 |
|
955 |
|
| 956 |
public synchronized void setCollectionLoadingPolicy(CDOCollectionLoadingPolicy policy) |
956 |
public Collection<CDOPackageUnit> getNewPackageUnits() { |
| 957 |
{ |
957 |
return newPackageUnits; |
| 958 |
if (policy == null) |
958 |
} |
| 959 |
{ |
959 |
|
| 960 |
policy = CDOCollectionLoadingPolicy.DEFAULT; |
960 |
@Override |
| 961 |
} |
961 |
public String toString() { |
| 962 |
|
962 |
return "CDOSessionInvalidationEvent: " + dirtyOIDs; |
| 963 |
if (collectionLoadingPolicy != policy) |
963 |
} |
| 964 |
{ |
964 |
} |
| 965 |
collectionLoadingPolicy = policy; |
965 |
|
| 966 |
IListener[] listeners = getListeners(); |
966 |
/** |
| 967 |
if (listeners != null) |
967 |
* @author Eike Stepper |
| 968 |
{ |
968 |
*/ |
| 969 |
fireEvent(new CollectionLoadingPolicyEventImpl(), listeners); |
969 |
public class DelegatingSessionProtocol extends Lifecycle implements |
| 970 |
} |
970 |
CDOSessionProtocol { |
| 971 |
} |
971 |
private CDOSessionProtocol delegate; |
| 972 |
} |
972 |
|
| 973 |
|
973 |
@ExcludeFromDump |
| 974 |
/** |
974 |
private IListener delegateListener = new LifecycleEventAdapter() { |
| 975 |
* @author Eike Stepper |
975 |
@Override |
| 976 |
*/ |
976 |
protected void onDeactivated(ILifecycle lifecycle) { |
| 977 |
private final class GeneratedPackageEmulationEventImpl extends OptionsEvent implements |
977 |
DelegatingSessionProtocol.this.deactivate(); |
| 978 |
GeneratedPackageEmulationEvent |
978 |
} |
| 979 |
{ |
979 |
}; |
| 980 |
private static final long serialVersionUID = 1L; |
980 |
|
| 981 |
|
981 |
public DelegatingSessionProtocol(CDOSessionProtocol delegate) { |
| 982 |
public GeneratedPackageEmulationEventImpl() |
982 |
this.delegate = delegate; |
| 983 |
{ |
983 |
activate(); |
| 984 |
super(OptionsImpl.this); |
984 |
} |
| 985 |
} |
985 |
|
| 986 |
} |
986 |
public CDOSessionProtocol getDelegate() { |
| 987 |
|
987 |
return delegate; |
| 988 |
/** |
988 |
} |
| 989 |
* @author Eike Stepper |
989 |
|
| 990 |
*/ |
990 |
public CDOSession getSession() { |
| 991 |
private final class PassiveUpdateEventImpl extends OptionsEvent implements PassiveUpdateEvent |
991 |
return (CDOSession) delegate.getSession(); |
| 992 |
{ |
992 |
} |
| 993 |
private static final long serialVersionUID = 1L; |
993 |
|
| 994 |
|
994 |
public boolean cancelQuery(int queryId) { |
| 995 |
public PassiveUpdateEventImpl() |
995 |
int attempt = 0; |
| 996 |
{ |
996 |
for (;;) { |
| 997 |
super(OptionsImpl.this); |
997 |
try { |
| 998 |
} |
998 |
return delegate.cancelQuery(queryId); |
| 999 |
} |
999 |
} catch (Exception ex) { |
| 1000 |
|
1000 |
handleException(++attempt, ex); |
| 1001 |
/** |
1001 |
} |
| 1002 |
* @author Eike Stepper |
1002 |
} |
| 1003 |
*/ |
1003 |
} |
| 1004 |
private final class CollectionLoadingPolicyEventImpl extends OptionsEvent implements CollectionLoadingPolicyEvent |
1004 |
|
| 1005 |
{ |
1005 |
public void changeSubscription(int viewId, List<CDOID> cdoIDs, |
| 1006 |
private static final long serialVersionUID = 1L; |
1006 |
boolean subscribeMode, boolean clear) { |
| 1007 |
|
1007 |
int attempt = 0; |
| 1008 |
public CollectionLoadingPolicyEventImpl() |
1008 |
for (;;) { |
| 1009 |
{ |
1009 |
try { |
| 1010 |
super(OptionsImpl.this); |
1010 |
delegate.changeSubscription(viewId, cdoIDs, subscribeMode, |
| 1011 |
} |
1011 |
clear); |
| 1012 |
} |
1012 |
return; |
| 1013 |
} |
1013 |
} catch (Exception ex) { |
| 1014 |
|
1014 |
handleException(++attempt, ex); |
| 1015 |
/** |
1015 |
} |
| 1016 |
* @author Eike Stepper |
1016 |
} |
| 1017 |
*/ |
1017 |
} |
| 1018 |
private final class InvalidationEvent extends Event implements CDOSessionInvalidationEvent |
1018 |
|
| 1019 |
{ |
1019 |
public void closeView(int viewId) { |
| 1020 |
private static final long serialVersionUID = 1L; |
1020 |
int attempt = 0; |
| 1021 |
|
1021 |
for (;;) { |
| 1022 |
private InternalCDOView view; |
1022 |
try { |
| 1023 |
|
1023 |
delegate.closeView(viewId); |
| 1024 |
private long timeStamp; |
1024 |
return; |
| 1025 |
|
1025 |
} catch (Exception ex) { |
| 1026 |
private Set<CDOIDAndVersion> dirtyOIDs; |
1026 |
handleException(++attempt, ex); |
| 1027 |
|
1027 |
} |
| 1028 |
private Collection<CDOID> detachedObjects; |
1028 |
} |
| 1029 |
|
1029 |
} |
| 1030 |
private Collection<CDOPackageUnit> newPackageUnits; |
1030 |
|
| 1031 |
|
1031 |
public CommitTransactionResult commitTransaction( |
| 1032 |
public InvalidationEvent(InternalCDOView view, long timeStamp, Collection<CDOPackageUnit> packageUnits, |
1032 |
InternalCDOCommitContext commitContext, OMMonitor monitor) { |
| 1033 |
Set<CDOIDAndVersion> dirtyOIDs, Collection<CDOID> detachedObjects) |
1033 |
int attempt = 0; |
| 1034 |
{ |
1034 |
for (;;) { |
| 1035 |
super(CDOSessionImpl.this); |
1035 |
try { |
| 1036 |
this.view = view; |
1036 |
return delegate.commitTransaction(commitContext, monitor); |
| 1037 |
this.timeStamp = timeStamp; |
1037 |
} catch (Exception ex) { |
| 1038 |
newPackageUnits = packageUnits; |
1038 |
handleException(++attempt, ex); |
| 1039 |
this.dirtyOIDs = dirtyOIDs; |
1039 |
} |
| 1040 |
this.detachedObjects = detachedObjects; |
1040 |
} |
| 1041 |
} |
1041 |
} |
| 1042 |
|
1042 |
|
| 1043 |
@Override |
1043 |
public CommitTransactionResult commitTransactionCancel( |
| 1044 |
public CDOSession getSource() |
1044 |
InternalCDOXACommitContext xaContext, OMMonitor monitor) { |
| 1045 |
{ |
1045 |
int attempt = 0; |
| 1046 |
return (CDOSession)super.getSource(); |
1046 |
for (;;) { |
| 1047 |
} |
1047 |
try { |
| 1048 |
|
1048 |
return delegate.commitTransactionCancel(xaContext, monitor); |
| 1049 |
public InternalCDOView getView() |
1049 |
} catch (Exception ex) { |
| 1050 |
{ |
1050 |
handleException(++attempt, ex); |
| 1051 |
return view; |
1051 |
} |
| 1052 |
} |
1052 |
} |
| 1053 |
|
1053 |
} |
| 1054 |
public boolean isRemote() |
1054 |
|
| 1055 |
{ |
1055 |
public CommitTransactionResult commitTransactionPhase1( |
| 1056 |
return view == null; |
1056 |
InternalCDOXACommitContext xaContext, OMMonitor monitor) { |
| 1057 |
} |
1057 |
int attempt = 0; |
| 1058 |
|
1058 |
for (;;) { |
| 1059 |
public long getTimeStamp() |
1059 |
try { |
| 1060 |
{ |
1060 |
return delegate.commitTransactionPhase1(xaContext, monitor); |
| 1061 |
return timeStamp; |
1061 |
} catch (Exception ex) { |
| 1062 |
} |
1062 |
handleException(++attempt, ex); |
| 1063 |
|
1063 |
} |
| 1064 |
public Set<CDOIDAndVersion> getDirtyOIDs() |
1064 |
} |
| 1065 |
{ |
1065 |
} |
| 1066 |
return dirtyOIDs; |
1066 |
|
| 1067 |
} |
1067 |
public CommitTransactionResult commitTransactionPhase2( |
| 1068 |
|
1068 |
InternalCDOXACommitContext xaContext, OMMonitor monitor) { |
| 1069 |
public Collection<CDOID> getDetachedObjects() |
1069 |
int attempt = 0; |
| 1070 |
{ |
1070 |
for (;;) { |
| 1071 |
return detachedObjects; |
1071 |
try { |
| 1072 |
} |
1072 |
return delegate.commitTransactionPhase2(xaContext, monitor); |
| 1073 |
|
1073 |
} catch (Exception ex) { |
| 1074 |
public Collection<CDOPackageUnit> getNewPackageUnits() |
1074 |
handleException(++attempt, ex); |
| 1075 |
{ |
1075 |
} |
| 1076 |
return newPackageUnits; |
1076 |
} |
| 1077 |
} |
1077 |
} |
| 1078 |
|
1078 |
|
| 1079 |
@Override |
1079 |
public CommitTransactionResult commitTransactionPhase3( |
| 1080 |
public String toString() |
1080 |
InternalCDOXACommitContext xaContext, OMMonitor monitor) { |
| 1081 |
{ |
1081 |
int attempt = 0; |
| 1082 |
return "CDOSessionInvalidationEvent: " + dirtyOIDs; |
1082 |
for (;;) { |
| 1083 |
} |
1083 |
try { |
| 1084 |
} |
1084 |
return delegate.commitTransactionPhase3(xaContext, monitor); |
| 1085 |
|
1085 |
} catch (Exception ex) { |
| 1086 |
/** |
1086 |
handleException(++attempt, ex); |
| 1087 |
* @author Eike Stepper |
1087 |
} |
| 1088 |
*/ |
1088 |
} |
| 1089 |
public class DelegatingSessionProtocol extends Lifecycle implements CDOSessionProtocol |
1089 |
} |
| 1090 |
{ |
1090 |
|
| 1091 |
private CDOSessionProtocol delegate; |
1091 |
public RepositoryTimeResult getRepositoryTime() { |
| 1092 |
|
1092 |
int attempt = 0; |
| 1093 |
@ExcludeFromDump |
1093 |
for (;;) { |
| 1094 |
private IListener delegateListener = new LifecycleEventAdapter() |
1094 |
try { |
| 1095 |
{ |
1095 |
return delegate.getRepositoryTime(); |
| 1096 |
@Override |
1096 |
} catch (Exception ex) { |
| 1097 |
protected void onDeactivated(ILifecycle lifecycle) |
1097 |
handleException(++attempt, ex); |
| 1098 |
{ |
1098 |
} |
| 1099 |
DelegatingSessionProtocol.this.deactivate(); |
1099 |
} |
| 1100 |
} |
1100 |
} |
| 1101 |
}; |
1101 |
|
| 1102 |
|
1102 |
public boolean isObjectLocked(CDOView view, CDOObject object, |
| 1103 |
public DelegatingSessionProtocol(CDOSessionProtocol delegate) |
1103 |
LockType lockType, boolean byOthers) { |
| 1104 |
{ |
1104 |
int attempt = 0; |
| 1105 |
this.delegate = delegate; |
1105 |
for (;;) { |
| 1106 |
activate(); |
1106 |
try { |
| 1107 |
} |
1107 |
return delegate.isObjectLocked(view, object, lockType, |
| 1108 |
|
1108 |
byOthers); |
| 1109 |
public CDOSessionProtocol getDelegate() |
1109 |
} catch (Exception ex) { |
| 1110 |
{ |
1110 |
handleException(++attempt, ex); |
| 1111 |
return delegate; |
1111 |
} |
| 1112 |
} |
1112 |
} |
| 1113 |
|
1113 |
} |
| 1114 |
public CDOSession getSession() |
1114 |
|
| 1115 |
{ |
1115 |
public EPackage[] loadPackages(CDOPackageUnit packageUnit) { |
| 1116 |
return (CDOSession)delegate.getSession(); |
1116 |
int attempt = 0; |
| 1117 |
} |
1117 |
for (;;) { |
| 1118 |
|
1118 |
try { |
| 1119 |
public boolean cancelQuery(int queryId) |
1119 |
return delegate.loadPackages(packageUnit); |
| 1120 |
{ |
1120 |
} catch (Exception ex) { |
| 1121 |
int attempt = 0; |
1121 |
handleException(++attempt, ex); |
| 1122 |
for (;;) |
1122 |
} |
| 1123 |
{ |
1123 |
} |
| 1124 |
try |
1124 |
} |
| 1125 |
{ |
1125 |
|
| 1126 |
return delegate.cancelQuery(queryId); |
1126 |
public Object loadChunk(InternalCDORevision revision, |
| 1127 |
} |
1127 |
EStructuralFeature feature, int accessIndex, int fetchIndex, |
| 1128 |
catch (Exception ex) |
1128 |
int fromIndex, int toIndex) { |
| 1129 |
{ |
1129 |
int attempt = 0; |
| 1130 |
handleException(++attempt, ex); |
1130 |
for (;;) { |
| 1131 |
} |
1131 |
try { |
| 1132 |
} |
1132 |
return delegate.loadChunk(revision, feature, accessIndex, |
| 1133 |
} |
1133 |
fetchIndex, fromIndex, toIndex); |
| 1134 |
|
1134 |
} catch (Exception ex) { |
| 1135 |
public void changeSubscription(int viewId, List<CDOID> cdoIDs, boolean subscribeMode, boolean clear) |
1135 |
handleException(++attempt, ex); |
| 1136 |
{ |
1136 |
} |
| 1137 |
int attempt = 0; |
1137 |
} |
| 1138 |
for (;;) |
1138 |
} |
| 1139 |
{ |
1139 |
|
| 1140 |
try |
1140 |
public InternalCDORevision loadRevision(CDOID id, int referenceChunk, |
| 1141 |
{ |
1141 |
int prefetchDepth) { |
| 1142 |
delegate.changeSubscription(viewId, cdoIDs, subscribeMode, clear); |
1142 |
int attempt = 0; |
| 1143 |
return; |
1143 |
for (;;) { |
| 1144 |
} |
1144 |
try { |
| 1145 |
catch (Exception ex) |
1145 |
return delegate.loadRevision(id, referenceChunk, |
| 1146 |
{ |
1146 |
prefetchDepth); |
| 1147 |
handleException(++attempt, ex); |
1147 |
} catch (Exception ex) { |
| 1148 |
} |
1148 |
handleException(++attempt, ex); |
| 1149 |
} |
1149 |
} |
| 1150 |
} |
1150 |
} |
| 1151 |
|
1151 |
} |
| 1152 |
public void closeView(int viewId) |
1152 |
|
| 1153 |
{ |
1153 |
public InternalCDORevision loadRevisionByTime(CDOID id, |
| 1154 |
int attempt = 0; |
1154 |
int referenceChunk, int prefetchDepth, long timeStamp) { |
| 1155 |
for (;;) |
1155 |
int attempt = 0; |
| 1156 |
{ |
1156 |
for (;;) { |
| 1157 |
try |
1157 |
try { |
| 1158 |
{ |
1158 |
return delegate.loadRevisionByTime(id, referenceChunk, |
| 1159 |
delegate.closeView(viewId); |
1159 |
prefetchDepth, timeStamp); |
| 1160 |
return; |
1160 |
} catch (Exception ex) { |
| 1161 |
} |
1161 |
handleException(++attempt, ex); |
| 1162 |
catch (Exception ex) |
1162 |
} |
| 1163 |
{ |
1163 |
} |
| 1164 |
handleException(++attempt, ex); |
1164 |
} |
| 1165 |
} |
1165 |
|
| 1166 |
} |
1166 |
public InternalCDORevision loadRevisionByVersion(CDOID id, |
| 1167 |
} |
1167 |
int referenceChunk, int prefetchDepth, int version) { |
| 1168 |
|
1168 |
int attempt = 0; |
| 1169 |
public CommitTransactionResult commitTransaction(InternalCDOCommitContext commitContext, OMMonitor monitor) |
1169 |
for (;;) { |
| 1170 |
{ |
1170 |
try { |
| 1171 |
int attempt = 0; |
1171 |
return delegate.loadRevisionByVersion(id, referenceChunk, |
| 1172 |
for (;;) |
1172 |
prefetchDepth, version); |
| 1173 |
{ |
1173 |
} catch (Exception ex) { |
| 1174 |
try |
1174 |
handleException(++attempt, ex); |
| 1175 |
{ |
1175 |
} |
| 1176 |
return delegate.commitTransaction(commitContext, monitor); |
1176 |
} |
| 1177 |
} |
1177 |
} |
| 1178 |
catch (Exception ex) |
1178 |
|
| 1179 |
{ |
1179 |
public List<InternalCDORevision> loadRevisions(Collection<CDOID> ids, |
| 1180 |
handleException(++attempt, ex); |
1180 |
int referenceChunk, int prefetchDepth) { |
| 1181 |
} |
1181 |
int attempt = 0; |
| 1182 |
} |
1182 |
for (;;) { |
| 1183 |
} |
1183 |
try { |
| 1184 |
|
1184 |
return delegate.loadRevisions(ids, referenceChunk, |
| 1185 |
public CommitTransactionResult commitTransactionCancel(InternalCDOXACommitContext xaContext, OMMonitor monitor) |
1185 |
prefetchDepth); |
| 1186 |
{ |
1186 |
} catch (Exception ex) { |
| 1187 |
int attempt = 0; |
1187 |
handleException(++attempt, ex); |
| 1188 |
for (;;) |
1188 |
} |
| 1189 |
{ |
1189 |
} |
| 1190 |
try |
1190 |
} |
| 1191 |
{ |
1191 |
|
| 1192 |
return delegate.commitTransactionCancel(xaContext, monitor); |
1192 |
public List<InternalCDORevision> loadRevisionsByTime( |
| 1193 |
} |
1193 |
Collection<CDOID> ids, int referenceChunk, int prefetchDepth, |
| 1194 |
catch (Exception ex) |
1194 |
long timeStamp) { |
| 1195 |
{ |
1195 |
int attempt = 0; |
| 1196 |
handleException(++attempt, ex); |
1196 |
for (;;) { |
| 1197 |
} |
1197 |
try { |
| 1198 |
} |
1198 |
return delegate.loadRevisionsByTime(ids, referenceChunk, |
| 1199 |
} |
1199 |
prefetchDepth, timeStamp); |
| 1200 |
|
1200 |
} catch (Exception ex) { |
| 1201 |
public CommitTransactionResult commitTransactionPhase1(InternalCDOXACommitContext xaContext, OMMonitor monitor) |
1201 |
handleException(++attempt, ex); |
| 1202 |
{ |
1202 |
} |
| 1203 |
int attempt = 0; |
1203 |
} |
| 1204 |
for (;;) |
1204 |
} |
| 1205 |
{ |
1205 |
|
| 1206 |
try |
1206 |
public InternalCDORevision verifyRevision(InternalCDORevision revision, |
| 1207 |
{ |
1207 |
int referenceChunk) { |
| 1208 |
return delegate.commitTransactionPhase1(xaContext, monitor); |
1208 |
int attempt = 0; |
| 1209 |
} |
1209 |
for (;;) { |
| 1210 |
catch (Exception ex) |
1210 |
try { |
| 1211 |
{ |
1211 |
return delegate.verifyRevision(revision, referenceChunk); |
| 1212 |
handleException(++attempt, ex); |
1212 |
} catch (Exception ex) { |
| 1213 |
} |
1213 |
handleException(++attempt, ex); |
| 1214 |
} |
1214 |
} |
| 1215 |
} |
1215 |
} |
| 1216 |
|
1216 |
} |
| 1217 |
public CommitTransactionResult commitTransactionPhase2(InternalCDOXACommitContext xaContext, OMMonitor monitor) |
1217 |
|
| 1218 |
{ |
1218 |
public void lockObjects(CDOView view, |
| 1219 |
int attempt = 0; |
1219 |
Map<CDOID, CDOIDAndVersion> objects, long timeout, |
| 1220 |
for (;;) |
1220 |
LockType lockType) throws InterruptedException { |
| 1221 |
{ |
1221 |
int attempt = 0; |
| 1222 |
try |
1222 |
for (;;) { |
| 1223 |
{ |
1223 |
try { |
| 1224 |
return delegate.commitTransactionPhase2(xaContext, monitor); |
1224 |
delegate.lockObjects(view, objects, timeout, lockType); |
| 1225 |
} |
1225 |
return; |
| 1226 |
catch (Exception ex) |
1226 |
} catch (Exception ex) { |
| 1227 |
{ |
1227 |
handleException(++attempt, ex); |
| 1228 |
handleException(++attempt, ex); |
1228 |
} |
| 1229 |
} |
1229 |
} |
| 1230 |
} |
1230 |
} |
| 1231 |
} |
1231 |
|
| 1232 |
|
1232 |
public void openView(int viewId, CDOCommonView.Type viewType, |
| 1233 |
public CommitTransactionResult commitTransactionPhase3(InternalCDOXACommitContext xaContext, OMMonitor monitor) |
1233 |
long timeStamp) { |
| 1234 |
{ |
1234 |
int attempt = 0; |
| 1235 |
int attempt = 0; |
1235 |
for (;;) { |
| 1236 |
for (;;) |
1236 |
try { |
| 1237 |
{ |
1237 |
delegate.openView(viewId, viewType, timeStamp); |
| 1238 |
try |
1238 |
return; |
| 1239 |
{ |
1239 |
} catch (Exception ex) { |
| 1240 |
return delegate.commitTransactionPhase3(xaContext, monitor); |
1240 |
handleException(++attempt, ex); |
| 1241 |
} |
1241 |
} |
| 1242 |
catch (Exception ex) |
1242 |
} |
| 1243 |
{ |
1243 |
} |
| 1244 |
handleException(++attempt, ex); |
1244 |
|
| 1245 |
} |
1245 |
public void query(int viewID, AbstractQueryIterator<?> queryResult) { |
| 1246 |
} |
1246 |
int attempt = 0; |
| 1247 |
} |
1247 |
for (;;) { |
| 1248 |
|
1248 |
try { |
| 1249 |
public RepositoryTimeResult getRepositoryTime() |
1249 |
delegate.query(viewID, queryResult); |
| 1250 |
{ |
1250 |
return; |
| 1251 |
int attempt = 0; |
1251 |
} catch (Exception ex) { |
| 1252 |
for (;;) |
1252 |
handleException(++attempt, ex); |
| 1253 |
{ |
1253 |
} |
| 1254 |
try |
1254 |
} |
| 1255 |
{ |
1255 |
} |
| 1256 |
return delegate.getRepositoryTime(); |
1256 |
|
| 1257 |
} |
1257 |
public boolean[] setAudit(int viewId, long timeStamp, |
| 1258 |
catch (Exception ex) |
1258 |
List<InternalCDOObject> invalidObjects) { |
| 1259 |
{ |
1259 |
int attempt = 0; |
| 1260 |
handleException(++attempt, ex); |
1260 |
for (;;) { |
| 1261 |
} |
1261 |
try { |
| 1262 |
} |
1262 |
return delegate.setAudit(viewId, timeStamp, invalidObjects); |
| 1263 |
} |
1263 |
} catch (Exception ex) { |
| 1264 |
|
1264 |
handleException(++attempt, ex); |
| 1265 |
public boolean isObjectLocked(CDOView view, CDOObject object, LockType lockType, boolean byOthers) |
1265 |
} |
| 1266 |
{ |
1266 |
} |
| 1267 |
int attempt = 0; |
1267 |
} |
| 1268 |
for (;;) |
1268 |
|
| 1269 |
{ |
1269 |
public void setPassiveUpdate(Map<CDOID, CDOIDAndVersion> idAndVersions, |
| 1270 |
try |
1270 |
int initialChunkSize, boolean passiveUpdateEnabled) { |
| 1271 |
{ |
1271 |
int attempt = 0; |
| 1272 |
return delegate.isObjectLocked(view, object, lockType, byOthers); |
1272 |
for (;;) { |
| 1273 |
} |
1273 |
try { |
| 1274 |
catch (Exception ex) |
1274 |
delegate.setPassiveUpdate(idAndVersions, initialChunkSize, |
| 1275 |
{ |
1275 |
passiveUpdateEnabled); |
| 1276 |
handleException(++attempt, ex); |
1276 |
return; |
| 1277 |
} |
1277 |
} catch (Exception ex) { |
| 1278 |
} |
1278 |
handleException(++attempt, ex); |
| 1279 |
} |
1279 |
} |
| 1280 |
|
1280 |
} |
| 1281 |
public EPackage[] loadPackages(CDOPackageUnit packageUnit) |
1281 |
} |
| 1282 |
{ |
1282 |
|
| 1283 |
int attempt = 0; |
1283 |
public Collection<CDOTimeStampContext> syncRevisions( |
| 1284 |
for (;;) |
1284 |
Map<CDOID, CDOIDAndVersion> allRevisions, int initialChunkSize) { |
| 1285 |
{ |
1285 |
int attempt = 0; |
| 1286 |
try |
1286 |
for (;;) { |
| 1287 |
{ |
1287 |
try { |
| 1288 |
return delegate.loadPackages(packageUnit); |
1288 |
return delegate.syncRevisions(allRevisions, |
| 1289 |
} |
1289 |
initialChunkSize); |
| 1290 |
catch (Exception ex) |
1290 |
} catch (Exception ex) { |
| 1291 |
{ |
1291 |
handleException(++attempt, ex); |
| 1292 |
handleException(++attempt, ex); |
1292 |
} |
| 1293 |
} |
1293 |
} |
| 1294 |
} |
1294 |
} |
| 1295 |
} |
1295 |
|
| 1296 |
|
1296 |
public void unlockObjects(CDOView view, |
| 1297 |
public Object loadChunk(InternalCDORevision revision, EStructuralFeature feature, int accessIndex, int fetchIndex, |
1297 |
Collection<? extends CDOObject> objects, LockType lockType) { |
| 1298 |
int fromIndex, int toIndex) |
1298 |
int attempt = 0; |
| 1299 |
{ |
1299 |
for (;;) { |
| 1300 |
int attempt = 0; |
1300 |
try { |
| 1301 |
for (;;) |
1301 |
delegate.unlockObjects(view, objects, lockType); |
| 1302 |
{ |
1302 |
return; |
| 1303 |
try |
1303 |
} catch (Exception ex) { |
| 1304 |
{ |
1304 |
handleException(++attempt, ex); |
| 1305 |
return delegate.loadChunk(revision, feature, accessIndex, fetchIndex, fromIndex, toIndex); |
1305 |
} |
| 1306 |
} |
1306 |
} |
| 1307 |
catch (Exception ex) |
1307 |
} |
| 1308 |
{ |
1308 |
|
| 1309 |
handleException(++attempt, ex); |
1309 |
public List<CDORemoteSession> getRemoteSessions( |
| 1310 |
} |
1310 |
InternalCDORemoteSessionManager manager, boolean subscribe) { |
| 1311 |
} |
1311 |
int attempt = 0; |
| 1312 |
} |
1312 |
for (;;) { |
| 1313 |
|
1313 |
try { |
| 1314 |
public InternalCDORevision loadRevision(CDOID id, int referenceChunk, int prefetchDepth) |
1314 |
return delegate.getRemoteSessions(manager, subscribe); |
| 1315 |
{ |
1315 |
} catch (Exception ex) { |
| 1316 |
int attempt = 0; |
1316 |
handleException(++attempt, ex); |
| 1317 |
for (;;) |
1317 |
} |
| 1318 |
{ |
1318 |
} |
| 1319 |
try |
1319 |
} |
| 1320 |
{ |
1320 |
|
| 1321 |
return delegate.loadRevision(id, referenceChunk, prefetchDepth); |
1321 |
public Set<Integer> sendRemoteMessage(CDORemoteSessionMessage message, |
| 1322 |
} |
1322 |
List<CDORemoteSession> recipients) { |
| 1323 |
catch (Exception ex) |
1323 |
int attempt = 0; |
| 1324 |
{ |
1324 |
for (;;) { |
| 1325 |
handleException(++attempt, ex); |
1325 |
try { |
| 1326 |
} |
1326 |
return delegate.sendRemoteMessage(message, recipients); |
| 1327 |
} |
1327 |
} catch (Exception ex) { |
| 1328 |
} |
1328 |
handleException(++attempt, ex); |
| 1329 |
|
1329 |
} |
| 1330 |
public InternalCDORevision loadRevisionByTime(CDOID id, int referenceChunk, int prefetchDepth, long timeStamp) |
1330 |
} |
| 1331 |
{ |
1331 |
} |
| 1332 |
int attempt = 0; |
1332 |
|
| 1333 |
for (;;) |
1333 |
public boolean unsubscribeRemoteSessions() { |
| 1334 |
{ |
1334 |
int attempt = 0; |
| 1335 |
try |
1335 |
for (;;) { |
| 1336 |
{ |
1336 |
try { |
| 1337 |
return delegate.loadRevisionByTime(id, referenceChunk, prefetchDepth, timeStamp); |
1337 |
return delegate.unsubscribeRemoteSessions(); |
| 1338 |
} |
1338 |
} catch (Exception ex) { |
| 1339 |
catch (Exception ex) |
1339 |
handleException(++attempt, ex); |
| 1340 |
{ |
1340 |
} |
| 1341 |
handleException(++attempt, ex); |
1341 |
} |
| 1342 |
} |
1342 |
} |
| 1343 |
} |
1343 |
|
| 1344 |
} |
1344 |
@Override |
| 1345 |
|
1345 |
protected void doActivate() throws Exception { |
| 1346 |
public InternalCDORevision loadRevisionByVersion(CDOID id, int referenceChunk, int prefetchDepth, int version) |
1346 |
super.doActivate(); |
| 1347 |
{ |
1347 |
EventUtil.addListener(delegate, delegateListener); |
| 1348 |
int attempt = 0; |
1348 |
} |
| 1349 |
for (;;) |
1349 |
|
| 1350 |
{ |
1350 |
@Override |
| 1351 |
try |
1351 |
protected void doDeactivate() throws Exception { |
| 1352 |
{ |
1352 |
EventUtil.removeListener(delegate, delegateListener); |
| 1353 |
return delegate.loadRevisionByVersion(id, referenceChunk, prefetchDepth, version); |
1353 |
LifecycleUtil.deactivate(delegate); |
| 1354 |
} |
1354 |
delegate = null; |
| 1355 |
catch (Exception ex) |
1355 |
super.doDeactivate(); |
| 1356 |
{ |
1356 |
} |
| 1357 |
handleException(++attempt, ex); |
1357 |
|
| 1358 |
} |
1358 |
private void handleException(int attempt, Exception exception) { |
| 1359 |
} |
1359 |
try { |
| 1360 |
} |
1360 |
getExceptionHandler().handleException(CDOSessionImpl.this, |
| 1361 |
|
1361 |
attempt, exception); |
| 1362 |
public List<InternalCDORevision> loadRevisions(Collection<CDOID> ids, int referenceChunk, int prefetchDepth) |
1362 |
} catch (Exception ex) { |
| 1363 |
{ |
1363 |
throw WrappedException.wrap(ex); |
| 1364 |
int attempt = 0; |
1364 |
} |
| 1365 |
for (;;) |
1365 |
} |
| 1366 |
{ |
1366 |
} |
| 1367 |
try |
1367 |
|
| 1368 |
{ |
|
|
| 1369 |
return delegate.loadRevisions(ids, referenceChunk, prefetchDepth); |
| 1370 |
} |
| 1371 |
catch (Exception ex) |
| 1372 |
{ |
| 1373 |
handleException(++attempt, ex); |
| 1374 |
} |
| 1375 |
} |
| 1376 |
} |
| 1377 |
|
| 1378 |
public List<InternalCDORevision> loadRevisionsByTime(Collection<CDOID> ids, int referenceChunk, int prefetchDepth, |
| 1379 |
long timeStamp) |
| 1380 |
{ |
| 1381 |
int attempt = 0; |
| 1382 |
for (;;) |
| 1383 |
{ |
| 1384 |
try |
| 1385 |
{ |
| 1386 |
return delegate.loadRevisionsByTime(ids, referenceChunk, prefetchDepth, timeStamp); |
| 1387 |
} |
| 1388 |
catch (Exception ex) |
| 1389 |
{ |
| 1390 |
handleException(++attempt, ex); |
| 1391 |
} |
| 1392 |
} |
| 1393 |
} |
| 1394 |
|
| 1395 |
public InternalCDORevision verifyRevision(InternalCDORevision revision, int referenceChunk) |
| 1396 |
{ |
| 1397 |
int attempt = 0; |
| 1398 |
for (;;) |
| 1399 |
{ |
| 1400 |
try |
| 1401 |
{ |
| 1402 |
return delegate.verifyRevision(revision, referenceChunk); |
| 1403 |
} |
| 1404 |
catch (Exception ex) |
| 1405 |
{ |
| 1406 |
handleException(++attempt, ex); |
| 1407 |
} |
| 1408 |
} |
| 1409 |
} |
| 1410 |
|
| 1411 |
public void lockObjects(CDOView view, Map<CDOID, CDOIDAndVersion> objects, long timeout, LockType lockType) |
| 1412 |
throws InterruptedException |
| 1413 |
{ |
| 1414 |
int attempt = 0; |
| 1415 |
for (;;) |
| 1416 |
{ |
| 1417 |
try |
| 1418 |
{ |
| 1419 |
delegate.lockObjects(view, objects, timeout, lockType); |
| 1420 |
return; |
| 1421 |
} |
| 1422 |
catch (Exception ex) |
| 1423 |
{ |
| 1424 |
handleException(++attempt, ex); |
| 1425 |
} |
| 1426 |
} |
| 1427 |
} |
| 1428 |
|
| 1429 |
public void openView(int viewId, CDOCommonView.Type viewType, long timeStamp) |
| 1430 |
{ |
| 1431 |
int attempt = 0; |
| 1432 |
for (;;) |
| 1433 |
{ |
| 1434 |
try |
| 1435 |
{ |
| 1436 |
delegate.openView(viewId, viewType, timeStamp); |
| 1437 |
return; |
| 1438 |
} |
| 1439 |
catch (Exception ex) |
| 1440 |
{ |
| 1441 |
handleException(++attempt, ex); |
| 1442 |
} |
| 1443 |
} |
| 1444 |
} |
| 1445 |
|
| 1446 |
public void query(int viewID, AbstractQueryIterator<?> queryResult) |
| 1447 |
{ |
| 1448 |
int attempt = 0; |
| 1449 |
for (;;) |
| 1450 |
{ |
| 1451 |
try |
| 1452 |
{ |
| 1453 |
delegate.query(viewID, queryResult); |
| 1454 |
return; |
| 1455 |
} |
| 1456 |
catch (Exception ex) |
| 1457 |
{ |
| 1458 |
handleException(++attempt, ex); |
| 1459 |
} |
| 1460 |
} |
| 1461 |
} |
| 1462 |
|
| 1463 |
public boolean[] setAudit(int viewId, long timeStamp, List<InternalCDOObject> invalidObjects) |
| 1464 |
{ |
| 1465 |
int attempt = 0; |
| 1466 |
for (;;) |
| 1467 |
{ |
| 1468 |
try |
| 1469 |
{ |
| 1470 |
return delegate.setAudit(viewId, timeStamp, invalidObjects); |
| 1471 |
} |
| 1472 |
catch (Exception ex) |
| 1473 |
{ |
| 1474 |
handleException(++attempt, ex); |
| 1475 |
} |
| 1476 |
} |
| 1477 |
} |
| 1478 |
|
| 1479 |
public void setPassiveUpdate(Map<CDOID, CDOIDAndVersion> idAndVersions, int initialChunkSize, |
| 1480 |
boolean passiveUpdateEnabled) |
| 1481 |
{ |
| 1482 |
int attempt = 0; |
| 1483 |
for (;;) |
| 1484 |
{ |
| 1485 |
try |
| 1486 |
{ |
| 1487 |
delegate.setPassiveUpdate(idAndVersions, initialChunkSize, passiveUpdateEnabled); |
| 1488 |
return; |
| 1489 |
} |
| 1490 |
catch (Exception ex) |
| 1491 |
{ |
| 1492 |
handleException(++attempt, ex); |
| 1493 |
} |
| 1494 |
} |
| 1495 |
} |
| 1496 |
|
| 1497 |
public Collection<CDOTimeStampContext> syncRevisions(Map<CDOID, CDOIDAndVersion> allRevisions, int initialChunkSize) |
| 1498 |
{ |
| 1499 |
int attempt = 0; |
| 1500 |
for (;;) |
| 1501 |
{ |
| 1502 |
try |
| 1503 |
{ |
| 1504 |
return delegate.syncRevisions(allRevisions, initialChunkSize); |
| 1505 |
} |
| 1506 |
catch (Exception ex) |
| 1507 |
{ |
| 1508 |
handleException(++attempt, ex); |
| 1509 |
} |
| 1510 |
} |
| 1511 |
} |
| 1512 |
|
| 1513 |
public void unlockObjects(CDOView view, Collection<? extends CDOObject> objects, LockType lockType) |
| 1514 |
{ |
| 1515 |
int attempt = 0; |
| 1516 |
for (;;) |
| 1517 |
{ |
| 1518 |
try |
| 1519 |
{ |
| 1520 |
delegate.unlockObjects(view, objects, lockType); |
| 1521 |
return; |
| 1522 |
} |
| 1523 |
catch (Exception ex) |
| 1524 |
{ |
| 1525 |
handleException(++attempt, ex); |
| 1526 |
} |
| 1527 |
} |
| 1528 |
} |
| 1529 |
|
| 1530 |
public List<CDORemoteSession> getRemoteSessions(InternalCDORemoteSessionManager manager, boolean subscribe) |
| 1531 |
{ |
| 1532 |
int attempt = 0; |
| 1533 |
for (;;) |
| 1534 |
{ |
| 1535 |
try |
| 1536 |
{ |
| 1537 |
return delegate.getRemoteSessions(manager, subscribe); |
| 1538 |
} |
| 1539 |
catch (Exception ex) |
| 1540 |
{ |
| 1541 |
handleException(++attempt, ex); |
| 1542 |
} |
| 1543 |
} |
| 1544 |
} |
| 1545 |
|
| 1546 |
public Set<Integer> sendRemoteMessage(CDORemoteSessionMessage message, List<CDORemoteSession> recipients) |
| 1547 |
{ |
| 1548 |
int attempt = 0; |
| 1549 |
for (;;) |
| 1550 |
{ |
| 1551 |
try |
| 1552 |
{ |
| 1553 |
return delegate.sendRemoteMessage(message, recipients); |
| 1554 |
} |
| 1555 |
catch (Exception ex) |
| 1556 |
{ |
| 1557 |
handleException(++attempt, ex); |
| 1558 |
} |
| 1559 |
} |
| 1560 |
} |
| 1561 |
|
| 1562 |
public boolean unsubscribeRemoteSessions() |
| 1563 |
{ |
| 1564 |
int attempt = 0; |
| 1565 |
for (;;) |
| 1566 |
{ |
| 1567 |
try |
| 1568 |
{ |
| 1569 |
return delegate.unsubscribeRemoteSessions(); |
| 1570 |
} |
| 1571 |
catch (Exception ex) |
| 1572 |
{ |
| 1573 |
handleException(++attempt, ex); |
| 1574 |
} |
| 1575 |
} |
| 1576 |
} |
| 1577 |
|
| 1578 |
@Override |
| 1579 |
protected void doActivate() throws Exception |
| 1580 |
{ |
| 1581 |
super.doActivate(); |
| 1582 |
EventUtil.addListener(delegate, delegateListener); |
| 1583 |
} |
| 1584 |
|
| 1585 |
@Override |
| 1586 |
protected void doDeactivate() throws Exception |
| 1587 |
{ |
| 1588 |
EventUtil.removeListener(delegate, delegateListener); |
| 1589 |
LifecycleUtil.deactivate(delegate); |
| 1590 |
delegate = null; |
| 1591 |
super.doDeactivate(); |
| 1592 |
} |
| 1593 |
|
| 1594 |
private void handleException(int attempt, Exception exception) |
| 1595 |
{ |
| 1596 |
try |
| 1597 |
{ |
| 1598 |
getExceptionHandler().handleException(CDOSessionImpl.this, attempt, exception); |
| 1599 |
} |
| 1600 |
catch (Exception ex) |
| 1601 |
{ |
| 1602 |
throw WrappedException.wrap(ex); |
| 1603 |
} |
| 1604 |
} |
| 1605 |
} |
| 1606 |
} |
1368 |
} |