Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 247226 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFactoryImpl.java (-1 / +3 lines)
Lines 39-46 Link Here
39
39
40
  /**
40
  /**
41
   * TODO Add TCs to ensure that Ecore internally doesn't change the way the stack is used!!!
41
   * TODO Add TCs to ensure that Ecore internally doesn't change the way the stack is used!!!
42
   * 
43
   * @since 3.0
42
   */
44
   */
43
  private boolean isGetResource()
45
  protected boolean isGetResource()
44
  {
46
  {
45
    boolean inResourceSet = false;
47
    boolean inResourceSet = false;
46
    StackTraceElement[] elements = Thread.currentThread().getStackTrace();
48
    StackTraceElement[] elements = Thread.currentThread().getStackTrace();
(-)src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java (-1 / +2 lines)
Lines 901-908 Link Here
901
901
902
  /**
902
  /**
903
   * @ADDED
903
   * @ADDED
904
   * @since 3.0
904
   */
905
   */
905
  void setExisting(boolean existing)
906
  protected void setExisting(boolean existing)
906
  {
907
  {
907
    this.existing = existing;
908
    this.existing = existing;
908
  }
909
  }
(-)src/org/eclipse/emf/cdo/transaction/CDOAutoAttacher.java (-2 / +4 lines)
Lines 23-28 Link Here
23
import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta;
23
import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta;
24
import org.eclipse.emf.cdo.common.revision.delta.CDOUnsetFeatureDelta;
24
import org.eclipse.emf.cdo.common.revision.delta.CDOUnsetFeatureDelta;
25
import org.eclipse.emf.cdo.eresource.CDOResource;
25
import org.eclipse.emf.cdo.eresource.CDOResource;
26
import org.eclipse.emf.cdo.util.CDOUtil;
26
27
27
import org.eclipse.emf.internal.cdo.util.FSMUtil;
28
import org.eclipse.emf.internal.cdo.util.FSMUtil;
28
29
Lines 60-66 Link Here
60
    }
61
    }
61
62
62
    // Persist the graph as well.
63
    // Persist the graph as well.
63
    handle(object, object);
64
    EObject obj = CDOUtil.getEObject(object);
65
    handle(obj, obj);
64
  }
66
  }
65
67
66
  @Override
68
  @Override
Lines 100-106 Link Here
100
      }
102
      }
101
      else
103
      else
102
      {
104
      {
103
        persist(referrer, element);
105
        persist(referrer, CDOUtil.getCDOObject(element));
104
      }
106
      }
105
    }
107
    }
106
  }
108
  }
(-)src/org/eclipse/emf/cdo/transaction/CDOPushTransaction.java (+5 lines)
Lines 306-311 Link Here
306
    return delegate.createResource(path);
306
    return delegate.createResource(path);
307
  }
307
  }
308
308
309
  public boolean isLegacyModeEnabled()
310
  {
311
    return delegate.isLegacyModeEnabled();
312
  }
313
309
  public Set<CDOObject> getConflicts()
314
  public Set<CDOObject> getConflicts()
310
  {
315
  {
311
    return delegate.getConflicts();
316
    return delegate.getConflicts();
(-)src/org/eclipse/emf/cdo/util/CDOUtil.java (+27 lines)
Lines 27-32 Link Here
27
import org.eclipse.emf.cdo.view.CDOViewSet;
27
import org.eclipse.emf.cdo.view.CDOViewSet;
28
28
29
import org.eclipse.emf.internal.cdo.CDOFactoryImpl;
29
import org.eclipse.emf.internal.cdo.CDOFactoryImpl;
30
import org.eclipse.emf.internal.cdo.CDOObjectWrapper;
30
import org.eclipse.emf.internal.cdo.CDOStateMachine;
31
import org.eclipse.emf.internal.cdo.CDOStateMachine;
31
import org.eclipse.emf.internal.cdo.messages.Messages;
32
import org.eclipse.emf.internal.cdo.messages.Messages;
32
import org.eclipse.emf.internal.cdo.session.CDOCollectionLoadingPolicyImpl;
33
import org.eclipse.emf.internal.cdo.session.CDOCollectionLoadingPolicyImpl;
Lines 60-65 Link Here
60
 */
61
 */
61
public final class CDOUtil
62
public final class CDOUtil
62
{
63
{
64
  private static final ThreadLocal<Boolean> legacyModeDefault = new InheritableThreadLocal<Boolean>();
65
63
  private CDOUtil()
66
  private CDOUtil()
64
  {
67
  {
65
  }
68
  }
Lines 400-403 Link Here
400
  {
403
  {
401
    return CDOSessionImpl.isInvalidationRunnerActive();
404
    return CDOSessionImpl.isInvalidationRunnerActive();
402
  }
405
  }
406
407
  /**
408
   * @since 3.0
409
   */
410
  public static boolean isLegacyObject(EObject object)
411
  {
412
    return object instanceof CDOObjectWrapper;
413
  }
414
415
  /**
416
   * @since 3.0
417
   */
418
  public static boolean isLegacyModeDefault()
419
  {
420
    return legacyModeDefault.get();
421
  }
422
423
  /**
424
   * @since 3.0
425
   */
426
  public static void setLegacyModeDefault(boolean on)
427
  {
428
    legacyModeDefault.set(on);
429
  }
403
}
430
}
(-)src/org/eclipse/emf/cdo/util/LegacyModeNotEnabledException.java (+40 lines)
Added Link Here
1
/**
2
 * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *    Eike Stepper - initial API and implementation
10
 */
11
package org.eclipse.emf.cdo.util;
12
13
/**
14
 * @author Eike Stepper
15
 * @since 3.0
16
 */
17
public class LegacyModeNotEnabledException extends IllegalStateException
18
{
19
  private static final long serialVersionUID = 1L;
20
21
  public LegacyModeNotEnabledException()
22
  {
23
    this("Legacy mode is not enabled");
24
  }
25
26
  public LegacyModeNotEnabledException(String s)
27
  {
28
    super(s);
29
  }
30
31
  public LegacyModeNotEnabledException(Throwable cause)
32
  {
33
    super(cause);
34
  }
35
36
  public LegacyModeNotEnabledException(String message, Throwable cause)
37
  {
38
    super(message, cause);
39
  }
40
}
(-)src/org/eclipse/emf/cdo/view/CDOView.java (+5 lines)
Lines 176-181 Link Here
176
  public ReentrantLock getLock();
176
  public ReentrantLock getLock();
177
177
178
  /**
178
  /**
179
   * @since 3.0
180
   */
181
  public boolean isLegacyModeEnabled();
182
183
  /**
179
   * Returns always <code>false</code>.
184
   * Returns always <code>false</code>.
180
   * <p>
185
   * <p>
181
   * This method has a special implementation in {@link CDOTransaction} as well.
186
   * This method has a special implementation in {@link CDOTransaction} as well.
(-)src/org/eclipse/emf/internal/cdo/CDOLegacyAdapter.java (-6 / +21 lines)
Lines 11-17 Link Here
11
 */
11
 */
12
package org.eclipse.emf.internal.cdo;
12
package org.eclipse.emf.internal.cdo;
13
13
14
import org.eclipse.emf.cdo.CDONotification;
14
import org.eclipse.emf.cdo.common.model.EMFUtil;
15
import org.eclipse.emf.cdo.common.model.EMFUtil;
16
import org.eclipse.emf.cdo.transaction.CDOTransaction;
15
17
16
import org.eclipse.emf.common.notify.Adapter;
18
import org.eclipse.emf.common.notify.Adapter;
17
import org.eclipse.emf.common.notify.Notification;
19
import org.eclipse.emf.common.notify.Notification;
Lines 32-37 Link Here
32
    super(null);
34
    super(null);
33
  }
35
  }
34
36
37
  /**
38
   * @since 3.0
39
   */
40
  public CDOLegacyAdapter(InternalEObject object)
41
  {
42
    super(object);
43
  }
44
35
  public void setTarget(Notifier newTarget)
45
  public void setTarget(Notifier newTarget)
36
  {
46
  {
37
    instance = (InternalEObject)newTarget;
47
    instance = (InternalEObject)newTarget;
Lines 57-71 Link Here
57
67
58
  public void notifyChanged(Notification msg)
68
  public void notifyChanged(Notification msg)
59
  {
69
  {
60
    EStructuralFeature feature = (EStructuralFeature)msg.getFeature();
70
    if (msg instanceof CDONotification)
71
    {
72
      return;
73
    }
61
74
62
    if (view == null || feature == null)
75
    EStructuralFeature feature = (EStructuralFeature)msg.getFeature();
76
    if (view == null || feature == null || !(view instanceof CDOTransaction))
63
    {
77
    {
64
      return;
78
      return;
65
    }
79
    }
66
80
67
    CDOStore store = view.getStore();
81
    CDOStore store = view.getStore();
68
69
    if (EMFUtil.isPersistent(feature))
82
    if (EMFUtil.isPersistent(feature))
70
    {
83
    {
71
      switch (msg.getEventType())
84
      switch (msg.getEventType())
Lines 108-124 Link Here
108
121
109
      case Notification.REMOVE_MANY:
122
      case Notification.REMOVE_MANY:
110
      {
123
      {
111
        int pos = msg.getPosition();
112
        @SuppressWarnings("unchecked")
124
        @SuppressWarnings("unchecked")
113
        List<Object> list = (List<Object>)msg.getOldValue();
125
        List<Object> list = (List<Object>)msg.getOldValue();
114
        for (int i = 0; i < list.size(); i++)
126
        for (int i = list.size() - 1; i >= 0; --i)
115
        {
127
        {
116
          store.remove(instance, feature, pos);
128
          store.remove(instance, feature, i);
117
        }
129
        }
118
130
119
        break;
131
        break;
120
      }
132
      }
121
      }
133
      }
134
135
      // Align Container for bidirectional references because this is not set in the store. See Bugzilla_246622_Test
136
      instanceToRevisionContainment();
122
    }
137
    }
123
  }
138
  }
124
}
139
}
(-)src/org/eclipse/emf/internal/cdo/CDOLegacyWrapper.java (-68 / +314 lines)
Lines 20-36 Link Here
20
import org.eclipse.emf.cdo.common.model.EMFUtil;
20
import org.eclipse.emf.cdo.common.model.EMFUtil;
21
import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
21
import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
22
import org.eclipse.emf.cdo.common.revision.CDORevision;
22
import org.eclipse.emf.cdo.common.revision.CDORevision;
23
import org.eclipse.emf.cdo.common.revision.CDORevisionData;
24
import org.eclipse.emf.cdo.common.util.CDOException;
23
import org.eclipse.emf.cdo.eresource.CDOResource;
25
import org.eclipse.emf.cdo.eresource.CDOResource;
24
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
26
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
27
import org.eclipse.emf.cdo.util.CDOUtil;
25
28
26
import org.eclipse.emf.internal.cdo.bundle.OM;
29
import org.eclipse.emf.internal.cdo.bundle.OM;
27
import org.eclipse.emf.internal.cdo.util.FSMUtil;
30
import org.eclipse.emf.internal.cdo.util.FSMUtil;
28
31
29
import org.eclipse.net4j.util.ImplementationError;
30
import org.eclipse.net4j.util.ReflectUtil;
32
import org.eclipse.net4j.util.ReflectUtil;
33
import org.eclipse.net4j.util.WrappedException;
31
import org.eclipse.net4j.util.om.trace.ContextTracer;
34
import org.eclipse.net4j.util.om.trace.ContextTracer;
32
35
33
import org.eclipse.emf.common.notify.Adapter;
36
import org.eclipse.emf.common.notify.Adapter;
37
import org.eclipse.emf.common.notify.impl.BasicNotifierImpl.EObservableAdapterList;
38
import org.eclipse.emf.common.util.EList;
34
import org.eclipse.emf.common.util.URI;
39
import org.eclipse.emf.common.util.URI;
35
import org.eclipse.emf.ecore.EAttribute;
40
import org.eclipse.emf.ecore.EAttribute;
36
import org.eclipse.emf.ecore.EClass;
41
import org.eclipse.emf.ecore.EClass;
Lines 41-46 Link Here
41
import org.eclipse.emf.ecore.InternalEObject;
46
import org.eclipse.emf.ecore.InternalEObject;
42
import org.eclipse.emf.ecore.resource.Resource;
47
import org.eclipse.emf.ecore.resource.Resource;
43
import org.eclipse.emf.ecore.util.InternalEList;
48
import org.eclipse.emf.ecore.util.InternalEList;
49
import org.eclipse.emf.spi.cdo.CDOElementProxy;
44
import org.eclipse.emf.spi.cdo.InternalCDOObject;
50
import org.eclipse.emf.spi.cdo.InternalCDOObject;
45
import org.eclipse.emf.spi.cdo.InternalCDOView;
51
import org.eclipse.emf.spi.cdo.InternalCDOView;
46
52
Lines 59-78 Link Here
59
{
65
{
60
  private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_OBJECT, CDOLegacyWrapper.class);
66
  private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_OBJECT, CDOLegacyWrapper.class);
61
67
62
  protected CDOState state;
63
64
  protected InternalCDORevision revision;
65
66
  /**
67
   * It could happen that while <i>revisionToInstance()</i> is executed externally the <i>internalPostLoad()</i> method
68
   * will be called. This happens for example if <i>internalPostInvalidate()</i> is called. The leads to another
69
   * <i>revisionToInstance()</i> call while the first call has not finished. This is certainly not so cool. That's why
70
   * <b>underConstruction</b> will flag that <i>revisionToInstance()</i> is still running and avoid the second call.
71
   * 
72
   * @since 3.0
73
   */
74
  private boolean underConstruction;
75
76
  /**
68
  /**
77
   * This local ThreadMap stores all pre-registered objects. This avoids a neverending loop when setting the container
69
   * This local ThreadMap stores all pre-registered objects. This avoids a neverending loop when setting the container
78
   * for the object.
70
   * for the object.
Lines 95-104 Link Here
95
    }
87
    }
96
  };
88
  };
97
89
90
  protected CDOState state;
91
92
  protected InternalCDORevision revision;
93
94
  /**
95
   * It could happen that while <i>revisionToInstance()</i> is executed externally the <i>internalPostLoad()</i> method
96
   * will be called. This happens for example if <i>internalPostInvalidate()</i> is called. The leads to another
97
   * <i>revisionToInstance()</i> call while the first call has not finished. This is certainly not so cool. That's why
98
   * <b>underConstruction</b> will flag that <i>revisionToInstance()</i> is still running and avoid the second call.
99
   * 
100
   * @since 3.0
101
   */
102
  private boolean underConstruction;
103
98
  public CDOLegacyWrapper(InternalEObject instance)
104
  public CDOLegacyWrapper(InternalEObject instance)
99
  {
105
  {
100
    this.instance = instance;
106
    this.instance = instance;
101
    state = CDOState.TRANSIENT;
107
    state = CDOState.TRANSIENT;
108
109
    instance.eAdapters().add((Adapter)this);
110
    attachAdapterListListener();
102
  }
111
  }
103
112
104
  public CDOState cdoState()
113
  public CDOState cdoState()
Lines 122-133 Link Here
122
    {
131
    {
123
      if (TRACER.isEnabled())
132
      if (TRACER.isEnabled())
124
      {
133
      {
125
        TRACER.format("Setting state {0} for {1}", state, this);
134
        TRACER.format("Setting state {0} for {1}", state, this); //$NON-NLS-1$
126
      }
135
      }
127
136
128
      CDOState oldState = this.state;
137
      CDOState oldState = this.state;
129
      this.state = state;
138
      this.state = state;
130
      adjustEProxy();
139
      adjustEProxy();
140
131
      if (view != null)
141
      if (view != null)
132
      {
142
      {
133
        view.handleObjectStateChanged(this, oldState, state);
143
        view.handleObjectStateChanged(this, oldState, state);
Lines 143-149 Link Here
143
  {
153
  {
144
    if (TRACER.isEnabled())
154
    if (TRACER.isEnabled())
145
    {
155
    {
146
      TRACER.format(("Setting revision: " + revision + ""));
156
      TRACER.trace(("Setting revision: " + revision)); //$NON-NLS-1$
147
    }
157
    }
148
158
149
    this.revision = (InternalCDORevision)revision;
159
    this.revision = (InternalCDORevision)revision;
Lines 153-183 Link Here
153
  {
163
  {
154
    instanceToRevision();
164
    instanceToRevision();
155
165
156
    // TODO Avoid if no adapters in list (eBasicAdapters?)
157
    // TODO LEGACY Clarify how to intercept adapter addition in the legacy
158
    // instance
159
    for (Adapter adapter : eAdapters())
166
    for (Adapter adapter : eAdapters())
160
    {
167
    {
161
      view.subscribe(this, adapter);
168
      if (!(adapter instanceof CDOObjectWrapper))
169
      {
170
        view.handleAddAdapter(this, adapter);
171
        view.subscribe(this, adapter);
172
      }
162
    }
173
    }
163
  }
174
  }
164
175
165
  public void cdoInternalPostDetach(boolean remote)
176
  public void cdoInternalPostDetach(boolean remote)
166
  {
177
  {
178
    if (remote)
179
    {
180
      // Do nothing??
181
      return;
182
    }
183
184
    EClass eClass = revision.getEClass();
185
186
    CDOStore store = view.getStore();
187
    InternalEObject eContainer = store.getContainer(this);
188
    if (eContainer != null && eContainmentFeature().isResolveProxies())
189
    {
190
      adjustOppositeReference(this, eContainer, eContainmentFeature());
191
    }
192
193
    // This loop adjusts the opposite wrapper objects to support dangling references. See Bugzilla_251263_Test
194
    for (EStructuralFeature feature : CDOModelUtil.getAllPersistentFeatures(eClass))
195
    {
196
      EReference oppositeReference = ((EStructuralFeature.Internal)feature).getEOpposite();
197
      if (oppositeReference != null)
198
      {
199
        if (feature.isMany())
200
        {
201
          int size = revision.size(feature);
202
          for (int i = 0; i < size; i++)
203
          {
204
            EObject object = (EObject)getValueFromRevision(feature, i);
205
            CDOObjectWrapper wrapper = (CDOObjectWrapper)CDOUtil.getCDOObject(object);
206
            setOppositeReference(wrapper, oppositeReference);
207
          }
208
        }
209
        else
210
        {
211
          EObject oppositeObject = (EObject)instance.eGet(feature);
212
          if (oppositeObject != null)
213
          {
214
            CDOObjectWrapper wrapper = (CDOObjectWrapper)CDOUtil.getCDOObject(oppositeObject);
215
            setOppositeReference(wrapper, oppositeReference);
216
          }
217
        }
218
      }
219
    }
220
  }
221
222
  private void setOppositeReference(CDOObjectWrapper wrapper, EReference oppositeReference)
223
  {
224
    if (wrapper != null)
225
    {
226
      InternalCDOView view = wrapper.cdoView();
227
      if (view != null)
228
      {
229
        CDOStore store = view.getStore();
230
        if (store != null)
231
        {
232
          store.set(wrapper, oppositeReference, 0, this);
233
        }
234
      }
235
    }
236
  }
237
238
  /**
239
   * @since 3.0
240
   */
241
  public void cdoInternalPostRollback()
242
  {
243
    InternalCDORevision revision = cdoView().getRevision(cdoID(), true);
244
    cdoInternalSetRevision(revision);
245
    revisionToInstance();
246
    state = CDOState.CLEAN;
167
  }
247
  }
168
248
249
  /**
250
   * CDO persists the isUnset state of an eObject in the database. The indicator for this is that the feature is null in
251
   * the revision (see CDOStore.isSet()). When committing a legacy object all values in the instance for native
252
   * attributes are set with the java default values. So, these values will be stored in the revision and CDO cannot
253
   * distinguish whether the feature is set or not. This method must ensure that the value will be set to null if the
254
   * feature is not set.
255
   */
169
  public void cdoInternalPreCommit()
256
  public void cdoInternalPreCommit()
170
  {
257
  {
258
    // We have to set this here because the CDOLegacyAdapter will not be notified when the instance is the target of a
259
    // single-directional containment reference.
260
    // If the container is not an legacy Object the system will get no information
261
    instanceToRevisionContainment();
262
263
    EClass eClass = revision.getEClass();
264
    for (EStructuralFeature feature : CDOModelUtil.getAllPersistentFeatures(eClass))
265
    {
266
      if (feature.isUnsettable())
267
      {
268
        if (!instance.eIsSet(feature))
269
        {
270
          if (feature.isMany())
271
          {
272
            @SuppressWarnings("unchecked")
273
            InternalEList<Object> list = (InternalEList<Object>)instance.eGet(feature);
274
            clearList(feature, list);
275
          }
276
          else
277
          {
278
            revision.set(feature, EStore.NO_INDEX, null);
279
          }
280
        }
281
        else if (instance.eGet(feature) == null)
282
        {
283
          // Must be single-valued!
284
          revision.set(feature, EStore.NO_INDEX, CDORevisionData.NIL);
285
        }
286
      }
287
    }
171
  }
288
  }
172
289
173
  public void cdoInternalPreLoad()
290
  public void cdoInternalPreLoad()
174
  {
291
  {
292
    // Do nothing
175
  }
293
  }
176
294
177
  public void cdoInternalPostLoad()
295
  public void cdoInternalPostLoad()
178
  {
296
  {
179
    // TODO Consider not remembering the revisin after copying it to the
297
    // TODO Consider not remembering the revision after copying it to the instance (spare 1/2 of the space)
180
    // instance (spare 1/2 of the space)
181
    revisionToInstance();
298
    revisionToInstance();
182
  }
299
  }
183
300
Lines 191-197 Link Here
191
308
192
  public void cdoInternalCleanup()
309
  public void cdoInternalCleanup()
193
  {
310
  {
194
    // clean();
311
    // Do nothing
195
  }
312
  }
196
313
197
  @Override
314
  @Override
Lines 214-227 Link Here
214
  @Override
331
  @Override
215
  public String toString()
332
  public String toString()
216
  {
333
  {
217
    return "CDOLegacyWrapper[" + id + "]";
334
    return "CDOLegacyWrapper[" + id + ", " + instance.getClass().getName() + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
335
  }
336
337
  /**
338
   * @since 3.0
339
   */
340
  protected void attachAdapterListListener()
341
  {
342
    ((EObservableAdapterList)instance.eAdapters()).addListener(new AdapterListListener());
218
  }
343
  }
219
344
220
  protected void instanceToRevision()
345
  protected void instanceToRevision()
221
  {
346
  {
222
    if (TRACER.isEnabled())
347
    if (TRACER.isEnabled())
223
    {
348
    {
224
      TRACER.format("Transfering instance to revision: {0} --> {1}", instance, revision);
349
      TRACER.format("Transfering instance to revision: {0} --> {1}", instance, revision); //$NON-NLS-1$
225
    }
350
    }
226
351
227
    // Handle containment
352
    // Handle containment
Lines 250-256 Link Here
250
    else
375
    else
251
    {
376
    {
252
      CDOObject cdoContainer = FSMUtil.adapt(eContainer, view);
377
      CDOObject cdoContainer = FSMUtil.adapt(eContainer, view);
253
      revision.setContainerID(cdoContainer.cdoID());
378
      revision.setContainerID(cdoContainer);
254
      revision.setContainingFeatureID(getInstanceContainerFeatureID(instance));
379
      revision.setContainingFeatureID(getInstanceContainerFeatureID(instance));
255
    }
380
    }
256
  }
381
  }
Lines 265-271 Link Here
265
  {
390
  {
266
    if (underConstruction)
391
    if (underConstruction)
267
    {
392
    {
268
      // return if revisionToInstance was called before to avoid doubled calls
393
      // Return if revisionToInstance was called before to avoid doubled calls
269
      return;
394
      return;
270
    }
395
    }
271
396
Lines 273-279 Link Here
273
398
274
    if (TRACER.isEnabled())
399
    if (TRACER.isEnabled())
275
    {
400
    {
276
      TRACER.format("Transfering revision to instance: {0} --> {1}", revision, instance);
401
      TRACER.format("Transfering revision to instance: {0} --> {1}", revision, instance); //$NON-NLS-1$
277
    }
402
    }
278
403
279
    boolean deliver = instance.eDeliver();
404
    boolean deliver = instance.eDeliver();
Lines 287-293 Link Here
287
    {
412
    {
288
      registerWrapper(this);
413
      registerWrapper(this);
289
      counter.increment();
414
      counter.increment();
290
291
      revisionToInstanceContainment();
415
      revisionToInstanceContainment();
292
416
293
      for (EStructuralFeature feature : CDOModelUtil.getAllPersistentFeatures(revision.getEClass()))
417
      for (EStructuralFeature feature : CDOModelUtil.getAllPersistentFeatures(revision.getEClass()))
Lines 300-305 Link Here
300
      OM.LOG.error(ex);
424
      OM.LOG.error(ex);
301
      throw ex;
425
      throw ex;
302
    }
426
    }
427
    catch (Exception ex)
428
    {
429
      OM.LOG.error(ex);
430
      throw new CDOException(ex);
431
    }
303
    finally
432
    finally
304
    {
433
    {
305
      if (deliver)
434
      if (deliver)
Lines 329-342 Link Here
329
   */
458
   */
330
  protected void revisionToInstanceFeature(EStructuralFeature feature)
459
  protected void revisionToInstanceFeature(EStructuralFeature feature)
331
  {
460
  {
461
    if (feature.isUnsettable() && !view.getStore().isSet(this, feature))
462
    {
463
      // Clarify if this is sufficient for bidirectional references
464
      instance.eUnset(feature);
465
      return;
466
    }
467
332
    if (feature.isMany())
468
    if (feature.isMany())
333
    {
469
    {
334
      if (TRACER.isEnabled())
470
      if (TRACER.isEnabled())
335
      {
471
      {
336
        TRACER.format("State of Object is : " + state);
472
        TRACER.format("State of Object (" + this + "/" + instance + ") is : " + state); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
337
      }
473
      }
338
474
339
      if (state == CDOState.CLEAN || state == CDOState.PROXY)
475
      if (state == CDOState.CLEAN || state == CDOState.PROXY || state == CDOState.NEW || state == CDOState.DIRTY)
340
      {
476
      {
341
        int size = revision.size(feature);
477
        int size = revision.size(feature);
342
478
Lines 350-356 Link Here
350
486
351
          if (TRACER.isEnabled())
487
          if (TRACER.isEnabled())
352
          {
488
          {
353
            TRACER.format("Adding " + object + " to feature " + feature + "in instance " + instance);
489
            TRACER.format("Adding " + object + " to feature " + feature + "in instance " + instance); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
354
          }
490
          }
355
491
356
          list.basicAdd(object, null);
492
          list.basicAdd(object, null);
Lines 365-391 Link Here
365
      {
501
      {
366
        if (TRACER.isEnabled())
502
        if (TRACER.isEnabled())
367
        {
503
        {
368
          TRACER.format(("Setting attribute value " + object + " to feature " + feature + " in instance " + instance));
504
          TRACER.format(("Setting attribute value " + object + " to feature " + feature + " in instance " + instance)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
369
        }
505
        }
370
506
371
        eSet(feature, object);
507
        // Just fake it for the store :(
508
        if (feature.isUnsettable() && object.equals(CDORevisionData.NIL))
509
        {
510
          eSet(feature, null);
511
        }
512
        else
513
        {
514
          eSet(feature, object);
515
        }
372
      }
516
      }
373
      else
517
      else
374
      {
518
      {
375
        // EReferences
519
        // EReferences
376
        if (TRACER.isEnabled())
520
        if (TRACER.isEnabled())
377
        {
521
        {
378
          TRACER.format(("Adding object " + object + " to feature " + feature + " in instance " + instance));
522
          TRACER.format(("Adding object " + object + " to feature " + feature + " in instance " + instance)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
379
        }
523
        }
380
524
381
        int featureID = instance.eClass().getFeatureID(feature);
525
        int featureID = instance.eClass().getFeatureID(feature);
382
        Class<? extends Object> baseClass = object == null ? null : object.getClass();
526
        Class<? extends Object> baseClass = object == null ? null : object.getClass();
383
        EStructuralFeature.Internal internalFeature = (EStructuralFeature.Internal)feature;
527
        EStructuralFeature.Internal internalFeature = (EStructuralFeature.Internal)feature;
384
        EReference oppositeReference = cdoID().isTemporary() ? null : internalFeature.getEOpposite();
528
        EReference oppositeReference = internalFeature.getEOpposite();
385
529
386
        if (oppositeReference != null)
530
        if (oppositeReference != null)
387
        {
531
        {
388
          instance.eInverseAdd((InternalEObject)object, featureID, baseClass, null);
532
          // If you have a containment reference but the container is not set, but the object is attached to a resource
533
          // do not set the feature to null. Otherwise the object will be removed from the container which is the
534
          // resource instead of the original container. As a result the object will be detached. See
535
          // MapTest.testEObjectToEObjectValueContainedMap for more information
536
          if (object != null)
537
          {
538
            instance.eInverseAdd((InternalEObject)object, featureID, baseClass, null);
539
          }
389
540
390
          if (object != null && !EMFUtil.isPersistent(oppositeReference))
541
          if (object != null && !EMFUtil.isPersistent(oppositeReference))
391
          {
542
          {
Lines 394-406 Link Here
394
        }
545
        }
395
        else
546
        else
396
        {
547
        {
397
          instance.eSet(feature, object);
548
          if (object != CDORevisionData.NIL)
549
          {
550
            instance.eSet(feature, object);
551
          }
552
          else
553
          {
554
            instance.eSet(feature, null);
555
          }
398
        }
556
        }
399
557
400
        // Adjust opposite for transient opposite features
401
        if (TRACER.isEnabled())
558
        if (TRACER.isEnabled())
402
        {
559
        {
403
          TRACER.format(("Added object " + object + " to feature " + feature + " in instance " + instance));
560
          TRACER.format(("Added object " + object + " to feature " + feature + " in instance " + instance)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
404
        }
561
        }
405
      }
562
      }
406
    }
563
    }
Lines 408-415 Link Here
408
565
409
  private void adjustOppositeReference(InternalEObject instance, InternalEObject object, EReference oppositeReference)
566
  private void adjustOppositeReference(InternalEObject instance, InternalEObject object, EReference oppositeReference)
410
  {
567
  {
411
    boolean deliver = object.eDeliver(); // Disable notifications
568
    boolean wasDeliver = object.eDeliver(); // Disable notifications
412
    if (deliver)
569
    if (wasDeliver)
413
    {
570
    {
414
      object.eSetDeliver(false);
571
      object.eSetDeliver(false);
415
    }
572
    }
Lines 434-440 Link Here
434
    }
591
    }
435
    finally
592
    finally
436
    {
593
    {
437
      if (deliver)
594
      if (wasDeliver)
438
      {
595
      {
439
        object.eSetDeliver(true);
596
        object.eSetDeliver(true);
440
      }
597
      }
Lines 449-457 Link Here
449
606
450
      // TODO Clarify obj.getClass()/baseclass
607
      // TODO Clarify obj.getClass()/baseclass
451
      ((InternalEList<?>)list).basicRemove(obj, null);
608
      ((InternalEList<?>)list).basicRemove(obj, null);
452
453
      // TODO Martin: baseicRemove seems to be better than eInverseremove
454
      // instance.eInverseRemove(obj, featureID, obj.getClass(), null);
455
    }
609
    }
456
  }
610
  }
457
611
Lines 460-466 Link Here
460
   * store or the internal pre-registration Map.
614
   * store or the internal pre-registration Map.
461
   * 
615
   * 
462
   * @param feature
616
   * @param feature
463
   *          the feature to retireive the value from
617
   *          the feature to retrieve the value from
464
   * @param index
618
   * @param index
465
   *          the given index of the object in the feature
619
   *          the given index of the object in the feature
466
   * @return the value from the feature at the given index
620
   * @return the value from the feature at the given index
Lines 473-478 Link Here
473
      return null;
627
      return null;
474
    }
628
    }
475
629
630
    if (object instanceof CDOElementProxy)
631
    {
632
      // Resolve proxy
633
      object = ((CDOElementProxy)object).resolve(view.getSession(), revision, feature, index);
634
    }
635
476
    if (object instanceof CDOLegacyWrapper)
636
    if (object instanceof CDOLegacyWrapper)
477
    {
637
    {
478
      return ((CDOLegacyWrapper)object).cdoInternalInstance();
638
      return ((CDOLegacyWrapper)object).cdoInternalInstance();
Lines 497-503 Link Here
497
          return ((CDOLegacyWrapper)object).cdoInternalInstance();
657
          return ((CDOLegacyWrapper)object).cdoInternalInstance();
498
        }
658
        }
499
659
500
        object = view.getObject(id);
660
        if (id.isExternal())
661
        {
662
          object = view.getResourceSet().getEObject(URI.createURI(id.toURIFragment()), true);
663
        }
664
        else
665
        {
666
          object = view.getObject(id);
667
        }
668
501
        if (object instanceof CDOObjectWrapper)
669
        if (object instanceof CDOObjectWrapper)
502
        {
670
        {
503
          return ((CDOObjectWrapper)object).cdoInternalInstance();
671
          return ((CDOObjectWrapper)object).cdoInternalInstance();
Lines 537-543 Link Here
537
705
538
  protected void setInstanceContainer(InternalEObject container, int containerFeatureID)
706
  protected void setInstanceContainer(InternalEObject container, int containerFeatureID)
539
  {
707
  {
540
    // TODO Change to direct call of eBasicSetContainer
541
    Method method = ReflectUtil.getMethod(instance.getClass(), "eBasicSetContainer", InternalEObject.class, int.class); //$NON-NLS-1$
708
    Method method = ReflectUtil.getMethod(instance.getClass(), "eBasicSetContainer", InternalEObject.class, int.class); //$NON-NLS-1$
542
    ReflectUtil.invokeMethod(method, instance, container, containerFeatureID);
709
    ReflectUtil.invokeMethod(method, instance, container, containerFeatureID);
543
  }
710
  }
Lines 563-569 Link Here
563
730
564
      if (TRACER.isEnabled())
731
      if (TRACER.isEnabled())
565
      {
732
      {
566
        TRACER.format("getting Object (" + potentialID + ") from localThread instead of the view");
733
        TRACER.format("Getting Object (" + potentialID + ") from localThread instead of the view"); //$NON-NLS-1$ //$NON-NLS-2$
567
      }
734
      }
568
    }
735
    }
569
    else
736
    else
Lines 576-581 Link Here
576
          return null;
743
          return null;
577
        }
744
        }
578
745
746
        if (id.isExternal())
747
        {
748
          URI uri = URI.createURI(id.toURIFragment());
749
          InternalEObject eObject = (InternalEObject)view.getResourceSet().getEObject(uri, true);
750
          return eObject;
751
        }
752
579
        boolean loadOnDemand = feature == null;
753
        boolean loadOnDemand = feature == null;
580
        potentialID = view.getObject(id, loadOnDemand);
754
        potentialID = view.getObject(id, loadOnDemand);
581
        if (potentialID == null && !loadOnDemand)
755
        if (potentialID == null && !loadOnDemand)
Lines 727-733 Link Here
727
        URI uri = URI.createURI(CDOProtocolConstants.PROTOCOL_NAME + ":proxy#" + id); //$NON-NLS-1$
901
        URI uri = URI.createURI(CDOProtocolConstants.PROTOCOL_NAME + ":proxy#" + id); //$NON-NLS-1$
728
        if (TRACER.isEnabled())
902
        if (TRACER.isEnabled())
729
        {
903
        {
730
          TRACER.format("Setting proxyURI {0} for {1}", uri, instance);
904
          TRACER.format("Setting proxyURI {0} for {1}", uri, instance); //$NON-NLS-1$
731
        }
905
        }
732
906
733
        instance.eSetProxyURI(uri);
907
        instance.eSetProxyURI(uri);
Lines 739-745 Link Here
739
      {
913
      {
740
        if (TRACER.isEnabled())
914
        if (TRACER.isEnabled())
741
        {
915
        {
742
          TRACER.format("Unsetting proxyURI for {0}", instance);
916
          TRACER.format("Unsetting proxyURI for {0}", instance); //$NON-NLS-1$
743
        }
917
        }
744
918
745
        instance.eSetProxyURI(null);
919
        instance.eSetProxyURI(null);
Lines 747-752 Link Here
747
    }
921
    }
748
  }
922
  }
749
923
924
  @Override
925
  public synchronized EList<Adapter> eAdapters()
926
  {
927
    EList<Adapter> adapters = instance.eAdapters();
928
    for (Adapter adapter : adapters)
929
    {
930
      if (!FSMUtil.isTransient(this) && !(adapter instanceof CDOLegacyWrapper))
931
      {
932
        cdoView().handleAddAdapter(this, adapter);
933
      }
934
    }
935
936
    return adapters;
937
  }
938
750
  public static boolean isLegacyProxy(Object object)
939
  public static boolean isLegacyProxy(Object object)
751
  {
940
  {
752
    return object instanceof LegacyProxy;
941
    return object instanceof LegacyProxy;
Lines 766-795 Link Here
766
    }
955
    }
767
    catch (IllegalAccessException ex)
956
    catch (IllegalAccessException ex)
768
    {
957
    {
769
      throw new ImplementationError(ex);
958
      throw WrappedException.wrap(ex);
770
    }
959
    }
771
  }
960
  }
772
961
773
  private static CDOLegacyWrapper getRegisteredWrapper(CDOID id)
962
  /**
963
   * @since 3.0
964
   */
965
  protected static CDOLegacyWrapper getRegisteredWrapper(CDOID id)
774
  {
966
  {
775
    return wrapperRegistry.get().get(id);
967
    return wrapperRegistry.get().get(id);
776
  }
968
  }
777
969
778
  /**
970
  /**
779
   * adds an object to the pre-registered objects list which hold all created objects even if they are not registered in
971
   * Adds an object to the pre-registered objects list which hold all created objects even if they are not registered in
780
   * the view
972
   * the view
973
   * 
974
   * @since 3.0
781
   */
975
   */
782
  private static void registerWrapper(CDOLegacyWrapper wrapper)
976
  protected static void registerWrapper(CDOLegacyWrapper wrapper)
783
  {
977
  {
784
    wrapperRegistry.get().put(wrapper.cdoID(), wrapper);
978
    wrapperRegistry.get().put(wrapper.cdoID(), wrapper);
785
  }
979
  }
786
980
787
  private static void unregisterWrapper(CDOLegacyWrapper wrapper)
981
  /**
982
   * @since 3.0
983
   */
984
  protected static void unregisterWrapper(CDOLegacyWrapper wrapper)
788
  {
985
  {
789
    wrapperRegistry.get().remove(wrapper.cdoID());
986
    wrapperRegistry.get().remove(wrapper.cdoID());
790
  }
987
  }
791
988
792
  /**
989
  /**
990
   * @since 3.0
991
   */
992
  protected static boolean isRegisteredWrapper(CDOLegacyWrapper wrapper)
993
  {
994
    return wrapperRegistry.get().containsKey(wrapper.cdoID());
995
  }
996
997
  private static void adjustOppositeReference(InternalCDOObject instance, InternalEObject object, EReference feature)
998
  {
999
    if (object != null)
1000
    {
1001
      InternalCDOObject cdoObject = (InternalCDOObject)CDOUtil.getCDOObject(object);
1002
      if (cdoObject != null && !FSMUtil.isTransient(cdoObject))
1003
      {
1004
        EStore eStore = cdoObject.eStore();
1005
        if (feature.isMany())
1006
        {
1007
          int index = eStore.indexOf(cdoObject, feature, instance.cdoID());
1008
          if (index != EStore.NO_INDEX)
1009
          {
1010
            eStore.set(cdoObject, feature, index, instance);
1011
          }
1012
        }
1013
        else
1014
        {
1015
          eStore.set(cdoObject, feature, 0, instance);
1016
        }
1017
      }
1018
      else
1019
      {
1020
        if (feature.isResolveProxies())
1021
        {
1022
          // We should not trigger events. But we have no choice :-(.
1023
          if (feature.isMany())
1024
          {
1025
            @SuppressWarnings("unchecked")
1026
            InternalEList<Object> list = (InternalEList<Object>)object.eGet(feature);
1027
            int index = list.indexOf(instance);
1028
            if (index != EStore.NO_INDEX)
1029
            {
1030
              list.set(index, instance);
1031
            }
1032
          }
1033
          else
1034
          {
1035
            object.eSet(feature, instance);
1036
          }
1037
        }
1038
      }
1039
    }
1040
  }
1041
1042
  /**
793
   * @author Eike Stepper
1043
   * @author Eike Stepper
794
   */
1044
   */
795
  private static interface LegacyProxy
1045
  private static interface LegacyProxy
Lines 802-812 Link Here
802
   */
1052
   */
803
  private static final class LegacyProxyInvocationHandler implements InvocationHandler, LegacyProxy
1053
  private static final class LegacyProxyInvocationHandler implements InvocationHandler, LegacyProxy
804
  {
1054
  {
805
    private static final Method getIDMethod = ReflectUtil.getMethod(LegacyProxy.class, "getID");
1055
    private static final Method getIDMethod = ReflectUtil.getMethod(LegacyProxy.class, "getID"); //$NON-NLS-1$
806
1056
807
    private static final Method eIsProxyMethod = ReflectUtil.getMethod(EObject.class, "eIsProxy");
1057
    private static final Method eIsProxyMethod = ReflectUtil.getMethod(EObject.class, "eIsProxy"); //$NON-NLS-1$
808
1058
809
    private static final Method eProxyURIMethod = ReflectUtil.getMethod(InternalEObject.class, "eProxyURI");
1059
    private static final Method eProxyURIMethod = ReflectUtil.getMethod(InternalEObject.class, "eProxyURI"); //$NON-NLS-1$
810
1060
811
    private CDOLegacyWrapper wrapper;
1061
    private CDOLegacyWrapper wrapper;
812
1062
Lines 837-854 Link Here
837
1087
838
      if (method.equals(eProxyURIMethod))
1088
      if (method.equals(eProxyURIMethod))
839
      {
1089
      {
840
        // Use the resource of the container because it's guaranteed to
1090
        // Use container's resource because it's guaranteed to be in the same CDOView as the resource of the target!
841
        // be in the same CDOView as the resource
842
        // of the target!
843
        Resource resource = wrapper.eResource();
1091
        Resource resource = wrapper.eResource();
844
1092
845
        // TODO Consider using a "fake" Resource implementation. See
1093
        // TODO Consider using a "fake" Resource implementation. See Resource.getEObject(...)
846
        // Resource.getEObject(...)
847
        return resource.getURI().appendFragment(id.toURIFragment());
1094
        return resource.getURI().appendFragment(id.toURIFragment());
848
      }
1095
      }
849
1096
850
      // A client must have invoked the proxy while being told not to do
1097
      // A client must have invoked the proxy while being told not to do so!
851
      // so!
852
      throw new UnsupportedOperationException(method.getName());
1098
      throw new UnsupportedOperationException(method.getName());
853
    }
1099
    }
854
  }
1100
  }
(-)src/org/eclipse/emf/internal/cdo/CDOMetaWrapper.java (+9 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *    Eike Stepper - initial API and implementation
9
 *    Eike Stepper - initial API and implementation
10
 *    Martin Fluegge - bug 247226: Transparently support legacy models
10
 */
11
 */
11
package org.eclipse.emf.internal.cdo;
12
package org.eclipse.emf.internal.cdo;
12
13
Lines 111-116 Link Here
111
    throw new UnsupportedOperationException();
112
    throw new UnsupportedOperationException();
112
  }
113
  }
113
114
115
  /**
116
   * @since 3.0
117
   */
118
  public void cdoInternalPostRollback()
119
  {
120
    // Do nothing
121
  }
122
114
  public void cdoInternalPreCommit()
123
  public void cdoInternalPreCommit()
115
  {
124
  {
116
    throw new UnsupportedOperationException();
125
    throw new UnsupportedOperationException();
(-)src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java (-1 / +9 lines)
Lines 29-36 Link Here
29
import org.eclipse.net4j.util.ImplementationError;
29
import org.eclipse.net4j.util.ImplementationError;
30
import org.eclipse.net4j.util.ObjectUtil;
30
import org.eclipse.net4j.util.ObjectUtil;
31
import org.eclipse.net4j.util.WrappedException;
31
import org.eclipse.net4j.util.WrappedException;
32
import org.eclipse.net4j.util.concurrent.TimeoutRuntimeException;
33
import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
32
import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
33
import org.eclipse.net4j.util.concurrent.TimeoutRuntimeException;
34
import org.eclipse.net4j.util.om.trace.ContextTracer;
34
import org.eclipse.net4j.util.om.trace.ContextTracer;
35
35
36
import org.eclipse.emf.common.notify.Adapter;
36
import org.eclipse.emf.common.notify.Adapter;
Lines 386-391 Link Here
386
    }
386
    }
387
  }
387
  }
388
388
389
  /**
390
   * @since 3.0
391
   */
392
  public void cdoInternalPostRollback()
393
  {
394
    // Do nothing
395
  }
396
389
  public void cdoInternalPreCommit()
397
  public void cdoInternalPreCommit()
390
  {
398
  {
391
    // Do nothing
399
    // Do nothing
(-)src/org/eclipse/emf/internal/cdo/CDOObjectMerger.java (+1 lines)
Lines 42-46 Link Here
42
    }
42
    }
43
43
44
    merge(revision, delta);
44
    merge(revision, delta);
45
    object.cdoInternalPostLoad();
45
  }
46
  }
46
}
47
}
(-)src/org/eclipse/emf/internal/cdo/CDOObjectWrapper.java (-10 / +181 lines)
Lines 18-28 Link Here
18
import org.eclipse.emf.internal.cdo.bundle.OM;
18
import org.eclipse.emf.internal.cdo.bundle.OM;
19
import org.eclipse.emf.internal.cdo.util.FSMUtil;
19
import org.eclipse.emf.internal.cdo.util.FSMUtil;
20
20
21
import org.eclipse.net4j.util.WrappedException;
22
import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
23
import org.eclipse.net4j.util.concurrent.TimeoutRuntimeException;
21
import org.eclipse.net4j.util.om.trace.ContextTracer;
24
import org.eclipse.net4j.util.om.trace.ContextTracer;
22
25
23
import org.eclipse.emf.common.notify.Adapter;
26
import org.eclipse.emf.common.notify.Adapter;
24
import org.eclipse.emf.common.notify.Notification;
27
import org.eclipse.emf.common.notify.Notification;
25
import org.eclipse.emf.common.notify.NotificationChain;
28
import org.eclipse.emf.common.notify.NotificationChain;
29
import org.eclipse.emf.common.notify.Notifier;
26
import org.eclipse.emf.common.util.EList;
30
import org.eclipse.emf.common.util.EList;
27
import org.eclipse.emf.common.util.TreeIterator;
31
import org.eclipse.emf.common.util.TreeIterator;
28
import org.eclipse.emf.common.util.URI;
32
import org.eclipse.emf.common.util.URI;
Lines 31-43 Link Here
31
import org.eclipse.emf.ecore.EOperation;
35
import org.eclipse.emf.ecore.EOperation;
32
import org.eclipse.emf.ecore.EReference;
36
import org.eclipse.emf.ecore.EReference;
33
import org.eclipse.emf.ecore.EStructuralFeature;
37
import org.eclipse.emf.ecore.EStructuralFeature;
34
import org.eclipse.emf.ecore.InternalEObject;
35
import org.eclipse.emf.ecore.EStructuralFeature.Setting;
38
import org.eclipse.emf.ecore.EStructuralFeature.Setting;
39
import org.eclipse.emf.ecore.EcorePackage;
40
import org.eclipse.emf.ecore.InternalEObject;
36
import org.eclipse.emf.ecore.resource.Resource;
41
import org.eclipse.emf.ecore.resource.Resource;
37
import org.eclipse.emf.spi.cdo.InternalCDOObject;
42
import org.eclipse.emf.spi.cdo.InternalCDOObject;
38
import org.eclipse.emf.spi.cdo.InternalCDOView;
43
import org.eclipse.emf.spi.cdo.InternalCDOView;
39
44
40
import java.lang.reflect.InvocationTargetException;
45
import java.lang.reflect.InvocationTargetException;
46
import java.util.Collections;
47
import java.util.concurrent.TimeUnit;
48
import java.util.concurrent.locks.Condition;
41
49
42
/**
50
/**
43
 * @author Eike Stepper
51
 * @author Eike Stepper
Lines 94-104 Link Here
94
102
95
  public void cdoInternalSetID(CDOID id)
103
  public void cdoInternalSetID(CDOID id)
96
  {
104
  {
97
    if (id != null && id.isNull())
98
    {
99
      throw new IllegalArgumentException("id is null"); //$NON-NLS-1$
100
    }
101
102
    if (TRACER.isEnabled())
105
    if (TRACER.isEnabled())
103
    {
106
    {
104
      TRACER.format("Setting ID: {0} for {1}", id, instance); //$NON-NLS-1$
107
      TRACER.format("Setting ID: {0} for {1}", id, instance); //$NON-NLS-1$
Lines 148-155 Link Here
148
151
149
  public EStructuralFeature cdoInternalDynamicFeature(int dynamicFeatureID)
152
  public EStructuralFeature cdoInternalDynamicFeature(int dynamicFeatureID)
150
  {
153
  {
151
    // TODO Implement method CDOWrapperImpl.cdoInternalDynamicFeature()
154
    return eDynamicFeature(dynamicFeatureID);
152
    throw new UnsupportedOperationException("Not yet implemented"); //$NON-NLS-1$
155
  }
156
157
  /**
158
   * @since 3.0
159
   */
160
  protected EStructuralFeature eDynamicFeature(int dynamicFeatureID)
161
  {
162
    return eClass().getEStructuralFeature(dynamicFeatureID + eStaticFeatureCount());
163
  }
164
165
  /**
166
   * @since 3.0
167
   */
168
  protected int eStaticFeatureCount()
169
  {
170
    return eStaticClass().getFeatureCount();
171
  }
172
173
  /**
174
   * @since 3.0
175
   */
176
  protected final EClass eStaticClass()
177
  {
178
    return EcorePackage.eINSTANCE.getEObject();
153
  }
179
  }
154
180
155
  /**
181
  /**
Lines 157-163 Link Here
157
   */
183
   */
158
  public CDOLock cdoReadLock()
184
  public CDOLock cdoReadLock()
159
  {
185
  {
160
    throw new UnsupportedOperationException();
186
    if (FSMUtil.isTransient(this) || FSMUtil.isNew(this))
187
    {
188
      return NOOPLockImpl.INSTANCE;
189
    }
190
191
    // Should we cache the locks ?
192
    return new Lock(LockType.READ);
161
  }
193
  }
162
194
163
  /**
195
  /**
Lines 165-171 Link Here
165
   */
197
   */
166
  public CDOLock cdoWriteLock()
198
  public CDOLock cdoWriteLock()
167
  {
199
  {
168
    throw new UnsupportedOperationException();
200
    if (FSMUtil.isTransient(this) || FSMUtil.isNew(this))
201
    {
202
      return NOOPLockImpl.INSTANCE;
203
    }
204
205
    // Should we cache the locks ?
206
    return new Lock(LockType.WRITE);
169
  }
207
  }
170
208
171
  public EList<Adapter> eAdapters()
209
  public EList<Adapter> eAdapters()
Lines 320-325 Link Here
320
358
321
  public boolean eIsSet(EStructuralFeature feature)
359
  public boolean eIsSet(EStructuralFeature feature)
322
  {
360
  {
361
    if (instance.eIsSet(feature) != view.getStore().isSet(this, feature))
362
    {
363
      // TODO Clarify whether this is always true
364
      throw new IllegalStateException("Store isSet should never differ from instance");
365
    }
366
323
    return instance.eIsSet(feature);
367
    return instance.eIsSet(feature);
324
  }
368
  }
325
369
Lines 417-420 Link Here
417
  {
461
  {
418
    return instance.eURIFragmentSegment(feature, object);
462
    return instance.eURIFragmentSegment(feature, object);
419
  }
463
  }
464
465
  /**
466
   * @author Martin Flügge
467
   * @since 3.0
468
   */
469
  protected class AdapterListListener implements
470
      org.eclipse.emf.common.notify.impl.BasicNotifierImpl.EObservableAdapterList.Listener
471
  {
472
    public void added(Notifier notifier, Adapter adapter)
473
    {
474
      if (TRACER.isEnabled())
475
      {
476
        TRACER.format("Added : {0} to {1} ", adapter, CDOObjectWrapper.this); //$NON-NLS-1$
477
      }
478
479
      if (!FSMUtil.isTransient(CDOObjectWrapper.this))
480
      {
481
        cdoView().handleAddAdapter(CDOObjectWrapper.this, adapter);
482
      }
483
    }
484
485
    public void removed(Notifier notifier, Adapter adapter)
486
    {
487
      if (TRACER.isEnabled())
488
      {
489
        TRACER.format("Removed : {0} from {1} ", adapter, CDOObjectWrapper.this); //$NON-NLS-1$
490
      }
491
492
      if (!FSMUtil.isTransient(CDOObjectWrapper.this))
493
      {
494
        cdoView().handleRemoveAdapter(CDOObjectWrapper.this, adapter);
495
      }
496
    }
497
  }
498
499
  /**
500
   * @author Martin Fluegge
501
   * @since 3.0
502
   */
503
  private final class Lock implements CDOLock
504
  {
505
    private LockType type;
506
507
    public Lock(LockType type)
508
    {
509
      this.type = type;
510
    }
511
512
    public LockType getType()
513
    {
514
      return type;
515
    }
516
517
    public boolean isLocked()
518
    {
519
      return cdoView().isObjectLocked(CDOObjectWrapper.this, type, false);
520
    }
521
522
    /**
523
     * @see org.eclipse.emf.cdo.CDOLock#isLockedByOthers()
524
     */
525
    public boolean isLockedByOthers()
526
    {
527
      return cdoView().isObjectLocked(CDOObjectWrapper.this, type, true);
528
    }
529
530
    public void lock()
531
    {
532
      try
533
      {
534
        cdoView().lockObjects(Collections.singletonList(CDOObjectWrapper.this), type, CDOLock.WAIT);
535
      }
536
      catch (InterruptedException ex)
537
      {
538
        throw WrappedException.wrap(ex);
539
      }
540
    }
541
542
    public void lockInterruptibly() throws InterruptedException
543
    {
544
      lock();
545
    }
546
547
    public Condition newCondition()
548
    {
549
      throw new UnsupportedOperationException();
550
    }
551
552
    public boolean tryLock()
553
    {
554
      try
555
      {
556
        cdoView().lockObjects(Collections.singletonList(CDOObjectWrapper.this), type, CDOLock.NO_WAIT);
557
        return true;
558
      }
559
      catch (TimeoutRuntimeException ex)
560
      {
561
        return false;
562
      }
563
      catch (InterruptedException ex)
564
      {
565
        throw WrappedException.wrap(ex);
566
      }
567
    }
568
569
    /**
570
     * @throws InterruptedException
571
     *           if timeout is reached.
572
     */
573
    public boolean tryLock(long time, TimeUnit unit) throws InterruptedException
574
    {
575
      try
576
      {
577
        cdoView().lockObjects(Collections.singletonList(CDOObjectWrapper.this), type, unit.toMillis(time));
578
        return true;
579
      }
580
      catch (TimeoutRuntimeException ex)
581
      {
582
        return false;
583
      }
584
    }
585
586
    public void unlock()
587
    {
588
      cdoView().unlockObjects(Collections.singletonList(CDOObjectWrapper.this), type);
589
    }
590
  }
420
}
591
}
(-)src/org/eclipse/emf/internal/cdo/CDOStateMachine.java (-1 / +2 lines)
Lines 41-50 Link Here
41
import org.eclipse.emf.ecore.InternalEObject;
41
import org.eclipse.emf.ecore.InternalEObject;
42
import org.eclipse.emf.ecore.impl.EStoreEObjectImpl;
42
import org.eclipse.emf.ecore.impl.EStoreEObjectImpl;
43
import org.eclipse.emf.ecore.resource.Resource;
43
import org.eclipse.emf.ecore.resource.Resource;
44
import org.eclipse.emf.spi.cdo.CDOSessionProtocol.CommitTransactionResult;
44
import org.eclipse.emf.spi.cdo.InternalCDOObject;
45
import org.eclipse.emf.spi.cdo.InternalCDOObject;
45
import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
46
import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
46
import org.eclipse.emf.spi.cdo.InternalCDOView;
47
import org.eclipse.emf.spi.cdo.InternalCDOView;
47
import org.eclipse.emf.spi.cdo.CDOSessionProtocol.CommitTransactionResult;
48
48
49
import java.util.ArrayList;
49
import java.util.ArrayList;
50
import java.util.Iterator;
50
import java.util.Iterator;
Lines 482-487 Link Here
482
      }
482
      }
483
483
484
      process(object, CDOEvent.ROLLBACK, null);
484
      process(object, CDOEvent.ROLLBACK, null);
485
      object.cdoInternalPostRollback();
485
    }
486
    }
486
    finally
487
    finally
487
    {
488
    {
(-)src/org/eclipse/emf/internal/cdo/query/CDOQueryResultIteratorImpl.java (-1 / +2 lines)
Lines 13-18 Link Here
13
13
14
import org.eclipse.emf.cdo.common.id.CDOID;
14
import org.eclipse.emf.cdo.common.id.CDOID;
15
import org.eclipse.emf.cdo.common.util.CDOQueryInfo;
15
import org.eclipse.emf.cdo.common.util.CDOQueryInfo;
16
import org.eclipse.emf.cdo.util.CDOUtil;
16
import org.eclipse.emf.cdo.view.CDOView;
17
import org.eclipse.emf.cdo.view.CDOView;
17
18
18
import org.eclipse.emf.common.util.EList;
19
import org.eclipse.emf.common.util.EList;
Lines 51-57 Link Here
51
        return null;
52
        return null;
52
      }
53
      }
53
54
54
      return (T)getView().getObject((CDOID)object, true);
55
      return (T)CDOUtil.getEObject(getView().getObject((CDOID)object, true));
55
    }
56
    }
56
57
57
    // Support a query return value of Object[]
58
    // Support a query return value of Object[]
(-)src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java (-24 / +4 lines)
Lines 63-75 Link Here
63
import org.eclipse.emf.internal.cdo.view.CDOViewImpl;
63
import org.eclipse.emf.internal.cdo.view.CDOViewImpl;
64
64
65
import org.eclipse.net4j.util.ObjectUtil;
65
import org.eclipse.net4j.util.ObjectUtil;
66
import org.eclipse.net4j.util.WrappedException;
67
import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
66
import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
67
import org.eclipse.net4j.util.WrappedException;
68
import org.eclipse.net4j.util.collection.Pair;
68
import org.eclipse.net4j.util.collection.Pair;
69
import org.eclipse.net4j.util.concurrent.IRWLockManager;
69
import org.eclipse.net4j.util.concurrent.IRWLockManager;
70
import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
70
import org.eclipse.net4j.util.concurrent.QueueRunner;
71
import org.eclipse.net4j.util.concurrent.QueueRunner;
71
import org.eclipse.net4j.util.concurrent.RWLockManager;
72
import org.eclipse.net4j.util.concurrent.RWLockManager;
72
import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
73
import org.eclipse.net4j.util.container.Container;
73
import org.eclipse.net4j.util.container.Container;
74
import org.eclipse.net4j.util.event.Event;
74
import org.eclipse.net4j.util.event.Event;
75
import org.eclipse.net4j.util.event.EventUtil;
75
import org.eclipse.net4j.util.event.EventUtil;
Lines 91-96 Link Here
91
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
91
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
92
import org.eclipse.emf.spi.cdo.AbstractQueryIterator;
92
import org.eclipse.emf.spi.cdo.AbstractQueryIterator;
93
import org.eclipse.emf.spi.cdo.CDOSessionProtocol;
93
import org.eclipse.emf.spi.cdo.CDOSessionProtocol;
94
import org.eclipse.emf.spi.cdo.CDOSessionProtocol.RefreshSessionResult;
94
import org.eclipse.emf.spi.cdo.InternalCDOObject;
95
import org.eclipse.emf.spi.cdo.InternalCDOObject;
95
import org.eclipse.emf.spi.cdo.InternalCDORemoteSessionManager;
96
import org.eclipse.emf.spi.cdo.InternalCDORemoteSessionManager;
96
import org.eclipse.emf.spi.cdo.InternalCDOSession;
97
import org.eclipse.emf.spi.cdo.InternalCDOSession;
Lines 98-104 Link Here
98
import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
99
import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
99
import org.eclipse.emf.spi.cdo.InternalCDOView;
100
import org.eclipse.emf.spi.cdo.InternalCDOView;
100
import org.eclipse.emf.spi.cdo.InternalCDOViewSet;
101
import org.eclipse.emf.spi.cdo.InternalCDOViewSet;
101
import org.eclipse.emf.spi.cdo.CDOSessionProtocol.RefreshSessionResult;
102
import org.eclipse.emf.spi.cdo.InternalCDOXATransaction.InternalCDOXACommitContext;
102
import org.eclipse.emf.spi.cdo.InternalCDOXATransaction.InternalCDOXACommitContext;
103
103
104
import java.text.MessageFormat;
104
import java.text.MessageFormat;
Lines 109-116 Link Here
109
import java.util.HashSet;
109
import java.util.HashSet;
110
import java.util.List;
110
import java.util.List;
111
import java.util.Map;
111
import java.util.Map;
112
import java.util.Set;
113
import java.util.Map.Entry;
112
import java.util.Map.Entry;
113
import java.util.Set;
114
114
115
/**
115
/**
116
 * @author Eike Stepper
116
 * @author Eike Stepper
Lines 957-982 Link Here
957
    super.doDeactivate();
957
    super.doDeactivate();
958
  }
958
  }
959
959
960
  // private Map<CDOID, CDOIDAndVersion> getAllCDOIDAndVersion()
961
  // {
962
  // Map<CDOID, CDOIDAndVersion> uniqueObjects = new HashMap<CDOID, CDOIDAndVersion>();
963
  // for (InternalCDOView view : getViews())
964
  // {
965
  // view.getCDOIDAndVersion(uniqueObjects, Arrays.asList(view.getObjectsArray()));
966
  // }
967
  //
968
  // // Need to add Revision from revisionManager since we do not have all objects in view.
969
  // for (CDORevision revision : getRevisionManager().getCache().getCurrentRevisions())
970
  // {
971
  // if (!uniqueObjects.containsKey(revision.getID()))
972
  // {
973
  // uniqueObjects.put(revision.getID(), CDOIDUtil.createIDAndVersion(revision.getID(), revision.getVersion()));
974
  // }
975
  // }
976
  //
977
  // return uniqueObjects;
978
  // }
979
980
  public static boolean isInvalidationRunnerActive()
960
  public static boolean isInvalidationRunnerActive()
981
  {
961
  {
982
    return invalidationRunnerActive.get();
962
    return invalidationRunnerActive.get();
(-)src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java (-4 / +16 lines)
Lines 76-85 Link Here
76
import org.eclipse.emf.cdo.transaction.CDOTransactionStartedEvent;
76
import org.eclipse.emf.cdo.transaction.CDOTransactionStartedEvent;
77
import org.eclipse.emf.cdo.transaction.CDOUserSavepoint;
77
import org.eclipse.emf.cdo.transaction.CDOUserSavepoint;
78
import org.eclipse.emf.cdo.util.CDOURIUtil;
78
import org.eclipse.emf.cdo.util.CDOURIUtil;
79
import org.eclipse.emf.cdo.util.LegacyModeNotEnabledException;
79
import org.eclipse.emf.cdo.util.ObjectNotFoundException;
80
import org.eclipse.emf.cdo.util.ObjectNotFoundException;
80
import org.eclipse.emf.cdo.view.CDOViewResourcesEvent;
81
import org.eclipse.emf.cdo.view.CDOViewResourcesEvent;
81
82
82
import org.eclipse.emf.internal.cdo.CDOObjectMerger;
83
import org.eclipse.emf.internal.cdo.CDOObjectMerger;
84
import org.eclipse.emf.internal.cdo.CDOObjectWrapper;
83
import org.eclipse.emf.internal.cdo.CDOStateMachine;
85
import org.eclipse.emf.internal.cdo.CDOStateMachine;
84
import org.eclipse.emf.internal.cdo.bundle.OM;
86
import org.eclipse.emf.internal.cdo.bundle.OM;
85
import org.eclipse.emf.internal.cdo.messages.Messages;
87
import org.eclipse.emf.internal.cdo.messages.Messages;
Lines 103-121 Link Here
103
import org.eclipse.emf.ecore.EObject;
105
import org.eclipse.emf.ecore.EObject;
104
import org.eclipse.emf.ecore.EPackage;
106
import org.eclipse.emf.ecore.EPackage;
105
import org.eclipse.emf.ecore.EReference;
107
import org.eclipse.emf.ecore.EReference;
106
import org.eclipse.emf.ecore.InternalEObject;
107
import org.eclipse.emf.ecore.EStructuralFeature.Setting;
108
import org.eclipse.emf.ecore.EStructuralFeature.Setting;
109
import org.eclipse.emf.ecore.InternalEObject;
108
import org.eclipse.emf.ecore.util.EContentsEList;
110
import org.eclipse.emf.ecore.util.EContentsEList;
109
import org.eclipse.emf.ecore.util.EcoreUtil;
110
import org.eclipse.emf.ecore.util.EContentsEList.FeatureIterator;
111
import org.eclipse.emf.ecore.util.EContentsEList.FeatureIterator;
112
import org.eclipse.emf.ecore.util.EcoreUtil;
111
import org.eclipse.emf.spi.cdo.CDOSessionProtocol;
113
import org.eclipse.emf.spi.cdo.CDOSessionProtocol;
114
import org.eclipse.emf.spi.cdo.CDOSessionProtocol.CommitTransactionResult;
112
import org.eclipse.emf.spi.cdo.CDOTransactionStrategy;
115
import org.eclipse.emf.spi.cdo.CDOTransactionStrategy;
113
import org.eclipse.emf.spi.cdo.InternalCDOObject;
116
import org.eclipse.emf.spi.cdo.InternalCDOObject;
114
import org.eclipse.emf.spi.cdo.InternalCDOSavepoint;
117
import org.eclipse.emf.spi.cdo.InternalCDOSavepoint;
115
import org.eclipse.emf.spi.cdo.InternalCDOSession;
118
import org.eclipse.emf.spi.cdo.InternalCDOSession;
116
import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
119
import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
117
import org.eclipse.emf.spi.cdo.InternalCDOUserSavepoint;
120
import org.eclipse.emf.spi.cdo.InternalCDOUserSavepoint;
118
import org.eclipse.emf.spi.cdo.CDOSessionProtocol.CommitTransactionResult;
119
121
120
import org.eclipse.core.runtime.IProgressMonitor;
122
import org.eclipse.core.runtime.IProgressMonitor;
121
import org.eclipse.core.runtime.NullProgressMonitor;
123
import org.eclipse.core.runtime.NullProgressMonitor;
Lines 132-140 Link Here
132
import java.util.Iterator;
134
import java.util.Iterator;
133
import java.util.List;
135
import java.util.List;
134
import java.util.Map;
136
import java.util.Map;
137
import java.util.Map.Entry;
135
import java.util.Set;
138
import java.util.Set;
136
import java.util.WeakHashMap;
139
import java.util.WeakHashMap;
137
import java.util.Map.Entry;
138
import java.util.concurrent.ConcurrentMap;
140
import java.util.concurrent.ConcurrentMap;
139
import java.util.concurrent.atomic.AtomicInteger;
141
import java.util.concurrent.atomic.AtomicInteger;
140
import java.util.concurrent.locks.ReentrantLock;
142
import java.util.concurrent.locks.ReentrantLock;
Lines 884-889 Link Here
884
        CDOTransactionStrategy transactionStrategy = getTransactionStrategy();
886
        CDOTransactionStrategy transactionStrategy = getTransactionStrategy();
885
        return transactionStrategy.commit(this, progressMonitor);
887
        return transactionStrategy.commit(this, progressMonitor);
886
      }
888
      }
889
      catch (LegacyModeNotEnabledException ex)
890
      {
891
        throw ex;
892
      }
887
      catch (TransactionException ex)
893
      catch (TransactionException ex)
888
      {
894
      {
889
        throw ex;
895
        throw ex;
Lines 2030-2037 Link Here
2030
    {
2036
    {
2031
      if (!objects.isEmpty())
2037
      if (!objects.isEmpty())
2032
      {
2038
      {
2039
        boolean noLegacy = !isLegacyModeEnabled();
2033
        for (CDOObject object : objects.values())
2040
        for (CDOObject object : objects.values())
2034
        {
2041
        {
2042
          if (noLegacy && object instanceof CDOObjectWrapper)
2043
          {
2044
            throw new LegacyModeNotEnabledException();
2045
          }
2046
2035
          ((InternalCDOObject)object).cdoInternalPreCommit();
2047
          ((InternalCDOObject)object).cdoInternalPreCommit();
2036
        }
2048
        }
2037
      }
2049
      }
(-)src/org/eclipse/emf/internal/cdo/util/FSMUtil.java (-8 / +7 lines)
Lines 18-23 Link Here
18
import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
18
import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
19
import org.eclipse.emf.cdo.util.CDOUtil;
19
import org.eclipse.emf.cdo.util.CDOUtil;
20
import org.eclipse.emf.cdo.util.InvalidObjectException;
20
import org.eclipse.emf.cdo.util.InvalidObjectException;
21
import org.eclipse.emf.cdo.util.LegacyModeNotEnabledException;
21
import org.eclipse.emf.cdo.util.ObjectNotFoundException;
22
import org.eclipse.emf.cdo.util.ObjectNotFoundException;
22
import org.eclipse.emf.cdo.view.CDOView;
23
import org.eclipse.emf.cdo.view.CDOView;
23
24
Lines 36-42 Link Here
36
import org.eclipse.emf.ecore.EPackage;
37
import org.eclipse.emf.ecore.EPackage;
37
import org.eclipse.emf.ecore.EcorePackage;
38
import org.eclipse.emf.ecore.EcorePackage;
38
import org.eclipse.emf.ecore.InternalEObject;
39
import org.eclipse.emf.ecore.InternalEObject;
39
import org.eclipse.emf.ecore.impl.DynamicEObjectImpl;
40
import org.eclipse.emf.ecore.util.EcoreUtil;
40
import org.eclipse.emf.ecore.util.EcoreUtil;
41
import org.eclipse.emf.spi.cdo.InternalCDOObject;
41
import org.eclipse.emf.spi.cdo.InternalCDOObject;
42
import org.eclipse.emf.spi.cdo.InternalCDOView;
42
import org.eclipse.emf.spi.cdo.InternalCDOView;
Lines 139-144 Link Here
139
139
140
    if (object instanceof InternalEObject)
140
    if (object instanceof InternalEObject)
141
    {
141
    {
142
      if (!view.isLegacyModeEnabled())
143
      {
144
        throw new LegacyModeNotEnabledException();
145
      }
146
142
      return adaptLegacy((InternalEObject)object);
147
      return adaptLegacy((InternalEObject)object);
143
    }
148
    }
144
149
Lines 175-191 Link Here
175
   */
180
   */
176
  public static InternalCDOObject adaptLegacy(InternalEObject object)
181
  public static InternalCDOObject adaptLegacy(InternalEObject object)
177
  {
182
  {
178
    if (object.getClass() == DynamicEObjectImpl.class)
179
    {
180
      throw new IllegalArgumentException(Messages.getString("FSMUtil.4") + object); //$NON-NLS-1$
181
    }
182
183
    EList<Adapter> adapters = object.eAdapters();
183
    EList<Adapter> adapters = object.eAdapters();
184
    CDOLegacyAdapter adapter = getLegacyAdapter(adapters);
184
    CDOLegacyAdapter adapter = getLegacyAdapter(adapters);
185
    if (adapter == null)
185
    if (adapter == null)
186
    {
186
    {
187
      adapter = new CDOLegacyAdapter();
187
      adapter = new CDOLegacyAdapter(object);
188
      adapters.add(adapter);
189
    }
188
    }
190
189
191
    return adapter;
190
    return adapter;
(-)src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java (-4 / +19 lines)
Lines 72-79 Link Here
72
import org.eclipse.emf.internal.cdo.util.FSMUtil;
72
import org.eclipse.emf.internal.cdo.util.FSMUtil;
73
73
74
import org.eclipse.net4j.util.ImplementationError;
74
import org.eclipse.net4j.util.ImplementationError;
75
import org.eclipse.net4j.util.StringUtil;
76
import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
75
import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
76
import org.eclipse.net4j.util.StringUtil;
77
import org.eclipse.net4j.util.collection.CloseableIterator;
77
import org.eclipse.net4j.util.collection.CloseableIterator;
78
import org.eclipse.net4j.util.collection.FastList;
78
import org.eclipse.net4j.util.collection.FastList;
79
import org.eclipse.net4j.util.collection.HashBag;
79
import org.eclipse.net4j.util.collection.HashBag;
Lines 100-111 Link Here
100
import org.eclipse.emf.ecore.resource.ResourceSet;
100
import org.eclipse.emf.ecore.resource.ResourceSet;
101
import org.eclipse.emf.ecore.util.EcoreUtil;
101
import org.eclipse.emf.ecore.util.EcoreUtil;
102
import org.eclipse.emf.spi.cdo.CDOSessionProtocol;
102
import org.eclipse.emf.spi.cdo.CDOSessionProtocol;
103
import org.eclipse.emf.spi.cdo.CDOSessionProtocol.RefreshSessionResult;
103
import org.eclipse.emf.spi.cdo.InternalCDOObject;
104
import org.eclipse.emf.spi.cdo.InternalCDOObject;
104
import org.eclipse.emf.spi.cdo.InternalCDOSession;
105
import org.eclipse.emf.spi.cdo.InternalCDOSession;
105
import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
106
import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
106
import org.eclipse.emf.spi.cdo.InternalCDOView;
107
import org.eclipse.emf.spi.cdo.InternalCDOView;
107
import org.eclipse.emf.spi.cdo.InternalCDOViewSet;
108
import org.eclipse.emf.spi.cdo.InternalCDOViewSet;
108
import org.eclipse.emf.spi.cdo.CDOSessionProtocol.RefreshSessionResult;
109
109
110
import java.text.MessageFormat;
110
import java.text.MessageFormat;
111
import java.util.ArrayList;
111
import java.util.ArrayList;
Lines 115-122 Link Here
115
import java.util.HashSet;
115
import java.util.HashSet;
116
import java.util.List;
116
import java.util.List;
117
import java.util.Map;
117
import java.util.Map;
118
import java.util.Set;
119
import java.util.Map.Entry;
118
import java.util.Map.Entry;
119
import java.util.Set;
120
import java.util.concurrent.ConcurrentMap;
120
import java.util.concurrent.ConcurrentMap;
121
import java.util.concurrent.locks.ReentrantLock;
121
import java.util.concurrent.locks.ReentrantLock;
122
122
Lines 127-132 Link Here
127
{
127
{
128
  private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_VIEW, CDOViewImpl.class);
128
  private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_VIEW, CDOViewImpl.class);
129
129
130
  private final boolean legacyModeEnabled;
131
130
  private int viewID;
132
  private int viewID;
131
133
132
  private InternalCDOSession session;
134
  private InternalCDOSession session;
Lines 176-181 Link Here
176
  public CDOViewImpl(CDOBranch branch, long timeStamp)
178
  public CDOViewImpl(CDOBranch branch, long timeStamp)
177
  {
179
  {
178
    branchPoint = branch.getPoint(timeStamp);
180
    branchPoint = branch.getPoint(timeStamp);
181
    legacyModeEnabled = CDOUtil.isLegacyModeDefault();
179
    options = createOptions();
182
    options = createOptions();
180
  }
183
  }
181
184
Lines 205-210 Link Here
205
    return true;
208
    return true;
206
  }
209
  }
207
210
211
  public boolean isLegacyModeEnabled()
212
  {
213
    return legacyModeEnabled;
214
  }
215
208
  public ResourceSet getResourceSet()
216
  public ResourceSet getResourceSet()
209
  {
217
  {
210
    return viewSet.getResourceSet();
218
    return viewSet.getResourceSet();
Lines 1270-1276 Link Here
1270
1278
1271
    if (old != null)
1279
    if (old != null)
1272
    {
1280
    {
1273
      throw new IllegalStateException(MessageFormat.format(Messages.getString("CDOViewImpl.20"), object)); //$NON-NLS-1$
1281
      if (CDOUtil.isLegacyObject(object))
1282
      {
1283
        OM.LOG.warn("Legacy object has been registered multiple times: " + object);
1284
      }
1285
      else
1286
      {
1287
        throw new IllegalStateException(MessageFormat.format(Messages.getString("CDOViewImpl.20"), object)); //$NON-NLS-1$
1288
      }
1274
    }
1289
    }
1275
  }
1290
  }
1276
1291
(-)src/org/eclipse/emf/spi/cdo/AbstractObjectConflictResolver.java (-1 / +2 lines)
Lines 129-134 Link Here
129
    merger.merge(revision, revisionDelta);
129
    merger.merge(revision, revisionDelta);
130
    ((InternalCDOObject)object).cdoInternalSetRevision(revision);
130
    ((InternalCDOObject)object).cdoInternalSetRevision(revision);
131
    ((InternalCDOObject)object).cdoInternalSetState(CDOState.DIRTY);
131
    ((InternalCDOObject)object).cdoInternalSetState(CDOState.DIRTY);
132
    ((InternalCDOObject)object).cdoInternalPostLoad();
132
  }
133
  }
133
134
134
  /**
135
  /**
Lines 239-245 Link Here
239
240
240
      public List<CDORevisionDelta> getRevisionDeltas(CDOObject notifier)
241
      public List<CDORevisionDelta> getRevisionDeltas(CDOObject notifier)
241
      {
242
      {
242
        List<CDORevisionDelta> list = deltas.get(notifier);
243
        List<CDORevisionDelta> list = deltas.get(CDOUtil.getEObject(notifier));
243
        if (list == null)
244
        if (list == null)
244
        {
245
        {
245
          return Collections.emptyList();
246
          return Collections.emptyList();
(-)src/org/eclipse/emf/spi/cdo/InternalCDOObject.java (+6 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *    Eike Stepper - initial API and implementation
9
 *    Eike Stepper - initial API and implementation
10
 *    Martin Flügge - enhancements
10
 */
11
 */
11
package org.eclipse.emf.spi.cdo;
12
package org.eclipse.emf.spi.cdo;
12
13
Lines 39-44 Link Here
39
40
40
  public void cdoInternalPostInvalidate();
41
  public void cdoInternalPostInvalidate();
41
42
43
  /**
44
   * @since 3.0
45
   */
46
  public void cdoInternalPostRollback();
47
42
  public void cdoInternalPreCommit();
48
  public void cdoInternalPreCommit();
43
49
44
  public void cdoInternalSetID(CDOID id);
50
  public void cdoInternalSetID(CDOID id);
(-)CDO (+15 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
3
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
4
<listEntry value="/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsLegacy.java"/>
5
</listAttribute>
6
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
7
<listEntry value="1"/>
8
</listAttribute>
9
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
10
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
11
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
12
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
13
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.AllTestsLegacy"/>
14
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests"/>
15
</launchConfiguration>
(-)src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java (+2 lines)
Lines 130-135 Link Here
130
    testClasses.add(ConflictResolverTest.class);
130
    testClasses.add(ConflictResolverTest.class);
131
    testClasses.add(DynamicXSDTest.class);
131
    testClasses.add(DynamicXSDTest.class);
132
    testClasses.add(SetFeatureTest.class);
132
    testClasses.add(SetFeatureTest.class);
133
    testClasses.add(DynamicPackageTest.class);
134
    testClasses.add(LegacyTest.class);
133
135
134
    // Specific for MEMStore
136
    // Specific for MEMStore
135
    testClasses.add(MEMStoreQueryTest.class);
137
    testClasses.add(MEMStoreQueryTest.class);
(-)src/org/eclipse/emf/cdo/tests/AllTestsLegacy.java (-41 / +6 lines)
Lines 10-25 Link Here
10
 */
10
 */
11
package org.eclipse.emf.cdo.tests;
11
package org.eclipse.emf.cdo.tests;
12
12
13
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_246622_Test;
14
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_248915_Test;
15
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_251263_Test;
16
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_254489_Test;
17
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_258933_Test;
18
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_259695_Test;
19
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_260756_Test;
20
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_266982_Test;
21
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_273565_Test;
22
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_279982_Test;
23
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
13
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
24
14
25
import java.util.List;
15
import java.util.List;
Lines 40-78 Link Here
40
  @Override
30
  @Override
41
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses)
31
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses)
42
  {
32
  {
43
    // testClasses.add(ChunkingTest.class);
44
    super.initTestClasses(testClasses);
33
    super.initTestClasses(testClasses);
34
    // testClasses.add(PerformanceTest.class);
45
35
46
    testClasses.remove(ComplexTest.class);
36
    // testClasses.add(ExternalReferenceTest.class); // null value contraint violated
47
    testClasses.remove(UnsetTest.class);
37
    // testClasses.add(XATransactionTest.class);// we shoudl have an exception here
48
    testClasses.remove(PushTransactionTest.class); // ArrayStoreException
38
49
    testClasses.remove(ContainmentTest.class); // ArrayStoreException/NullpointerException in Transaction
39
    // // Legacy only
50
    testClasses.remove(RollbackTest.class); // Failures
40
    // testClasses.add(GMFTest.class);
51
    testClasses.remove(CrossReferenceTest.class); // Failures
52
    testClasses.remove(ChunkingTest.class); // ArrayStoreException / ClassCastExecption
53
    testClasses.remove(ChunkingWithMEMTest.class); // java.lang.ClassCastException
54
    testClasses.remove(MetaTest.class); // wa // NullPointer
55
    testClasses.remove(AutoAttacherTest.class); // transaction failure
56
    testClasses.remove(SavePointTest.class);
57
    testClasses.remove(ChangeSubscriptionTest.class); // timeout
58
    testClasses.remove(ExternalReferenceTest.class); // NullPointerException / ObjectNotFoundException
59
    testClasses.remove(XATransactionTest.class);
60
    testClasses.remove(LockingManagerTest.class); // Locking not support in Legacy Mode
61
    testClasses.remove(MultiValuedOfAttributeTest.class); // java.lang.ArrayStoreException
62
    testClasses.remove(ConflictResolverTest.class); // null value in Attribute
63
64
    //
65
    // Bugzilla verifications
66
    testClasses.remove(Bugzilla_246622_Test.class);
67
    testClasses.remove(Bugzilla_248915_Test.class); // Failure incomplete resource
68
    testClasses.remove(Bugzilla_251263_Test.class);
69
    testClasses.remove(Bugzilla_254489_Test.class); // timeout
70
    testClasses.remove(Bugzilla_258933_Test.class);
71
    testClasses.remove(Bugzilla_259695_Test.class); // ArrayIndexOutOfBounds
72
    testClasses.remove(Bugzilla_260756_Test.class); // ArrayStoreException
73
    testClasses.remove(Bugzilla_266982_Test.class);
74
    testClasses.remove(Bugzilla_273565_Test.class); // locking not supported
75
    testClasses.remove(Bugzilla_279982_Test.class);
76
  }
41
  }
77
42
78
  @Override
43
  @Override
(-)src/org/eclipse/emf/cdo/tests/BranchingTest.java (-1 / +1 lines)
Lines 691-697 Link Here
691
691
692
    CDOID id = CDOUtil.getCDOObject(product).cdoID();
692
    CDOID id = CDOUtil.getCDOObject(product).cdoID();
693
    CDOView view = session.openView();
693
    CDOView view = session.openView();
694
    product = (Product1)view.getObject(id);
694
    product = (Product1)CDOUtil.getEObject(view.getObject(id));
695
695
696
    view.setBranch(subBranch);
696
    view.setBranch(subBranch);
697
697
(-)src/org/eclipse/emf/cdo/tests/ChangeSubscriptionTest.java (-2 / +2 lines)
Lines 611-617 Link Here
611
      }
611
      }
612
    }.assertNoTimeOut();
612
    }.assertNoTimeOut();
613
613
614
    assertInstanceOf(Category.class, oldValue[0]);
614
    assertInstanceOf(Category.class, CDOUtil.getEObject((EObject)oldValue[0]));
615
  }
615
  }
616
616
617
  public void testRemoveManyContained() throws Exception
617
  public void testRemoveManyContained() throws Exception
Lines 740-746 Link Here
740
      }
740
      }
741
    }.assertNoTimeOut();
741
    }.assertNoTimeOut();
742
742
743
    assertInstanceOf(OrderDetail.class, oldValue[0]);
743
    assertInstanceOf(OrderDetail.class, CDOUtil.getEObject((EObject)oldValue[0]));
744
  }
744
  }
745
745
746
  public void testRemoveManyXRef() throws Exception
746
  public void testRemoveManyXRef() throws Exception
(-)src/org/eclipse/emf/cdo/tests/ConflictResolverTest.java (+3 lines)
Lines 60-65 Link Here
60
60
61
  public void testMergeLocalChangesPerFeature_BasicException() throws Exception
61
  public void testMergeLocalChangesPerFeature_BasicException() throws Exception
62
  {
62
  {
63
    // Does not work in legacy as long as there is not getter interception
64
    skipConfig(LEGACY);
65
63
    msg("Opening session");
66
    msg("Opening session");
64
    CDOSession session = openSession();
67
    CDOSession session = openSession();
65
68
(-)src/org/eclipse/emf/cdo/tests/ContainmentTest.java (-3 / +8 lines)
Lines 404-410 Link Here
404
    assertEquals(resource1.getContents().get(0), order.eContainer());
404
    assertEquals(resource1.getContents().get(0), order.eContainer());
405
    resource2.getContents().remove(order);
405
    resource2.getContents().remove(order);
406
406
407
    Order order2 = (Order)container.eGet(container.eClass().getEStructuralFeature("proxyElement"));
407
    Order order2 = (Order)CDOUtil.getEObject((EObject)container.eGet(container.eClass().getEStructuralFeature(
408
        "proxyElement")));
408
    assertSame(order, order2);
409
    assertSame(order, order2);
409
  }
410
  }
410
411
Lines 453-459 Link Here
453
    assertEquals(resource1.getContents().get(0), order.eContainer());
454
    assertEquals(resource1.getContents().get(0), order.eContainer());
454
    resource2.getContents().remove(order);
455
    resource2.getContents().remove(order);
455
456
456
    Order order2 = (Order)container.eGet(container.eClass().getEStructuralFeature("proxyElement"));
457
    Order order2 = (Order)CDOUtil.getEObject((EObject)container.eGet(container.eClass().getEStructuralFeature(
458
        "proxyElement")));
457
    assertSame(order, order2);
459
    assertSame(order, order2);
458
  }
460
  }
459
461
Lines 632-639 Link Here
632
    schoolPackage.setNsPrefix("elv");
634
    schoolPackage.setNsPrefix("elv");
633
    schoolPackage.setNsURI("http:///www.elver.org/School");
635
    schoolPackage.setNsURI("http:///www.elver.org/School");
634
    schoolPackage.getEClassifiers().add(schoolBookEClass);
636
    schoolPackage.getEClassifiers().add(schoolBookEClass);
637
    if (!isConfig(LEGACY))
638
    {
639
      CDOUtil.prepareDynamicEPackage(schoolPackage);
640
    }
635
641
636
    CDOUtil.prepareDynamicEPackage(schoolPackage);
637
    return schoolPackage;
642
    return schoolPackage;
638
  }
643
  }
639
644
(-)src/org/eclipse/emf/cdo/tests/CrossReferenceTest.java (-1 / +1 lines)
Lines 319-325 Link Here
319
319
320
    company.getCustomers().remove(customer);
320
    company.getCustomers().remove(customer);
321
    company.getCustomers().add(customer);
321
    company.getCustomers().add(customer);
322
322
    assertEquals(1, company.getCustomers().size());
323
    transaction.commit();
323
    transaction.commit();
324
  }
324
  }
325
325
(-)src/org/eclipse/emf/cdo/tests/DynamicPackageTest.java (+87 lines)
Added Link Here
1
/**
2
 * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *    Martin Fluegge - initial API and implementation
10
 */
11
package org.eclipse.emf.cdo.tests;
12
13
import org.eclipse.emf.cdo.eresource.CDOResource;
14
import org.eclipse.emf.cdo.session.CDOSession;
15
import org.eclipse.emf.cdo.transaction.CDOTransaction;
16
import org.eclipse.emf.cdo.util.CDOUtil;
17
18
import org.eclipse.emf.internal.cdo.DynamicCDOObjectImpl;
19
20
import org.eclipse.emf.ecore.EClass;
21
import org.eclipse.emf.ecore.EFactory;
22
import org.eclipse.emf.ecore.EObject;
23
import org.eclipse.emf.ecore.EPackage;
24
import org.eclipse.emf.ecore.EStructuralFeature;
25
import org.eclipse.emf.ecore.EcoreFactory;
26
import org.eclipse.emf.ecore.EcorePackage;
27
import org.eclipse.emf.ecore.impl.DynamicEObjectImpl;
28
29
/**
30
 * @author Martin Fluegge
31
 */
32
public class DynamicPackageTest extends AbstractCDOTest
33
{
34
  protected static EClass mapContainerEClass;
35
36
  public void testDynamicMaps() throws Exception
37
  {
38
    CDOSession session = openSession();
39
    CDOTransaction transaction = session.openTransaction();
40
    EPackage dynamicMapEPackge = createPackage();
41
    EFactory dynamicMapEFactoryInstance = dynamicMapEPackge.getEFactoryInstance();
42
43
    CDOResource resource = transaction.createResource("/test1");
44
    EObject mapContainer = dynamicMapEFactoryInstance.create((EClass)dynamicMapEPackge.getEClassifier("MapContainer"));
45
46
    resource.getContents().add(mapContainer);
47
    transaction.commit();
48
49
    if (!isConfig(LEGACY))
50
    {
51
      assertTrue(mapContainer instanceof DynamicCDOObjectImpl);
52
    }
53
    else
54
    {
55
      assertTrue(mapContainer instanceof DynamicEObjectImpl);
56
    }
57
  }
58
59
  public EPackage createPackage()
60
  {
61
    EcoreFactory theCoreFactory = EcoreFactory.eINSTANCE;
62
    EcorePackage theCorePackage = EcorePackage.eINSTANCE;
63
64
    mapContainerEClass = theCoreFactory.createEClass();
65
    mapContainerEClass.setName("MapContainer");
66
67
    EPackage dynamicMapEPackage = theCoreFactory.createEPackage();
68
    dynamicMapEPackage.setName("DynamicMapPackage");
69
    dynamicMapEPackage.setNsPrefix("dynamicmap");
70
    dynamicMapEPackage.setNsURI("http:///org.mftech.examples.emf.dynamic.map");
71
72
    dynamicMapEPackage.getEClassifiers().add(mapContainerEClass);
73
74
    EStructuralFeature name = theCoreFactory.createEAttribute();
75
    name.setName("name");
76
    name.setEType(theCorePackage.getEString());
77
78
    mapContainerEClass.getEStructuralFeatures().add(name);
79
80
    if (!isConfig(LEGACY))
81
    {
82
      CDOUtil.prepareDynamicEPackage(dynamicMapEPackage);
83
    }
84
85
    return dynamicMapEPackage;
86
  }
87
}
(-)src/org/eclipse/emf/cdo/tests/FeatureMapTest.java (-2 / +4 lines)
Lines 111-118 Link Here
111
    ExtendedMetaData.INSTANCE.setGroup(bool, fMap);
111
    ExtendedMetaData.INSTANCE.setGroup(bool, fMap);
112
    ExtendedMetaData.INSTANCE.setGroup(ref1, fMap);
112
    ExtendedMetaData.INSTANCE.setGroup(ref1, fMap);
113
    ExtendedMetaData.INSTANCE.setGroup(ref2, fMap);
113
    ExtendedMetaData.INSTANCE.setGroup(ref2, fMap);
114
114
    if (!isConfig(LEGACY))
115
    CDOUtil.prepareDynamicEPackage(pkg);
115
    {
116
      CDOUtil.prepareDynamicEPackage(pkg);
117
    }
116
118
117
    dummyObj = pkg.getEFactoryInstance().create(dummy);
119
    dummyObj = pkg.getEFactoryInstance().create(dummy);
118
    dummyObj.eSet(name, "DummyName");
120
    dummyObj.eSet(name, "DummyName");
(-)src/org/eclipse/emf/cdo/tests/LegacyTest.java (-117 / +39 lines)
Lines 4-134 Link Here
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *    Eike Stepper - initial API and implementation
9
 *    Eike Stepper - initial API and implementation
10
 *    Martin Fluegge - recreation of the test case
10
 */
11
 */
11
package org.eclipse.emf.cdo.tests;
12
package org.eclipse.emf.cdo.tests;
12
13
14
import org.eclipse.emf.cdo.eresource.CDOResource;
15
import org.eclipse.emf.cdo.session.CDOSession;
16
import org.eclipse.emf.cdo.tests.model1.Customer;
17
import org.eclipse.emf.cdo.transaction.CDOTransaction;
18
import org.eclipse.emf.cdo.util.CDOUtil;
19
import org.eclipse.emf.cdo.util.LegacyModeNotEnabledException;
20
13
/**
21
/**
14
 * @author Eike Stepper
22
 * @author Eike Stepper
15
 */
23
 */
16
public class LegacyTest extends AbstractCDOTest
24
public class LegacyTest extends AbstractCDOTest
17
{
25
{
18
  // TODO LEGACY
26
  public void testLegacyModeEnabled() throws Exception
19
  // public void testCommit() throws Exception
27
  {
20
  // {
28
    Customer customer = getModel1Factory().createCustomer();
21
  // Hook hook = createHook("Mr. Hook");
29
    customer.setName("Martin Fluegge");
22
  //
30
    customer.setStreet("ABC Street 7");
23
  // CDOSession session = openLegacySession();
31
    customer.setCity("Berlin");
24
  // CDOTransaction transaction = session.openTransaction();
32
25
  // CDOResource resource = transaction.createResource("/test1");
33
    CDOSession session = openSession();
26
  // resource.getContents().add(hook);
34
    CDOUtil.setLegacyModeDefault(false);
27
  // transaction.commit();
35
    CDOTransaction transaction = session.openTransaction();
28
  //
36
    CDOResource resource = transaction.createResource("/test1");
29
  // CDOObject cdoHook = CDONet4jUtil.getCDOObject(hook);
37
30
  // assertEquals(false, CDOLegacyWrapper.isLegacyProxy(cdoHook));
38
    try
31
  // assertEquals(CDOState.CLEAN, cdoHook.cdoState());
39
    {
32
  // assertEquals(CDOState.CLEAN, resource.cdoState());
40
      resource.getContents().add(customer);
33
  // session.close();
41
      transaction.commit();
34
  // }
42
35
  //
43
      if (isConfig(LEGACY))
36
  // public void testLoad() throws Exception
44
      {
37
  // {
45
        fail("LegacyModeNotEnabledException expected");
38
  // {
46
      }
39
  // CDOSession session = openLegacySession();
47
    }
40
  // CDOTransaction transaction = session.openTransaction();
48
    catch (LegacyModeNotEnabledException ex)
41
  // CDOResource resource = transaction.createResource("/test1");
49
    {
42
  // resource.getContents().add(createHook("Mr. Hook"));
50
      if (!isConfig(LEGACY))
43
  // transaction.commit();
51
      {
44
  // session.close();
52
        fail("Native mode should not throw an exception here (" + ex.getMessage() + ")");
45
  // }
53
      }
46
  //
54
    }
47
  // CDOSession session = openLegacySession();
55
  }
48
  // CDOTransaction transaction = session.openTransaction();
49
  // CDOResource resource = transaction.getResource("/test1");
50
  // EList<EObject> contents = resource.getContents();
51
  //
52
  // Hook hook = (Hook)contents.get(0);
53
  // CDOObject cdoHook = CDONet4jUtil.getCDOObject(hook);
54
  // assertEquals(false, CDOLegacyWrapper.isLegacyProxy(cdoHook));
55
  // assertEquals(CDOState.CLEAN, cdoHook.cdoState());
56
  // assertEquals(CDOState.CLEAN, resource.cdoState());
57
  //
58
  // String name = hook.getName();
59
  // assertEquals("Mr. Hook", name);
60
  // assertEquals(CDOState.CLEAN, cdoHook.cdoState());
61
  // session.close();
62
  // }
63
  //
64
  // public void testReferences() throws Exception
65
  // {
66
  // {
67
  // Hook hook = createHook("Mr. Hook");
68
  // EList<Hook> children = hook.getChildren();
69
  // children.add(createHook("Hook 1"));
70
  // children.add(createHook("Hook 2"));
71
  // children.add(createHook("Hook 3"));
72
  //
73
  // CDOSession session = openLegacySession();
74
  // CDOTransaction transaction = session.openTransaction();
75
  // CDOResource resource = transaction.createResource("/test1");
76
  // resource.getContents().add(hook);
77
  // transaction.commit();
78
  //
79
  // CDOObject cdoHook = CDONet4jUtil.getCDOObject(hook);
80
  // assertEquals(false, CDOLegacyWrapper.isLegacyProxy(cdoHook));
81
  // assertEquals(CDOState.CLEAN, cdoHook.cdoState());
82
  // assertEquals(CDOState.CLEAN, resource.cdoState());
83
  // session.close();
84
  // }
85
  //
86
  // CDOSession session = openLegacySession();
87
  // CDOTransaction transaction = session.openTransaction();
88
  // CDOResource resource = transaction.getResource("/test1");
89
  // EList<EObject> contents = resource.getContents();
90
  //
91
  // Hook hook = (Hook)contents.get(0);
92
  // assertNotProxy(hook);
93
  //
94
  // CDOObject cdoHook = CDONet4jUtil.getCDOObject(hook);
95
  // assertEquals(false, CDOLegacyWrapper.isLegacyProxy(cdoHook));
96
  // assertEquals(CDOState.CLEAN, cdoHook.cdoState());
97
  //
98
  // EList<Hook> children = hook.getChildren();
99
  // assertEquals(CDOState.CLEAN, cdoHook.cdoState());
100
  // assertEquals(CDOState.CLEAN, resource.cdoState());
101
  //
102
  // // TODO Should the proxyURI be null for CLEAN?
103
  // // Hook h = children.get(0);
104
  // // URI proxyURI = ((InternalEObject)h).eProxyURI();
105
  // // assertEquals(null,proxyURI);
106
  //
107
  // int size = children.size();
108
  // assertEquals(3, size);
109
  // assertEquals(CDOState.CLEAN, cdoHook.cdoState());
110
  //
111
  // Hook h0 = children.get(0);
112
  // assertNotProxy(h0);
113
  // assertEquals("Hook 1", h0.getName());
114
  // assertEquals(CDOState.CLEAN, CDONet4jUtil.getCDOObject(h0).cdoState());
115
  //
116
  // Hook h1 = children.get(1);
117
  // assertNotProxy(h1);
118
  // assertEquals("Hook 2", h1.getName());
119
  // assertEquals(CDOState.CLEAN, CDONet4jUtil.getCDOObject(h1).cdoState());
120
  //
121
  // Hook h2 = children.get(2);
122
  // assertNotProxy(h2);
123
  // assertEquals("Hook 3", h2.getName());
124
  // assertEquals(CDOState.CLEAN, CDONet4jUtil.getCDOObject(h2).cdoState());
125
  // session.close();
126
  // }
127
  //
128
  // private Hook createHook(String name)
129
  // {
130
  // Hook hook = LegacyFactory.eINSTANCE.createHook();
131
  // hook.setName(name);
132
  // return hook;
133
  // }
134
}
56
}
(-)src/org/eclipse/emf/cdo/tests/LockingManagerTest.java (-1 / +1 lines)
Lines 586-592 Link Here
586
586
587
    cdoCompany1.cdoWriteLock().lock();
587
    cdoCompany1.cdoWriteLock().lock();
588
    assertEquals(true, cdoCompany1.cdoWriteLock().isLocked());
588
    assertEquals(true, cdoCompany1.cdoWriteLock().isLocked());
589
    Company companyFrom2 = (Company)transaction2.getObject(cdoCompany2.cdoID());
589
    Company companyFrom2 = (Company)CDOUtil.getEObject(transaction2.getObject(cdoCompany2.cdoID()));
590
    companyFrom2.setCity("sss");
590
    companyFrom2.setCity("sss");
591
    transaction2.commit();
591
    transaction2.commit();
592
    assertEquals(true, cdoCompany1.cdoWriteLock().isLocked());
592
    assertEquals(true, cdoCompany1.cdoWriteLock().isLocked());
(-)src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java (-3 / +13 lines)
Lines 28-33 Link Here
28
import org.eclipse.emf.cdo.tests.model3.subpackage.Class2;
28
import org.eclipse.emf.cdo.tests.model3.subpackage.Class2;
29
import org.eclipse.emf.cdo.transaction.CDOTransaction;
29
import org.eclipse.emf.cdo.transaction.CDOTransaction;
30
import org.eclipse.emf.cdo.util.CDOUtil;
30
import org.eclipse.emf.cdo.util.CDOUtil;
31
import org.eclipse.emf.cdo.util.LegacyModeNotEnabledException;
31
32
32
import org.eclipse.emf.common.util.EList;
33
import org.eclipse.emf.common.util.EList;
33
import org.eclipse.emf.common.util.URI;
34
import org.eclipse.emf.common.util.URI;
Lines 299-305 Link Here
299
      c.setName("DClass");
300
      c.setName("DClass");
300
301
301
      p.getEClassifiers().add(c);
302
      p.getEClassifiers().add(c);
302
      CDOUtil.prepareDynamicEPackage(p);
303
      if (!isConfig(LEGACY))
304
      {
305
        CDOUtil.prepareDynamicEPackage(p);
306
      }
307
303
      EPackage.Registry.INSTANCE.put(nsURI, p);
308
      EPackage.Registry.INSTANCE.put(nsURI, p);
304
309
305
      CDOSession session = openSession();
310
      CDOSession session = openSession();
Lines 337-342 Link Here
337
      EPackage.Registry.INSTANCE.put(nsURI, p);
342
      EPackage.Registry.INSTANCE.put(nsURI, p);
338
343
339
      CDOSession session = openSession();
344
      CDOSession session = openSession();
345
346
      // The default case is that legacy is disabled. For our test bed it is always enabled.
347
      // To test the default case we must switch of legacy here.
348
      CDOUtil.setLegacyModeDefault(false);
349
340
      CDOTransaction transaction = session.openTransaction();
350
      CDOTransaction transaction = session.openTransaction();
341
      CDOResource res = transaction.createResource("/res");
351
      CDOResource res = transaction.createResource("/res");
342
352
Lines 347-355 Link Here
347
      transaction.commit();
357
      transaction.commit();
348
      session.close();
358
      session.close();
349
359
350
      fail("Expected: IllegalArgumentException: Use CDOFactory to create dynamic object");
360
      fail("LegacyModeNotEnabledException expected");
351
    }
361
    }
352
    catch (IllegalArgumentException success)
362
    catch (LegacyModeNotEnabledException expected)
353
    {
363
    {
354
      // SUCCESS
364
      // SUCCESS
355
    }
365
    }
(-)src/org/eclipse/emf/cdo/tests/PerformanceTest.java (+379 lines)
Added Link Here
1
/**
2
 * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *    Martin Fluegge - initial API and implementation
10
 */
11
package org.eclipse.emf.cdo.tests;
12
13
import org.eclipse.emf.cdo.eresource.CDOResource;
14
import org.eclipse.emf.cdo.session.CDOSession;
15
import org.eclipse.emf.cdo.tests.model1.Customer;
16
import org.eclipse.emf.cdo.tests.model1.SalesOrder;
17
import org.eclipse.emf.cdo.transaction.CDOTransaction;
18
import org.eclipse.emf.cdo.util.CDOUtil;
19
20
import org.eclipse.net4j.util.io.IOUtil;
21
22
import org.eclipse.emf.ecore.EClass;
23
import org.eclipse.emf.ecore.EObject;
24
import org.eclipse.emf.ecore.EPackage;
25
import org.eclipse.emf.ecore.EStructuralFeature;
26
import org.eclipse.emf.ecore.EcoreFactory;
27
import org.eclipse.emf.ecore.EcorePackage;
28
29
import org.junit.AfterClass;
30
31
import java.io.File;
32
import java.io.FileWriter;
33
import java.io.IOException;
34
import java.util.Date;
35
import java.util.HashMap;
36
import java.util.Map;
37
38
/**
39
 * @author Martin Fluegge
40
 */
41
public class PerformanceTest extends AbstractCDOTest
42
{
43
  protected static EClass mapContainerEClass;
44
45
  private static Map<String, TimeTaker> results = new HashMap<String, TimeTaker>();
46
47
  public void testSimpleTestNoCommit() throws Exception
48
  {
49
    TimeTaker t = start("testSimpleTestNoCommit");
50
51
    getModel1Factory().createCustomer();
52
    for (int i = 0; i < 50000; i++)
53
    {
54
      Customer customer = getModel1Factory().createCustomer();
55
      customer.setCity("Barovia");
56
      customer.setName("Strahd von Zarovich");
57
      customer.setStreet("Necromancer Road 5");
58
59
      for (int c = 0; c < 50; c++)
60
      {
61
        SalesOrder salesOrder = getModel1Factory().createSalesOrder();
62
        salesOrder.setCustomer(customer);
63
        salesOrder.setId(c);
64
      }
65
    }
66
67
    finish(t);
68
    msg(t.getTiming());
69
  }
70
71
  public void testSimpleTestWithCommit() throws Exception
72
  {
73
    TimeTaker t = start("testBasicCommitPerformance");
74
75
    CDOSession session = openSession();
76
    CDOTransaction transaction = session.openTransaction();
77
    CDOResource resource = transaction.createResource("/test1");
78
    getModel1Factory().createCustomer();
79
    for (int i = 0; i < 500; i++)
80
    {
81
      Customer customer = getModel1Factory().createCustomer();
82
      customer.setCity("Barovia");
83
      customer.setName("Strahd von Zarovich");
84
      customer.setStreet("Necromancer Road 5");
85
86
      for (int c = 0; c < 5; c++)
87
      {
88
        SalesOrder salesOrder = getModel1Factory().createSalesOrder();
89
        salesOrder.setCustomer(customer);
90
        salesOrder.setId(c);
91
        resource.getContents().add(salesOrder);
92
      }
93
94
      resource.getContents().add(customer);
95
    }
96
97
    transaction.commit();
98
99
    finish(t);
100
    msg(t.getTiming());
101
  }
102
103
  // public void testDynamicPerformance() throws Exception
104
  // {
105
  //
106
  // TimeTaker t = start("testDynamicPerformance");
107
  // CDOSession session = openSession();
108
  // CDOTransaction transaction = session.openTransaction();
109
  // EPackage dynamicMapEPackge = createPackage();
110
  // EFactory dynamicMapEFactoryInstance = dynamicMapEPackge.getEFactoryInstance();
111
  //
112
  // CDOResource resource = transaction.createResource("/test1");
113
  // for (int i = 0; i < 5000; i++)
114
  // {
115
  //
116
  // EObject mapContainer = dynamicMapEFactoryInstance
117
  // .create((EClass)dynamicMapEPackge.getEClassifier("MapContainer"));
118
  //
119
  // resource.getContents().add(mapContainer);
120
  //
121
  // }
122
  // transaction.commit();
123
  //
124
  // finish(t);
125
  // }
126
127
  public void testLoadAnStoreDataPerformance() throws Exception
128
  {
129
    TimeTaker t = start("testLoadAnStoreDataPerformance");
130
131
    {
132
      CDOSession session = openSession();
133
      CDOTransaction transaction = session.openTransaction();
134
      CDOResource resource = transaction.createResource("/test1");
135
      getModel1Factory().createCustomer();
136
      for (int i = 0; i < 500; i++)
137
      {
138
        Customer customer = getModel1Factory().createCustomer();
139
        customer.setCity("Barovia");
140
        customer.setName("Strahd von Zarovich");
141
        customer.setStreet("Necromancer Road 5");
142
143
        for (int c = 0; c < 5; c++)
144
        {
145
          SalesOrder salesOrder = getModel1Factory().createSalesOrder();
146
          salesOrder.setCustomer(customer);
147
          salesOrder.setId(c);
148
          resource.getContents().add(salesOrder);
149
        }
150
151
        resource.getContents().add(customer);
152
      }
153
154
      transaction.commit();
155
      session.close();
156
    }
157
158
    {
159
      CDOSession session = openSession();
160
      CDOTransaction transaction = session.openTransaction();
161
      CDOResource resource = transaction.getResource("/test1");
162
163
      int i = 0;
164
      for (EObject o : resource.getContents())
165
      {
166
        if (o instanceof Customer)
167
        {
168
          Customer customer = (Customer)o;
169
          customer.setCity("Dargaard");
170
          customer.setName("Lord Soth");
171
          customer.setStreet("Death Knight Alley 7");
172
173
          for (SalesOrder salesOrder : customer.getSalesOrders())
174
          {
175
            salesOrder.setId(salesOrder.getId() + 1);
176
          }
177
178
          i++;
179
        }
180
      }
181
182
      assertEquals(500, i);
183
184
      transaction.commit();
185
      session.close();
186
    }
187
188
    finish(t);
189
    msg(t.getTiming());
190
  }
191
192
  public void testLoadAnStoreDataPreAddPerformance() throws Exception
193
  {
194
    TimeTaker t = start("testLoadAnStoreDataPreAddPerformance");
195
196
    {
197
      CDOSession session = openSession();
198
      CDOTransaction transaction = session.openTransaction();
199
      CDOResource resource = transaction.createResource("/test1");
200
      getModel1Factory().createCustomer();
201
      for (int i = 0; i < 500; i++)
202
      {
203
        Customer customer = getModel1Factory().createCustomer();
204
        resource.getContents().add(customer);
205
        customer.setCity("Barovia");
206
        customer.setName("Strahd von Zarovich");
207
        customer.setStreet("Necromancer Road 5");
208
209
        for (int c = 0; c < 5; c++)
210
        {
211
          SalesOrder salesOrder = getModel1Factory().createSalesOrder();
212
          resource.getContents().add(salesOrder);
213
          salesOrder.setCustomer(customer);
214
          salesOrder.setId(c);
215
        }
216
      }
217
218
      transaction.commit();
219
      session.close();
220
    }
221
222
    {
223
      CDOSession session = openSession();
224
      CDOTransaction transaction = session.openTransaction();
225
      CDOResource resource = transaction.getResource("/test1");
226
227
      int i = 0;
228
      for (EObject o : resource.getContents())
229
      {
230
        if (o instanceof Customer)
231
        {
232
          Customer customer = (Customer)o;
233
          customer.setCity("Dargaard");
234
          customer.setName("Lord Soth");
235
          customer.setStreet("Death Knight Alley 7");
236
237
          for (SalesOrder salesOrder : customer.getSalesOrders())
238
          {
239
            salesOrder.setId(salesOrder.getId() + 1);
240
          }
241
242
          i++;
243
        }
244
      }
245
246
      assertEquals(500, i);
247
248
      transaction.commit();
249
      session.close();
250
    }
251
252
    finish(t);
253
    msg(t.getTiming());
254
  }
255
256
  public void testAddRemove() throws Exception
257
  {
258
    TimeTaker t = start("testAddRemove");
259
260
    CDOSession session = openSession();
261
    CDOTransaction transaction = session.openTransaction();
262
    CDOResource resource = transaction.createResource("/test1");
263
    for (int i = 0; i < 100; i++)
264
    {
265
      Customer customer = getModel1Factory().createCustomer();
266
      customer.setName("Azalin Rex");
267
      customer.setCity("Darkon");
268
269
      resource.getContents().add(customer);
270
      transaction.commit();
271
272
      resource.getContents().remove(resource.getContents().size() - 1);
273
      transaction.commit();
274
275
      resource.getContents().add(customer);
276
      transaction.commit();
277
    }
278
279
    finish(t);
280
    msg(t.getTiming());
281
  }
282
283
  public EPackage createPackage()
284
  {
285
    EcoreFactory theCoreFactory = EcoreFactory.eINSTANCE;
286
    EcorePackage theCorePackage = EcorePackage.eINSTANCE;
287
288
    mapContainerEClass = theCoreFactory.createEClass();
289
    mapContainerEClass.setName("MapContainer");
290
291
    EPackage dynamicMapEPackage = theCoreFactory.createEPackage();
292
    dynamicMapEPackage.setName("DynamicMapPackage");
293
    dynamicMapEPackage.setNsPrefix("dynamicmap");
294
    dynamicMapEPackage.setNsURI("http:///org.mftech.examples.emf.dynamic.map");
295
    dynamicMapEPackage.getEClassifiers().add(mapContainerEClass);
296
297
    EStructuralFeature name = theCoreFactory.createEAttribute();
298
    name.setName("name");
299
    name.setEType(theCorePackage.getEString());
300
301
    mapContainerEClass.getEStructuralFeatures().add(name);
302
303
    if (!isConfig(LEGACY))
304
    {
305
      CDOUtil.prepareDynamicEPackage(dynamicMapEPackage);
306
    }
307
308
    return dynamicMapEPackage;
309
  }
310
311
  private TimeTaker start(String testName)
312
  {
313
    TimeTaker t = new TimeTaker();
314
    results.put(testName, t);
315
    t.setStart(System.currentTimeMillis());
316
    return t;
317
  }
318
319
  private void finish(TimeTaker t)
320
  {
321
    t.setEnd(System.currentTimeMillis());
322
  }
323
324
  /**
325
   * @author Martin Fluegge
326
   */
327
  private static class TimeTaker
328
  {
329
    private long start;
330
331
    private long end;
332
333
    public void setStart(long start)
334
    {
335
      this.start = start;
336
    }
337
338
    public void setEnd(long end)
339
    {
340
      this.end = end;
341
    }
342
343
    public long getTiming()
344
    {
345
      return end - start;
346
    }
347
  }
348
349
  // A fake because afterClass does not seem to work :(
350
  @AfterClass
351
  public void testTearDown() throws IOException
352
  {
353
    String ext = "NATIVE";
354
    if (isConfig(LEGACY))
355
    {
356
      ext = "LEGACY";
357
    }
358
359
    String location = System.getProperty("user.home") + "/cdo_Performance_" + ext + "_" + new Date().getTime() + ".csv";
360
    System.out.println("Writing performance results to: " + location);
361
    File file = new File(location);
362
    FileWriter fileWriter = new FileWriter(file);
363
364
    try
365
    {
366
      StringBuffer stringBuffer = new StringBuffer();
367
      for (String key : results.keySet())
368
      {
369
        stringBuffer.append(key + ";" + results.get(key).getTiming() + "\n");
370
      }
371
372
      fileWriter.write(stringBuffer.toString());
373
    }
374
    finally
375
    {
376
      IOUtil.close(fileWriter);
377
    }
378
  }
379
}
(-)src/org/eclipse/emf/cdo/tests/RollbackTest.java (-1 / +1 lines)
Lines 4-10 Link Here
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *    Eike Stepper - initial API and implementation
9
 *    Eike Stepper - initial API and implementation
10
 */
10
 */
(-)src/org/eclipse/emf/cdo/tests/SetFeatureTest.java (-6 / +6 lines)
Lines 30-43 Link Here
30
 */
30
 */
31
public class SetFeatureTest extends AbstractCDOTest
31
public class SetFeatureTest extends AbstractCDOTest
32
{
32
{
33
  // TODO clarify the problems with the default
34
  public void testUnsettableDateNoDefault_SetDefault() throws Exception
33
  public void testUnsettableDateNoDefault_SetDefault() throws Exception
35
  {
34
  {
36
    testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableDate(),
35
    testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableDate(),
37
        getModel2Package().getUnsettable1_UnsettableDate().getDefaultValue());
36
        getModel2Package().getUnsettable1_UnsettableDate().getDefaultValue());
38
  }
37
  }
39
38
40
  // TODO clarify the problems with the default
41
  public void testUnsettableStringNoDefault_SetDefault() throws Exception
39
  public void testUnsettableStringNoDefault_SetDefault() throws Exception
42
  {
40
  {
43
    testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableString(),
41
    testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableString(),
Lines 316-329 Link Here
316
        .getNotUnsettableWithDefault_NotUnsettableDouble().getDefaultValue());
314
        .getNotUnsettableWithDefault_NotUnsettableDouble().getDefaultValue());
317
  }
315
  }
318
316
319
  // TODO clarify the problems with the default
320
  public void testNotUnsettableWithDefaultVAT() throws Exception
317
  public void testNotUnsettableWithDefaultVAT() throws Exception
321
  {
318
  {
322
    testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
319
    testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
323
        .getNotUnsettableWithDefault_NotUnsettableVAT(), VAT.VAT7);
320
        .getNotUnsettableWithDefault_NotUnsettableVAT(), VAT.VAT7);
324
  }
321
  }
325
322
326
  // TODO clarify the problems with the default
327
  public void testNotUnsettableWithDefaultVAT_SetDefault() throws Exception
323
  public void testNotUnsettableWithDefaultVAT_SetDefault() throws Exception
328
  {
324
  {
329
    testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
325
    testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package()
Lines 646-659 Link Here
646
        .getDefaultValue());
642
        .getDefaultValue());
647
  }
643
  }
648
644
649
  // TODO clarify the problems with the default
650
  public void testUnsettableWithDefaultVAT() throws Exception
645
  public void testUnsettableWithDefaultVAT() throws Exception
651
  {
646
  {
652
    testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
647
    testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
653
        .getUnsettable2WithDefault_UnsettableVAT(), VAT.VAT7);
648
        .getUnsettable2WithDefault_UnsettableVAT(), VAT.VAT7);
654
  }
649
  }
655
650
656
  // TODO clarify the problems with the default
657
  public void testUnsettableWithDefaultVAT_SetDefault() throws Exception
651
  public void testUnsettableWithDefaultVAT_SetDefault() throws Exception
658
  {
652
  {
659
    testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
653
    testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package()
Lines 714-719 Link Here
714
          .eIsSet(feature));
708
          .eIsSet(feature));
715
709
716
      session.close();
710
      session.close();
711
712
      // ---------- open new session --------------
713
717
      session = openSession();
714
      session = openSession();
718
715
719
      transaction = session.openTransaction();
716
      transaction = session.openTransaction();
Lines 743-748 Link Here
743
          .eIsSet(feature));
740
          .eIsSet(feature));
744
741
745
      session.close();
742
      session.close();
743
744
      // ---------- open new session --------------
745
746
      session = openSession();
746
      session = openSession();
747
747
748
      transaction = session.openTransaction();
748
      transaction = session.openTransaction();
(-)src/org/eclipse/emf/cdo/tests/UnsetTest.java (-2 / +4 lines)
Lines 414-421 Link Here
414
        .getEIntegerObject());
414
        .getEIntegerObject());
415
    objectElement.setUnsettable(true);
415
    objectElement.setUnsettable(true);
416
    objectElement.setDefaultValue(42);
416
    objectElement.setDefaultValue(42);
417
417
    if (!isConfig(LEGACY))
418
    CDOUtil.prepareDynamicEPackage(pkg);
418
    {
419
      CDOUtil.prepareDynamicEPackage(pkg);
420
    }
419
421
420
    {
422
    {
421
      EObject test1 = EcoreUtil.create(cls);
423
      EObject test1 = EcoreUtil.create(cls);
(-)src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_246622_Test.java (-1 / +1 lines)
Lines 46-52 Link Here
46
    EStructuralFeature order_OrderDetailFeature = getModel1Package().getOrder_OrderDetails();
46
    EStructuralFeature order_OrderDetailFeature = getModel1Package().getOrder_OrderDetails();
47
    assertEquals(orderDetail, CDOUtil.getCDOObject(order).cdoRevision().data().get(order_OrderDetailFeature, 0));
47
    assertEquals(orderDetail, CDOUtil.getCDOObject(order).cdoRevision().data().get(order_OrderDetailFeature, 0));
48
48
49
    assertEquals(order, CDOUtil.getCDOObject(orderDetail).cdoRevision().data().getContainerID());
49
    assertEquals(CDOUtil.getCDOObject(order), CDOUtil.getCDOObject(orderDetail).cdoRevision().data().getContainerID());
50
50
51
    Order order2 = getModel1Factory().createOrder();
51
    Order order2 = getModel1Factory().createOrder();
52
    OrderDetail orderDetail2 = getModel1Factory().createOrderDetail();
52
    OrderDetail orderDetail2 = getModel1Factory().createOrderDetail();
(-)src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_248915_Test.java (-2 / +9 lines)
Lines 79-86 Link Here
79
    CDOResource supplierResource2 = transaction2.getResource("/supplierResource");
79
    CDOResource supplierResource2 = transaction2.getResource("/supplierResource");
80
    Supplier savedSupplier = (Supplier)supplierResource2.getContents().get(0);
80
    Supplier savedSupplier = (Supplier)supplierResource2.getContents().get(0);
81
81
82
    /* Confirm the presence of supplierResource2 in transaction2's resourceSet */
82
    if (!isConfig(LEGACY))
83
    assertEquals(1, transaction2.getResourceSet().getResources().size());
83
    {
84
      /* Confirm the presence of supplierResource2 in transaction2's resourceSet */
85
      assertEquals(1, transaction2.getResourceSet().getResources().size());
86
    }
87
    else
88
    {// legacy mode loads the whole tree. So there will be 3 resources
89
      assertEquals(2, transaction2.getResourceSet().getResources().size());
90
    }
84
91
85
    for (PurchaseOrder po : savedSupplier.getPurchaseOrders())
92
    for (PurchaseOrder po : savedSupplier.getPurchaseOrders())
86
    {
93
    {
(-)src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_254489_Test.java (-1 / +3 lines)
Lines 21-26 Link Here
21
import org.eclipse.emf.cdo.util.CDOUtil;
21
import org.eclipse.emf.cdo.util.CDOUtil;
22
import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
22
import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
23
23
24
import org.eclipse.emf.ecore.EObject;
25
24
/**
26
/**
25
 * CDOTransaction.postCommit not adjusting the Transaction/View reference
27
 * CDOTransaction.postCommit not adjusting the Transaction/View reference
26
 * <p>
28
 * <p>
Lines 69-75 Link Here
69
      }
71
      }
70
    }.assertNoTimeOut();
72
    }.assertNoTimeOut();
71
73
72
    Category category2 = (Category)companyA2Adapter.getNotifications()[0].getNewValue();
74
    Category category2 = (Category)CDOUtil.getEObject((EObject)companyA2Adapter.getNotifications()[0].getNewValue());
73
    assertNotSame(category2, category1A);
75
    assertNotSame(category2, category1A);
74
    assertSame(transaction2, CDOUtil.getCDOObject(category2).cdoView());
76
    assertSame(transaction2, CDOUtil.getCDOObject(category2).cdoView());
75
  }
77
  }
(-)src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_266982_Test.java (-1 / +2 lines)
Lines 50-56 Link Here
50
        {
50
        {
51
          CDOSession session = openSession();
51
          CDOSession session = openSession();
52
          CDOTransaction transaction = session.openTransaction();
52
          CDOTransaction transaction = session.openTransaction();
53
          Customer customerToLoad = (Customer)transaction.getObject(CDOUtil.getCDOObject(customer).cdoID());
53
          Customer customerToLoad = (Customer)CDOUtil.getEObject(transaction.getObject(CDOUtil.getCDOObject(customer)
54
              .cdoID()));
54
          while (!done[0])
55
          while (!done[0])
55
          {
56
          {
56
            // Could fail if the attach is not thread safe
57
            // Could fail if the attach is not thread safe
(-)src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_273565_Test.java (-2 / +2 lines)
Lines 66-72 Link Here
66
      {
66
      {
67
        CDOSession session = openSession();
67
        CDOSession session = openSession();
68
        CDOTransaction transaction = session.openTransaction();
68
        CDOTransaction transaction = session.openTransaction();
69
        OrderDetail orderDetail = (OrderDetail)transaction.getObject(id);
69
        OrderDetail orderDetail = (OrderDetail)CDOUtil.getEObject(transaction.getObject(id));
70
70
71
        try
71
        try
72
        {
72
        {
Lines 272-278 Link Here
272
    transaction.commit();
272
    transaction.commit();
273
273
274
    CDOTransaction transaction2 = session.openTransaction();
274
    CDOTransaction transaction2 = session.openTransaction();
275
    OrderDetail orderDetail2 = transaction2.getObject(orderDetail);
275
    OrderDetail orderDetail2 = (OrderDetail)CDOUtil.getEObject(transaction2.getObject(orderDetail));
276
276
277
    CDOUtil.getCDOObject(orderDetail).cdoWriteLock().lock();
277
    CDOUtil.getCDOObject(orderDetail).cdoWriteLock().lock();
278
    orderDetail.setPrice(2);
278
    orderDetail.setPrice(2);
(-)src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_279982_Test.java (-3 / +6 lines)
Lines 33-39 Link Here
33
public class Bugzilla_279982_Test extends AbstractCDOTest
33
public class Bugzilla_279982_Test extends AbstractCDOTest
34
{
34
{
35
  public void testBugzilla_279982_Single() throws Exception
35
  public void testBugzilla_279982_Single() throws Exception
36
  {
36
  {// as log as there is no getter interception, stale reference cannot be detected for legacy
37
    skipConfig(LEGACY);
37
    CDOSession session = openSession();
38
    CDOSession session = openSession();
38
    CDOTransaction tx = session.openTransaction();
39
    CDOTransaction tx = session.openTransaction();
39
    CDOResource res = tx.getOrCreateResource("/resource1");
40
    CDOResource res = tx.getOrCreateResource("/resource1");
Lines 98-104 Link Here
98
  }
99
  }
99
100
100
  public void testBugzilla_279982_Multi() throws Exception
101
  public void testBugzilla_279982_Multi() throws Exception
101
  {
102
  {// as log as there is no getter interception, stale reference cannot be detected for legacy
103
    skipConfig(LEGACY);
102
    CDOSession session = openSession();
104
    CDOSession session = openSession();
103
    CDOTransaction tx = session.openTransaction();
105
    CDOTransaction tx = session.openTransaction();
104
    CDOResource res = tx.getOrCreateResource("/resource1");
106
    CDOResource res = tx.getOrCreateResource("/resource1");
Lines 147-153 Link Here
147
  }
149
  }
148
150
149
  public void testBugzilla_279982_Multi_RevisionPrefetchingPolicy() throws Exception
151
  public void testBugzilla_279982_Multi_RevisionPrefetchingPolicy() throws Exception
150
  {
152
  {// as log as there is no getter interception, stale reference cannot be detected for legacy
153
    skipConfig(LEGACY);
151
    CDOSession session = openSession();
154
    CDOSession session = openSession();
152
    {
155
    {
153
      CDOTransaction tx = session.openTransaction();
156
      CDOTransaction tx = session.openTransaction();
(-)src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java (+3 lines)
Lines 18-23 Link Here
18
import org.eclipse.emf.cdo.tests.config.IConfig;
18
import org.eclipse.emf.cdo.tests.config.IConfig;
19
import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
19
import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
20
import org.eclipse.emf.cdo.tests.config.ISessionConfig;
20
import org.eclipse.emf.cdo.tests.config.ISessionConfig;
21
import org.eclipse.emf.cdo.util.CDOUtil;
21
22
22
import org.eclipse.net4j.acceptor.IAcceptor;
23
import org.eclipse.net4j.acceptor.IAcceptor;
23
import org.eclipse.net4j.connector.IConnector;
24
import org.eclipse.net4j.connector.IConnector;
Lines 147-152 Link Here
147
148
148
  protected void configureSession(CDOSession session)
149
  protected void configureSession(CDOSession session)
149
  {
150
  {
151
    CDOUtil.setLegacyModeDefault(true);
150
  }
152
  }
151
153
152
  private void removeDynamicPackagesFromGlobalRegistry()
154
  private void removeDynamicPackagesFromGlobalRegistry()
Lines 241-246 Link Here
241
    @Override
243
    @Override
242
    protected void configureSession(CDOSession session)
244
    protected void configureSession(CDOSession session)
243
    {
245
    {
246
      super.configureSession(session);
244
      ((org.eclipse.emf.cdo.net4j.CDOSession)session).options().getProtocol().setTimeout(-1);
247
      ((org.eclipse.emf.cdo.net4j.CDOSession)session).options().getProtocol().setTimeout(-1);
245
    }
248
    }
246
249
(-)src/org/eclipse/emf/cdo/tests/db/DBStoreTest.java (-2 / +4 lines)
Lines 136-143 Link Here
136
136
137
    assertEquals(cust1ref, cust1);
137
    assertEquals(cust1ref, cust1);
138
    assertEquals(cust2ref, cust2);
138
    assertEquals(cust2ref, cust2);
139
139
    if (!isConfig(LEGACY))
140
    CDOUtil.prepareDynamicEPackage(pkg);
140
    {
141
      CDOUtil.prepareDynamicEPackage(pkg);
142
    }
141
143
142
    {
144
    {
143
      EObject obj1 = EcoreUtil.create(clz);
145
      EObject obj1 = EcoreUtil.create(clz);
(-)src/org/eclipse/emf/cdo/tests/legacy/model3/impl/Model3FactoryImpl.java (-4 / +4 lines)
Lines 169-189 Link Here
169
  /**
169
  /**
170
   * <!-- begin-user-doc --> <!-- end-user-doc -->
170
   * <!-- begin-user-doc --> <!-- end-user-doc -->
171
   * 
171
   * 
172
   * @generated
172
   * @generated NOT
173
   */
173
   */
174
  public Point createPointFromString(EDataType eDataType, String initialValue)
174
  public Point createPointFromString(EDataType eDataType, String initialValue)
175
  {
175
  {
176
    return (Point)super.createFromString(eDataType, initialValue);
176
    return Point.parse(initialValue);
177
  }
177
  }
178
178
179
  /**
179
  /**
180
   * <!-- begin-user-doc --> <!-- end-user-doc -->
180
   * <!-- begin-user-doc --> <!-- end-user-doc -->
181
   * 
181
   * 
182
   * @generated
182
   * @generated NOT
183
   */
183
   */
184
  public String convertPointToString(EDataType eDataType, Object instanceValue)
184
  public String convertPointToString(EDataType eDataType, Object instanceValue)
185
  {
185
  {
186
    return super.convertToString(eDataType, instanceValue);
186
    return ((Point)instanceValue).toString();
187
  }
187
  }
188
188
189
  /**
189
  /**
(-)src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java (-2 / +1 lines)
Lines 30-36 Link Here
30
import org.eclipse.emf.cdo.util.CDOUtil;
30
import org.eclipse.emf.cdo.util.CDOUtil;
31
import org.eclipse.emf.cdo.view.CDOView;
31
import org.eclipse.emf.cdo.view.CDOView;
32
32
33
import org.eclipse.emf.internal.cdo.CDOLegacyWrapper;
34
import org.eclipse.emf.internal.cdo.CDOStateMachine;
33
import org.eclipse.emf.internal.cdo.CDOStateMachine;
35
34
36
import org.eclipse.net4j.util.transaction.TransactionException;
35
import org.eclipse.net4j.util.transaction.TransactionException;
Lines 1268-1274 Link Here
1268
        @Override
1267
        @Override
1269
        protected void objectInvalidated(InternalCDOObject cdoObject)
1268
        protected void objectInvalidated(InternalCDOObject cdoObject)
1270
        {
1269
        {
1271
          if (cdoObject instanceof CDOLegacyWrapper)
1270
          if (CDOUtil.isLegacyObject(cdoObject))
1272
          {
1271
          {
1273
            CDOStateMachine.INSTANCE.read(cdoObject);
1272
            CDOStateMachine.INSTANCE.read(cdoObject);
1274
          }
1273
          }
(-)src/org/eclipse/emf/cdo/ui/ide/RepositoryContentProvider.java (-3 / +3 lines)
Lines 28-38 Link Here
28
import org.eclipse.emf.cdo.ui.ide.Node.SessionsNode;
28
import org.eclipse.emf.cdo.ui.ide.Node.SessionsNode;
29
import org.eclipse.emf.cdo.ui.internal.ide.actions.RemoveResourceActionDelegate;
29
import org.eclipse.emf.cdo.ui.internal.ide.actions.RemoveResourceActionDelegate;
30
import org.eclipse.emf.cdo.ui.internal.ide.bundle.OM;
30
import org.eclipse.emf.cdo.ui.internal.ide.bundle.OM;
31
import org.eclipse.emf.cdo.util.CDOUtil;
31
import org.eclipse.emf.cdo.view.CDOView;
32
import org.eclipse.emf.cdo.view.CDOView;
32
import org.eclipse.emf.cdo.view.CDOViewInvalidationEvent;
33
import org.eclipse.emf.cdo.view.CDOViewInvalidationEvent;
33
import org.eclipse.emf.cdo.view.CDOViewTargetChangedEvent;
34
import org.eclipse.emf.cdo.view.CDOViewTargetChangedEvent;
34
35
35
import org.eclipse.emf.internal.cdo.CDOLegacyWrapper;
36
import org.eclipse.emf.internal.cdo.CDOStateMachine;
36
import org.eclipse.emf.internal.cdo.CDOStateMachine;
37
37
38
import org.eclipse.net4j.util.container.ContainerEventAdapter;
38
import org.eclipse.net4j.util.container.ContainerEventAdapter;
Lines 45-53 Link Here
45
import org.eclipse.emf.common.notify.Notifier;
45
import org.eclipse.emf.common.notify.Notifier;
46
import org.eclipse.emf.edit.EMFEditPlugin;
46
import org.eclipse.emf.edit.EMFEditPlugin;
47
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
47
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
48
import org.eclipse.emf.edit.provider.ComposedAdapterFactory.Descriptor.Registry;
48
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
49
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
49
import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
50
import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
50
import org.eclipse.emf.edit.provider.ComposedAdapterFactory.Descriptor.Registry;
51
import org.eclipse.emf.spi.cdo.InternalCDOObject;
51
import org.eclipse.emf.spi.cdo.InternalCDOObject;
52
52
53
import org.eclipse.core.resources.IProject;
53
import org.eclipse.core.resources.IProject;
Lines 359-365 Link Here
359
    @Override
359
    @Override
360
    protected void objectInvalidated(InternalCDOObject cdoObject)
360
    protected void objectInvalidated(InternalCDOObject cdoObject)
361
    {
361
    {
362
      if (cdoObject instanceof CDOLegacyWrapper)
362
      if (CDOUtil.isLegacyObject(cdoObject))
363
      {
363
      {
364
        CDOStateMachine.INSTANCE.read(cdoObject);
364
        CDOStateMachine.INSTANCE.read(cdoObject);
365
      }
365
      }

Return to bug 247226