|
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.ReferenceType; |
70 |
import org.eclipse.net4j.util.ref.ReferenceType; |
|
Lines 135-144
Link Here
|
| 135 |
*/ |
136 |
*/ |
| 136 |
private ChangeSubscriptionManager changeSubscriptionManager = new ChangeSubscriptionManager(); |
137 |
private ChangeSubscriptionManager changeSubscriptionManager = new ChangeSubscriptionManager(); |
| 137 |
|
138 |
|
|
|
139 |
private ViewAdapterManager adapterPolicyManager = null; |
| 140 |
|
| 138 |
/** |
141 |
/** |
| 139 |
* @since 2.0 |
142 |
* @since 2.0 |
| 140 |
*/ |
143 |
*/ |
| 141 |
private CDOChangeSubscriptionPolicy changeSubscriptionPolicy = CDOChangeSubscriptionPolicy.NONE; |
144 |
private CDOAdapterPolicy changeSubscriptionPolicy = CDOAdapterPolicy.NONE; |
|
|
145 |
|
| 146 |
private CDOAdapterPolicy adapterReferencePolicy = CDOAdapterPolicy.NONE; |
| 142 |
|
147 |
|
| 143 |
/** |
148 |
/** |
| 144 |
* @since 2.0 |
149 |
* @since 2.0 |
|
Lines 150-155
Link Here
|
| 150 |
invalidationNotificationEnabled = OM.PREF_ENABLE_INVALIDATION_NOTIFICATION.getValue(); |
155 |
invalidationNotificationEnabled = OM.PREF_ENABLE_INVALIDATION_NOTIFICATION.getValue(); |
| 151 |
revisionPrefetchingPolicy = CDOUtil.createRevisionPrefetchingPolicy(OM.PREF_REVISION_LOADING_CHUNK_SIZE.getValue()); |
156 |
revisionPrefetchingPolicy = CDOUtil.createRevisionPrefetchingPolicy(OM.PREF_REVISION_LOADING_CHUNK_SIZE.getValue()); |
| 152 |
setCacheReferenceType(null); |
157 |
setCacheReferenceType(null); |
|
|
158 |
adapterPolicyManager = createAdapterManager(); |
| 153 |
} |
159 |
} |
| 154 |
|
160 |
|
| 155 |
public int getViewID() |
161 |
public int getViewID() |
|
Lines 339-345
Link Here
|
| 339 |
/** |
345 |
/** |
| 340 |
* @since 2.0 |
346 |
* @since 2.0 |
| 341 |
*/ |
347 |
*/ |
| 342 |
public CDOChangeSubscriptionPolicy getChangeSubscriptionPolicy() |
348 |
public CDOAdapterPolicy getChangeSubscriptionPolicy() |
| 343 |
{ |
349 |
{ |
| 344 |
return changeSubscriptionPolicy; |
350 |
return changeSubscriptionPolicy; |
| 345 |
} |
351 |
} |
|
Lines 347-357
Link Here
|
| 347 |
/** |
353 |
/** |
| 348 |
* @since 2.0 |
354 |
* @since 2.0 |
| 349 |
*/ |
355 |
*/ |
| 350 |
public void setChangeSubscriptionPolicy(CDOChangeSubscriptionPolicy subscriptionPolicy) |
356 |
public void setChangeSubscriptionPolicy(CDOAdapterPolicy subscriptionPolicy) |
| 351 |
{ |
357 |
{ |
| 352 |
if (subscriptionPolicy == null) |
358 |
if (subscriptionPolicy == null) |
| 353 |
{ |
359 |
{ |
| 354 |
subscriptionPolicy = CDOChangeSubscriptionPolicy.NONE; |
360 |
subscriptionPolicy = CDOAdapterPolicy.NONE; |
| 355 |
} |
361 |
} |
| 356 |
|
362 |
|
| 357 |
if (changeSubscriptionPolicy != subscriptionPolicy) |
363 |
if (changeSubscriptionPolicy != subscriptionPolicy) |
|
Lines 364-369
Link Here
|
| 364 |
/** |
370 |
/** |
| 365 |
* @since 2.0 |
371 |
* @since 2.0 |
| 366 |
*/ |
372 |
*/ |
|
|
373 |
public CDOAdapterPolicy getStrongReferencePolicy() |
| 374 |
{ |
| 375 |
return adapterReferencePolicy; |
| 376 |
} |
| 377 |
|
| 378 |
/** |
| 379 |
* @since 2.0 |
| 380 |
*/ |
| 381 |
public void setStrongReferencePolicy(CDOAdapterPolicy adapterPolicy) |
| 382 |
{ |
| 383 |
if (adapterPolicy == null) |
| 384 |
{ |
| 385 |
adapterPolicy = CDOAdapterPolicy.NONE; |
| 386 |
} |
| 387 |
|
| 388 |
if (adapterReferencePolicy != adapterPolicy) |
| 389 |
{ |
| 390 |
adapterReferencePolicy = adapterPolicy; |
| 391 |
adapterPolicyManager.reset(); |
| 392 |
} |
| 393 |
} |
| 394 |
|
| 395 |
/** |
| 396 |
* @since 2.0 |
| 397 |
*/ |
| 367 |
public CDORevisionPrefetchingPolicy getRevisionPrefetchingPolicy() |
398 |
public CDORevisionPrefetchingPolicy getRevisionPrefetchingPolicy() |
| 368 |
{ |
399 |
{ |
| 369 |
return revisionPrefetchingPolicy; |
400 |
return revisionPrefetchingPolicy; |
|
Lines 1213-1219
Link Here
|
| 1213 |
*/ |
1244 |
*/ |
| 1214 |
public void handleChangeSubscription(Collection<CDORevisionDelta> deltas, Collection<CDOID> detachedObjects) |
1245 |
public void handleChangeSubscription(Collection<CDORevisionDelta> deltas, Collection<CDOID> detachedObjects) |
| 1215 |
{ |
1246 |
{ |
| 1216 |
if (getChangeSubscriptionPolicy() != CDOChangeSubscriptionPolicy.NONE) |
1247 |
if (getChangeSubscriptionPolicy() != CDOAdapterPolicy.NONE) |
| 1217 |
{ |
1248 |
{ |
| 1218 |
if (deltas != null) |
1249 |
if (deltas != null) |
| 1219 |
{ |
1250 |
{ |
|
Lines 1253-1258
Link Here
|
| 1253 |
/** |
1284 |
/** |
| 1254 |
* @since 2.0 |
1285 |
* @since 2.0 |
| 1255 |
*/ |
1286 |
*/ |
|
|
1287 |
protected ViewAdapterManager getAdapterManager() |
| 1288 |
{ |
| 1289 |
return adapterPolicyManager; |
| 1290 |
} |
| 1291 |
|
| 1292 |
/** |
| 1293 |
* @since 2.0 |
| 1294 |
*/ |
| 1295 |
protected ViewAdapterManager createAdapterManager() |
| 1296 |
{ |
| 1297 |
return new ViewAdapterManager(); |
| 1298 |
} |
| 1299 |
|
| 1300 |
/** |
| 1301 |
* @since 2.0 |
| 1302 |
*/ |
| 1303 |
public void handleAddAdapter(InternalCDOObject eObject, Adapter adapter) |
| 1304 |
{ |
| 1305 |
if (!FSMUtil.isNew(eObject)) |
| 1306 |
{ |
| 1307 |
subscribe(eObject, adapter); |
| 1308 |
} |
| 1309 |
|
| 1310 |
adapterPolicyManager.attachAdapter(eObject, adapter); |
| 1311 |
} |
| 1312 |
|
| 1313 |
/** |
| 1314 |
* @since 2.0 |
| 1315 |
*/ |
| 1316 |
public void handleRemoveAdapter(InternalCDOObject eObject, Adapter adapter) |
| 1317 |
{ |
| 1318 |
if (!FSMUtil.isNew(eObject)) |
| 1319 |
{ |
| 1320 |
unsubscribe(eObject, adapter); |
| 1321 |
} |
| 1322 |
|
| 1323 |
adapterPolicyManager.detachAdapter(eObject, adapter); |
| 1324 |
} |
| 1325 |
|
| 1326 |
/** |
| 1327 |
* @since 2.0 |
| 1328 |
*/ |
| 1256 |
public void subscribe(EObject eObject, Adapter adapter) |
1329 |
public void subscribe(EObject eObject, Adapter adapter) |
| 1257 |
{ |
1330 |
{ |
| 1258 |
changeSubscriptionManager.subscribe(eObject, adapter); |
1331 |
changeSubscriptionManager.subscribe(eObject, adapter); |
|
Lines 1492-1497
Link Here
|
| 1492 |
* @author Simon McDuff |
1565 |
* @author Simon McDuff |
| 1493 |
* @since 2.0 |
1566 |
* @since 2.0 |
| 1494 |
*/ |
1567 |
*/ |
|
|
1568 |
protected class ViewAdapterManager |
| 1569 |
{ |
| 1570 |
protected Set<CDOObject> objects = new HashBag<CDOObject>(); |
| 1571 |
|
| 1572 |
synchronized protected void attachObject(CDOObject object) |
| 1573 |
{ |
| 1574 |
int count = 0; |
| 1575 |
for (Adapter adapter : object.eAdapters()) |
| 1576 |
{ |
| 1577 |
if (adapterReferencePolicy.valid(object, adapter)) |
| 1578 |
{ |
| 1579 |
count++; |
| 1580 |
} |
| 1581 |
} |
| 1582 |
|
| 1583 |
for (int i = 0; i < count; i++) |
| 1584 |
{ |
| 1585 |
objects.add(object); |
| 1586 |
} |
| 1587 |
|
| 1588 |
} |
| 1589 |
|
| 1590 |
synchronized protected void detachObject(CDOObject object) |
| 1591 |
{ |
| 1592 |
while (objects.remove(object)) |
| 1593 |
{ |
| 1594 |
; |
| 1595 |
} |
| 1596 |
} |
| 1597 |
|
| 1598 |
synchronized protected void attachAdapter(CDOObject object, Adapter adapter) |
| 1599 |
{ |
| 1600 |
if (getStrongReferencePolicy().valid(object, adapter)) |
| 1601 |
{ |
| 1602 |
objects.add(object); |
| 1603 |
} |
| 1604 |
} |
| 1605 |
|
| 1606 |
synchronized protected void detachAdapter(CDOObject object, Adapter adapter) |
| 1607 |
{ |
| 1608 |
if (getStrongReferencePolicy().valid(object, adapter)) |
| 1609 |
{ |
| 1610 |
objects.add(object); |
| 1611 |
} |
| 1612 |
} |
| 1613 |
|
| 1614 |
synchronized public void reset() |
| 1615 |
{ |
| 1616 |
// Keep the object in memory |
| 1617 |
Set<CDOObject> oldObject = objects; |
| 1618 |
objects = new HashBag<CDOObject>(); |
| 1619 |
if (getStrongReferencePolicy() != CDOAdapterPolicy.NONE) |
| 1620 |
{ |
| 1621 |
InternalCDOObject objects[] = getObjectsArray(); |
| 1622 |
for (int i = 0; i < objects.length; i++) |
| 1623 |
{ |
| 1624 |
InternalCDOObject object = objects[i]; |
| 1625 |
attachObject(object); |
| 1626 |
} |
| 1627 |
} |
| 1628 |
oldObject.clear(); |
| 1629 |
} |
| 1630 |
}; |
| 1631 |
|
| 1632 |
/** |
| 1633 |
* @author Simon McDuff |
| 1634 |
* @since 2.0 |
| 1635 |
*/ |
| 1495 |
protected class ChangeSubscriptionManager |
1636 |
protected class ChangeSubscriptionManager |
| 1496 |
{ |
1637 |
{ |
| 1497 |
private Map<CDOID, SubscribeEntry> subscriptions = new HashMap<CDOID, SubscribeEntry>() |
1638 |
private Map<CDOID, SubscribeEntry> subscriptions = new HashMap<CDOID, SubscribeEntry>() |
|
Lines 1518-1524
Link Here
|
| 1518 |
{ |
1659 |
{ |
| 1519 |
subscriptions.clear(); |
1660 |
subscriptions.clear(); |
| 1520 |
List<CDOID> cdoIDs = new ArrayList<CDOID>(); |
1661 |
List<CDOID> cdoIDs = new ArrayList<CDOID>(); |
| 1521 |
if (changeSubscriptionPolicy != CDOChangeSubscriptionPolicy.NONE) |
1662 |
if (changeSubscriptionPolicy != CDOAdapterPolicy.NONE) |
| 1522 |
{ |
1663 |
{ |
| 1523 |
for (InternalCDOObject cdoObject : getObjectsArray()) |
1664 |
for (InternalCDOObject cdoObject : getObjectsArray()) |
| 1524 |
{ |
1665 |
{ |
|
Lines 1605-1611
Link Here
|
| 1605 |
{ |
1746 |
{ |
| 1606 |
for (Adapter adapter : object.eAdapters()) |
1747 |
for (Adapter adapter : object.eAdapters()) |
| 1607 |
{ |
1748 |
{ |
| 1608 |
if (changeSubscriptionPolicy.shouldSubscribe(object, adapter)) |
1749 |
if (changeSubscriptionPolicy.valid(object, adapter)) |
| 1609 |
{ |
1750 |
{ |
| 1610 |
count++; |
1751 |
count++; |
| 1611 |
} |
1752 |
} |
|
Lines 1620-1626
Link Here
|
| 1620 |
{ |
1761 |
{ |
| 1621 |
synchronized (subscriptions) |
1762 |
synchronized (subscriptions) |
| 1622 |
{ |
1763 |
{ |
| 1623 |
if (getChangeSubscriptionPolicy().shouldSubscribe(eObject, adapter)) |
1764 |
if (getChangeSubscriptionPolicy().valid(eObject, adapter)) |
| 1624 |
{ |
1765 |
{ |
| 1625 |
InternalCDOObject internalCDOObject = FSMUtil.adapt(eObject, CDOViewImpl.this); |
1766 |
InternalCDOObject internalCDOObject = FSMUtil.adapt(eObject, CDOViewImpl.this); |
| 1626 |
if (internalCDOObject.cdoView() != CDOViewImpl.this) |
1767 |
if (internalCDOObject.cdoView() != CDOViewImpl.this) |
|
Lines 1648-1654
Link Here
|
| 1648 |
} |
1789 |
} |
| 1649 |
|
1790 |
|
| 1650 |
// Notification need to be enable to send correct value to the server |
1791 |
// Notification need to be enable to send correct value to the server |
| 1651 |
if (getChangeSubscriptionPolicy() != CDOChangeSubscriptionPolicy.NONE) |
1792 |
if (getChangeSubscriptionPolicy() != CDOAdapterPolicy.NONE) |
| 1652 |
{ |
1793 |
{ |
| 1653 |
request(Collections.singletonList(id), false, true); |
1794 |
request(Collections.singletonList(id), false, true); |
| 1654 |
} |
1795 |
} |
|
Lines 1666-1672
Link Here
|
| 1666 |
subscriptions.remove(id); |
1807 |
subscriptions.remove(id); |
| 1667 |
|
1808 |
|
| 1668 |
// Notification need to be enable to send correct value to the server |
1809 |
// Notification need to be enable to send correct value to the server |
| 1669 |
if (getChangeSubscriptionPolicy() != CDOChangeSubscriptionPolicy.NONE) |
1810 |
if (getChangeSubscriptionPolicy() != CDOAdapterPolicy.NONE) |
| 1670 |
{ |
1811 |
{ |
| 1671 |
request(Collections.singletonList(id), false, false); |
1812 |
request(Collections.singletonList(id), false, false); |
| 1672 |
} |
1813 |
} |