|
Lines 12-18
Link Here
|
| 12 |
**************************************************************************/ |
12 |
**************************************************************************/ |
| 13 |
package org.eclipse.emf.internal.cdo; |
13 |
package org.eclipse.emf.internal.cdo; |
| 14 |
|
14 |
|
| 15 |
import org.eclipse.emf.cdo.CDOChangeSubscriptionPolicy; |
15 |
import org.eclipse.emf.cdo.CDOAdapterPolicy; |
| 16 |
import org.eclipse.emf.cdo.CDOFeatureAnalyzer; |
16 |
import org.eclipse.emf.cdo.CDOFeatureAnalyzer; |
| 17 |
import org.eclipse.emf.cdo.CDONotification; |
17 |
import org.eclipse.emf.cdo.CDONotification; |
| 18 |
import org.eclipse.emf.cdo.CDOObject; |
18 |
import org.eclipse.emf.cdo.CDOObject; |
|
Lines 64-69
Link Here
|
| 64 |
import org.eclipse.net4j.util.WrappedException; |
64 |
import org.eclipse.net4j.util.WrappedException; |
| 65 |
import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump; |
65 |
import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump; |
| 66 |
import org.eclipse.net4j.util.collection.CloseableIterator; |
66 |
import org.eclipse.net4j.util.collection.CloseableIterator; |
|
|
67 |
import org.eclipse.net4j.util.collection.HashBag; |
| 67 |
import org.eclipse.net4j.util.concurrent.RWLockManager; |
68 |
import org.eclipse.net4j.util.concurrent.RWLockManager; |
| 68 |
import org.eclipse.net4j.util.om.trace.ContextTracer; |
69 |
import org.eclipse.net4j.util.om.trace.ContextTracer; |
| 69 |
import org.eclipse.net4j.util.ref.ReferenceValueMap; |
70 |
import org.eclipse.net4j.util.ref.ReferenceValueMap; |
|
Lines 133-142
Link Here
|
| 133 |
*/ |
134 |
*/ |
| 134 |
private ChangeSubscriptionManager changeSubscriptionManager = new ChangeSubscriptionManager(); |
135 |
private ChangeSubscriptionManager changeSubscriptionManager = new ChangeSubscriptionManager(); |
| 135 |
|
136 |
|
|
|
137 |
private ViewAdapterManager adapterPolicyManager = null; |
| 138 |
|
| 136 |
/** |
139 |
/** |
| 137 |
* @since 2.0 |
140 |
* @since 2.0 |
| 138 |
*/ |
141 |
*/ |
| 139 |
private CDOChangeSubscriptionPolicy changeSubscriptionPolicy = CDOChangeSubscriptionPolicy.NONE; |
142 |
private CDOAdapterPolicy changeSubscriptionPolicy = CDOAdapterPolicy.NONE; |
|
|
143 |
|
| 144 |
private CDOAdapterPolicy adapterReferencePolicy = CDOAdapterPolicy.NONE; |
| 140 |
|
145 |
|
| 141 |
/** |
146 |
/** |
| 142 |
* @since 2.0 |
147 |
* @since 2.0 |
|
Lines 148-153
Link Here
|
| 148 |
invalidationNotificationEnabled = OM.PREF_ENABLE_INVALIDATION_NOTIFICATION.getValue(); |
153 |
invalidationNotificationEnabled = OM.PREF_ENABLE_INVALIDATION_NOTIFICATION.getValue(); |
| 149 |
revisionPrefetchingPolicy = CDOUtil.createRevisionPrefetchingPolicy(OM.PREF_REVISION_LOADING_CHUNK_SIZE.getValue()); |
154 |
revisionPrefetchingPolicy = CDOUtil.createRevisionPrefetchingPolicy(OM.PREF_REVISION_LOADING_CHUNK_SIZE.getValue()); |
| 150 |
objects = createObjectsMap(); |
155 |
objects = createObjectsMap(); |
|
|
156 |
adapterPolicyManager = createAdapterManager(); |
| 151 |
} |
157 |
} |
| 152 |
|
158 |
|
| 153 |
public int getViewID() |
159 |
public int getViewID() |
|
Lines 337-343
Link Here
|
| 337 |
/** |
343 |
/** |
| 338 |
* @since 2.0 |
344 |
* @since 2.0 |
| 339 |
*/ |
345 |
*/ |
| 340 |
public CDOChangeSubscriptionPolicy getChangeSubscriptionPolicy() |
346 |
public CDOAdapterPolicy getAdapterDeltaNotificationPolicy() |
| 341 |
{ |
347 |
{ |
| 342 |
return changeSubscriptionPolicy; |
348 |
return changeSubscriptionPolicy; |
| 343 |
} |
349 |
} |
|
Lines 345-355
Link Here
|
| 345 |
/** |
351 |
/** |
| 346 |
* @since 2.0 |
352 |
* @since 2.0 |
| 347 |
*/ |
353 |
*/ |
| 348 |
public void setChangeSubscriptionPolicy(CDOChangeSubscriptionPolicy subscriptionPolicy) |
354 |
public void setAdapterDeltaNotificationPolicy(CDOAdapterPolicy subscriptionPolicy) |
| 349 |
{ |
355 |
{ |
| 350 |
if (subscriptionPolicy == null) |
356 |
if (subscriptionPolicy == null) |
| 351 |
{ |
357 |
{ |
| 352 |
subscriptionPolicy = CDOChangeSubscriptionPolicy.NONE; |
358 |
subscriptionPolicy = CDOAdapterPolicy.NONE; |
| 353 |
} |
359 |
} |
| 354 |
|
360 |
|
| 355 |
if (changeSubscriptionPolicy != subscriptionPolicy) |
361 |
if (changeSubscriptionPolicy != subscriptionPolicy) |
|
Lines 362-367
Link Here
|
| 362 |
/** |
368 |
/** |
| 363 |
* @since 2.0 |
369 |
* @since 2.0 |
| 364 |
*/ |
370 |
*/ |
|
|
371 |
public CDOAdapterPolicy getAdapterReferencePolicy() |
| 372 |
{ |
| 373 |
return adapterReferencePolicy; |
| 374 |
} |
| 375 |
|
| 376 |
/** |
| 377 |
* @since 2.0 |
| 378 |
*/ |
| 379 |
public void setAdapterReferencePolicy(CDOAdapterPolicy adapterPolicy) |
| 380 |
{ |
| 381 |
if (adapterPolicy == null) |
| 382 |
{ |
| 383 |
adapterPolicy = CDOAdapterPolicy.NONE; |
| 384 |
} |
| 385 |
|
| 386 |
if (this.adapterReferencePolicy != adapterPolicy) |
| 387 |
{ |
| 388 |
this.adapterReferencePolicy = adapterPolicy; |
| 389 |
adapterPolicyManager.reset(); |
| 390 |
} |
| 391 |
} |
| 392 |
|
| 393 |
/** |
| 394 |
* @since 2.0 |
| 395 |
*/ |
| 365 |
public CDORevisionPrefetchingPolicy getRevisionPrefetchingPolicy() |
396 |
public CDORevisionPrefetchingPolicy getRevisionPrefetchingPolicy() |
| 366 |
{ |
397 |
{ |
| 367 |
return revisionPrefetchingPolicy; |
398 |
return revisionPrefetchingPolicy; |
|
Lines 1211-1217
Link Here
|
| 1211 |
*/ |
1242 |
*/ |
| 1212 |
public void handleChangeSubscription(Collection<CDORevisionDelta> deltas, Collection<CDOID> detachedObjects) |
1243 |
public void handleChangeSubscription(Collection<CDORevisionDelta> deltas, Collection<CDOID> detachedObjects) |
| 1213 |
{ |
1244 |
{ |
| 1214 |
if (getChangeSubscriptionPolicy() != CDOChangeSubscriptionPolicy.NONE) |
1245 |
if (getAdapterDeltaNotificationPolicy() != CDOAdapterPolicy.NONE) |
| 1215 |
{ |
1246 |
{ |
| 1216 |
if (deltas != null) |
1247 |
if (deltas != null) |
| 1217 |
{ |
1248 |
{ |
|
Lines 1251-1256
Link Here
|
| 1251 |
/** |
1282 |
/** |
| 1252 |
* @since 2.0 |
1283 |
* @since 2.0 |
| 1253 |
*/ |
1284 |
*/ |
|
|
1285 |
public void handleAddAdapter(InternalCDOObject eObject, Adapter adapter) |
| 1286 |
{ |
| 1287 |
if (!FSMUtil.isNew(eObject)) |
| 1288 |
{ |
| 1289 |
subscribe(eObject, adapter); |
| 1290 |
} |
| 1291 |
|
| 1292 |
adapterPolicyManager.attachAdapter(eObject, adapter); |
| 1293 |
} |
| 1294 |
|
| 1295 |
/** |
| 1296 |
* @since 2.0 |
| 1297 |
*/ |
| 1298 |
public void handleRemoveAdapter(InternalCDOObject eObject, Adapter adapter) |
| 1299 |
{ |
| 1300 |
if (!FSMUtil.isNew(eObject)) |
| 1301 |
{ |
| 1302 |
unsubscribe(eObject, adapter); |
| 1303 |
} |
| 1304 |
|
| 1305 |
adapterPolicyManager.detachAdapter(eObject, adapter); |
| 1306 |
} |
| 1307 |
|
| 1308 |
/** |
| 1309 |
* @since 2.0 |
| 1310 |
*/ |
| 1254 |
public void subscribe(EObject eObject, Adapter adapter) |
1311 |
public void subscribe(EObject eObject, Adapter adapter) |
| 1255 |
{ |
1312 |
{ |
| 1256 |
changeSubscriptionManager.subscribe(eObject, adapter); |
1313 |
changeSubscriptionManager.subscribe(eObject, adapter); |
|
Lines 1280-1291
Link Here
|
| 1280 |
return changeSubscriptionManager; |
1337 |
return changeSubscriptionManager; |
| 1281 |
} |
1338 |
} |
| 1282 |
|
1339 |
|
|
|
1340 |
/** |
| 1341 |
* @since 2.0 |
| 1342 |
*/ |
| 1343 |
protected ViewAdapterManager getAdapterManager() |
| 1344 |
{ |
| 1345 |
return adapterPolicyManager; |
| 1346 |
} |
| 1347 |
|
| 1283 |
protected ConcurrentMap<CDOID, InternalCDOObject> createObjectsMap() |
1348 |
protected ConcurrentMap<CDOID, InternalCDOObject> createObjectsMap() |
| 1284 |
{ |
1349 |
{ |
| 1285 |
return new ReferenceValueMap.Weak<CDOID, InternalCDOObject>(); |
1350 |
return new ReferenceValueMap.Weak<CDOID, InternalCDOObject>(); |
| 1286 |
} |
1351 |
} |
| 1287 |
|
1352 |
|
| 1288 |
/** |
1353 |
/** |
|
|
1354 |
* @since 2.0 |
| 1355 |
*/ |
| 1356 |
protected ViewAdapterManager createAdapterManager() |
| 1357 |
{ |
| 1358 |
return new ViewAdapterManager(); |
| 1359 |
} |
| 1360 |
|
| 1361 |
/** |
| 1289 |
* Needed for {@link CDOAuditImpl#setTimeStamp(long)}. |
1362 |
* Needed for {@link CDOAuditImpl#setTimeStamp(long)}. |
| 1290 |
* |
1363 |
* |
| 1291 |
* @since 2.0 |
1364 |
* @since 2.0 |
|
Lines 1426-1431
Link Here
|
| 1426 |
* @author Simon McDuff |
1499 |
* @author Simon McDuff |
| 1427 |
* @since 2.0 |
1500 |
* @since 2.0 |
| 1428 |
*/ |
1501 |
*/ |
|
|
1502 |
protected class ViewAdapterManager |
| 1503 |
{ |
| 1504 |
protected Set<CDOObject> objects = new HashBag<CDOObject>(); |
| 1505 |
|
| 1506 |
synchronized protected void attachObject(CDOObject object) |
| 1507 |
{ |
| 1508 |
int count = 0; |
| 1509 |
for (Adapter adapter : object.eAdapters()) |
| 1510 |
{ |
| 1511 |
if (adapterReferencePolicy.valid(object, adapter)) |
| 1512 |
{ |
| 1513 |
count++; |
| 1514 |
} |
| 1515 |
} |
| 1516 |
|
| 1517 |
for (int i = 0; i < count; i++) |
| 1518 |
{ |
| 1519 |
objects.add(object); |
| 1520 |
} |
| 1521 |
|
| 1522 |
} |
| 1523 |
|
| 1524 |
synchronized protected void detachObject(CDOObject object) |
| 1525 |
{ |
| 1526 |
while (objects.remove(object)) |
| 1527 |
{ |
| 1528 |
; |
| 1529 |
} |
| 1530 |
} |
| 1531 |
|
| 1532 |
synchronized protected void attachAdapter(CDOObject object, Adapter adapter) |
| 1533 |
{ |
| 1534 |
if (getAdapterReferencePolicy().valid(object, adapter)) |
| 1535 |
{ |
| 1536 |
objects.add(object); |
| 1537 |
} |
| 1538 |
} |
| 1539 |
|
| 1540 |
synchronized protected void detachAdapter(CDOObject object, Adapter adapter) |
| 1541 |
{ |
| 1542 |
if (getAdapterReferencePolicy().valid(object, adapter)) |
| 1543 |
{ |
| 1544 |
objects.add(object); |
| 1545 |
} |
| 1546 |
} |
| 1547 |
|
| 1548 |
synchronized public void reset() |
| 1549 |
{ |
| 1550 |
// Keep the object in memory |
| 1551 |
Set<CDOObject> oldObject = objects; |
| 1552 |
objects = new HashBag<CDOObject>(); |
| 1553 |
if (getAdapterReferencePolicy() != CDOAdapterPolicy.NONE) |
| 1554 |
{ |
| 1555 |
InternalCDOObject objects[] = getObjectsArray(); |
| 1556 |
for (int i = 0; i < objects.length; i++) |
| 1557 |
{ |
| 1558 |
InternalCDOObject object = objects[i]; |
| 1559 |
attachObject(object); |
| 1560 |
} |
| 1561 |
} |
| 1562 |
oldObject.clear(); |
| 1563 |
} |
| 1564 |
}; |
| 1565 |
|
| 1566 |
/** |
| 1567 |
* @author Simon McDuff |
| 1568 |
* @since 2.0 |
| 1569 |
*/ |
| 1429 |
protected class ChangeSubscriptionManager |
1570 |
protected class ChangeSubscriptionManager |
| 1430 |
{ |
1571 |
{ |
| 1431 |
private Map<CDOID, SubscribeEntry> subscriptions = new HashMap<CDOID, SubscribeEntry>() |
1572 |
private Map<CDOID, SubscribeEntry> subscriptions = new HashMap<CDOID, SubscribeEntry>() |
|
Lines 1452-1458
Link Here
|
| 1452 |
{ |
1593 |
{ |
| 1453 |
subscriptions.clear(); |
1594 |
subscriptions.clear(); |
| 1454 |
List<CDOID> cdoIDs = new ArrayList<CDOID>(); |
1595 |
List<CDOID> cdoIDs = new ArrayList<CDOID>(); |
| 1455 |
if (changeSubscriptionPolicy != CDOChangeSubscriptionPolicy.NONE) |
1596 |
if (changeSubscriptionPolicy != CDOAdapterPolicy.NONE) |
| 1456 |
{ |
1597 |
{ |
| 1457 |
for (InternalCDOObject cdoObject : getObjectsArray()) |
1598 |
for (InternalCDOObject cdoObject : getObjectsArray()) |
| 1458 |
{ |
1599 |
{ |
|
Lines 1539-1545
Link Here
|
| 1539 |
{ |
1680 |
{ |
| 1540 |
for (Adapter adapter : object.eAdapters()) |
1681 |
for (Adapter adapter : object.eAdapters()) |
| 1541 |
{ |
1682 |
{ |
| 1542 |
if (changeSubscriptionPolicy.shouldSubscribe(object, adapter)) |
1683 |
if (changeSubscriptionPolicy.valid(object, adapter)) |
| 1543 |
{ |
1684 |
{ |
| 1544 |
count++; |
1685 |
count++; |
| 1545 |
} |
1686 |
} |
|
Lines 1554-1560
Link Here
|
| 1554 |
{ |
1695 |
{ |
| 1555 |
synchronized (subscriptions) |
1696 |
synchronized (subscriptions) |
| 1556 |
{ |
1697 |
{ |
| 1557 |
if (getChangeSubscriptionPolicy().shouldSubscribe(eObject, adapter)) |
1698 |
if (getAdapterDeltaNotificationPolicy().valid(eObject, adapter)) |
| 1558 |
{ |
1699 |
{ |
| 1559 |
InternalCDOObject internalCDOObject = FSMUtil.adapt(eObject, CDOViewImpl.this); |
1700 |
InternalCDOObject internalCDOObject = FSMUtil.adapt(eObject, CDOViewImpl.this); |
| 1560 |
if (internalCDOObject.cdoView() != CDOViewImpl.this) |
1701 |
if (internalCDOObject.cdoView() != CDOViewImpl.this) |
|
Lines 1582-1588
Link Here
|
| 1582 |
} |
1723 |
} |
| 1583 |
|
1724 |
|
| 1584 |
// Notification need to be enable to send correct value to the server |
1725 |
// Notification need to be enable to send correct value to the server |
| 1585 |
if (getChangeSubscriptionPolicy() != CDOChangeSubscriptionPolicy.NONE) |
1726 |
if (getAdapterDeltaNotificationPolicy() != CDOAdapterPolicy.NONE) |
| 1586 |
{ |
1727 |
{ |
| 1587 |
request(Collections.singletonList(id), false, true); |
1728 |
request(Collections.singletonList(id), false, true); |
| 1588 |
} |
1729 |
} |
|
Lines 1600-1606
Link Here
|
| 1600 |
subscriptions.remove(id); |
1741 |
subscriptions.remove(id); |
| 1601 |
|
1742 |
|
| 1602 |
// Notification need to be enable to send correct value to the server |
1743 |
// Notification need to be enable to send correct value to the server |
| 1603 |
if (getChangeSubscriptionPolicy() != CDOChangeSubscriptionPolicy.NONE) |
1744 |
if (getAdapterDeltaNotificationPolicy() != CDOAdapterPolicy.NONE) |
| 1604 |
{ |
1745 |
{ |
| 1605 |
request(Collections.singletonList(id), false, false); |
1746 |
request(Collections.singletonList(id), false, false); |
| 1606 |
} |
1747 |
} |