Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: ad471fbad11ffd247f5155ad15dbd6e3bdc88b35 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
/*
 * Copyright (c) 2009-2016 Eike Stepper (Berlin, Germany) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Eike Stepper - initial API and implementation
 */
package org.eclipse.emf.spi.cdo;

import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDProvider;
import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo;
import org.eclipse.emf.cdo.common.lock.CDOLockState;
import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.cdo.view.CDOFeatureAnalyzer;
import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.cdo.view.CDOViewProvider;

import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
import org.eclipse.net4j.util.lifecycle.ILifecycle;

import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.ecore.EObject;

import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * If the meaning of this type isn't clear, there really should be more of a description here...
 *
 * @author Eike Stepper
 * @since 2.0
 * @noextend This interface is not intended to be extended by clients.
 * @noimplement This interface is not intended to be implemented by clients.
 */
public interface InternalCDOView extends CDOView, CDOIDProvider, ILifecycle
{
  public void setViewID(int viewId);

  /**
   * @since 4.4
   */
  public void setProvider(CDOViewProvider provider);

  /**
   * @since 4.4
   */
  public String getRepositoryName();

  /**
   * @since 4.4
   */
  public void setRepositoryName(String repositoryName);

  public InternalCDOSession getSession();

  public void setSession(InternalCDOSession session);

  public InternalCDOViewSet getViewSet();

  public void setViewSet(InternalCDOViewSet viewSet);

  @Deprecated
  public CDOFeatureAnalyzer getFeatureAnalyzer();

  @Deprecated
  public void setFeatureAnalyzer(CDOFeatureAnalyzer featureAnalyzer);

  /**
   * Returns an unmodifiable map of the objects managed by this view.
   *
   * @since 4.0
   */
  public Map<CDOID, InternalCDOObject> getObjects();

  /**
   * @since 4.3
   */
  public List<InternalCDOObject> getObjectsList();

  /**
   * @since 4.0
   */
  public CDOStore getStore();

  public InternalCDOTransaction toTransaction();

  public void attachResource(CDOResourceImpl resource);

  /**
   * @since 4.5
   */
  public void resourceLoaded(CDOResourceImpl resource, boolean loaded);

  /**
   * @since 3.0
   */
  public void handleObjectStateChanged(InternalCDOObject object, CDOState oldState, CDOState newState);

  /**
   * @deprecated As of 4.2. use {@link #invalidate(CDOBranch, long, List, List, Map, boolean, boolean)}
   */
  @Deprecated
  public void invalidate(CDOBranch branch, long lastUpdateTime, List<CDORevisionKey> allChangedObjects,
      List<CDOIDAndVersion> allDetachedObjects, Map<CDOID, InternalCDORevision> oldRevisions, boolean async);

  /**
   * @since 4.2
   * @deprecated As of 4.6. use {@link #invalidate(ViewInvalidationData)}
   */
  @Deprecated
  public void invalidate(CDOBranch branch, long lastUpdateTime, List<CDORevisionKey> allChangedObjects,
      List<CDOIDAndVersion> allDetachedObjects, Map<CDOID, InternalCDORevision> oldRevisions, boolean async,
      boolean clearResourcePathCache);

  /**
   * @since 4.6
   */
  public void invalidate(ViewInvalidationData invalidationData);

  /**
   * @since 3.0
   */
  public void setLastUpdateTime(long lastUpdateTime);

  /**
   * @since 3.0
   */
  public void collectViewedRevisions(Map<CDOID, InternalCDORevision> revisions);

  public void remapObject(CDOID oldID);

  /**
   * @since 4.2
   */
  public void clearResourcePathCacheIfNecessary(CDORevisionDelta delta);

  public CDOID getResourceNodeID(String path);

  /**
   * @deprecated No longer supported.
   */
  @Deprecated
  public void registerProxyResource(CDOResourceImpl resource);

  public void registerObject(InternalCDOObject object);

  public void deregisterObject(InternalCDOObject object);

  public InternalCDORevision getRevision(CDOID id, boolean loadOnDemand);

  /**
   * @since 3.0
   */
  public void prefetchRevisions(CDOID id, int depth);

  public Object convertObjectToID(Object potentialObject);

  public Object convertObjectToID(Object potentialObject, boolean onlyPersistedID);

  public Object convertIDToObject(Object potentialID);

  /**
   * @since 3.0
   */
  public boolean isObjectLocked(CDOObject object, LockType lockType, boolean byOthers);

  /**
   * @since 4.1
   */
  public boolean isObjectNew(CDOID id);

  public void handleAddAdapter(InternalCDOObject eObject, Adapter adapter);

  public void handleRemoveAdapter(InternalCDOObject eObject, Adapter adapter);

  public void subscribe(EObject eObject, Adapter adapter);

  public void unsubscribe(EObject eObject, Adapter adapter);

  public boolean hasSubscription(CDOID id);

  /**
   * @since 4.1
   */
  public void handleLockNotification(InternalCDOView sender, CDOLockChangeInfo lockChangeInfo);

  /**
   * Get an array of {@link CDOLockState lock states} corresponding to the specified collection of {@link CDOID ids}.
   *
   * If the collection of {@link CDOID ids} is empty, {@link CDOLockState lock states} of all locked objects are returned.
   *
   * @since 4.1
   */
  public CDOLockState[] getLockStates(Collection<CDOID> ids);

  /**
   * @since 4.2
   */
  public ViewAndState getViewAndState(CDOState state);

  /**
   * @since 4.5
   */
  public Object getViewMonitor();

  /**
   * @since 4.5
   */
  public void lockView();

  /**
   * @since 4.5
   */
  public void unlockView();

  /**
   * Optimizes the storage of {@link CDOObject#cdoView()} and {@link CDOObject#cdoState()}. All objects of a view
   * share a small number of {@link CDOState} literals, so they are moved into a final AbstractCDOView.viewAndStates array.
   * For the {@link CDOState#TRANSIENT TRANSIENT} state, where there is no view associated with a {@link CDOObject}, this class
   * maintains a static {@link #VIEW_AND_STATES} array.
   *
   * @author Eike Stepper
   * @since 4.2
   */
  public static final class ViewAndState
  {
    private static final CDOState[] STATE_VALUES = CDOState.values();

    private static final ViewAndState[] VIEW_AND_STATES = create(null);

    public static final ViewAndState TRANSIENT = VIEW_AND_STATES[CDOState.TRANSIENT.ordinal()];

    public final InternalCDOView view;

    public final CDOState state;

    public ViewAndState(InternalCDOView view, CDOState state)
    {
      this.view = view;
      this.state = state;
    }

    public ViewAndState getViewAndState(CDOState state)
    {
      if (view != null)
      {
        return view.getViewAndState(state);
      }

      return VIEW_AND_STATES[state.ordinal()];
    }

    @Override
    public String toString()
    {
      return "ViewAndState[view=" + view + ", state=" + state + "]";
    }

    public static ViewAndState[] create(InternalCDOView view)
    {
      ViewAndState[] viewAndStates = new ViewAndState[STATE_VALUES.length];
      for (CDOState state : STATE_VALUES)
      {
        viewAndStates[state.ordinal()] = new ViewAndState(view, state);
      }

      return viewAndStates;
    }
  }

  /**
   * A data structure that holds all input values of {@link InternalCDOView#invalidate(ViewInvalidationData) InternalCDOView#invalidate()}.
   *
   * @author Eike Stepper
   * @since 4.6
   */
  public static final class ViewInvalidationData
  {
    private CDOBranch branch;

    private long lastUpdateTime;

    private List<CDORevisionKey> allChangedObjects;

    private List<CDOIDAndVersion> allDetachedObjects;

    private Map<CDOID, InternalCDORevision> oldRevisions;

    private boolean async;

    private boolean clearResourcePathCache;

    private CDOLockChangeInfo lockChangeInfo;

    public ViewInvalidationData()
    {
    }

    public CDOBranch getBranch()
    {
      return branch;
    }

    public void setBranch(CDOBranch branch)
    {
      this.branch = branch;
    }

    public long getLastUpdateTime()
    {
      return lastUpdateTime;
    }

    public void setLastUpdateTime(long lastUpdateTime)
    {
      this.lastUpdateTime = lastUpdateTime;
    }

    public List<CDORevisionKey> getAllChangedObjects()
    {
      return allChangedObjects;
    }

    public void setAllChangedObjects(List<CDORevisionKey> allChangedObjects)
    {
      this.allChangedObjects = allChangedObjects;
    }

    public List<CDOIDAndVersion> getAllDetachedObjects()
    {
      return allDetachedObjects;
    }

    public void setAllDetachedObjects(List<CDOIDAndVersion> allDetachedObjects)
    {
      this.allDetachedObjects = allDetachedObjects;
    }

    public Map<CDOID, InternalCDORevision> getOldRevisions()
    {
      return oldRevisions;
    }

    public void setOldRevisions(Map<CDOID, InternalCDORevision> oldRevisions)
    {
      this.oldRevisions = oldRevisions;
    }

    public boolean isAsync()
    {
      return async;
    }

    public void setAsync(boolean async)
    {
      this.async = async;
    }

    public boolean isClearResourcePathCache()
    {
      return clearResourcePathCache;
    }

    public void setClearResourcePathCache(boolean clearResourcePathCache)
    {
      this.clearResourcePathCache = clearResourcePathCache;
    }

    public CDOLockChangeInfo getLockChangeInfo()
    {
      return lockChangeInfo;
    }

    public void setLockChangeInfo(CDOLockChangeInfo lockChangeInfo)
    {
      this.lockChangeInfo = lockChangeInfo;
    }

    @Override
    public String toString()
    {
      StringBuilder builder = new StringBuilder();
      builder.append("ViewInvalidationData[branch=");
      builder.append(branch);
      builder.append(", lastUpdateTime=");
      builder.append(lastUpdateTime);
      builder.append(", allChangedObjects=");
      builder.append(allChangedObjects);
      builder.append(", allDetachedObjects=");
      builder.append(allDetachedObjects);
      builder.append(", oldRevisions=");
      builder.append(oldRevisions);
      builder.append(", async=");
      builder.append(async);
      builder.append(", clearResourcePathCache=");
      builder.append(clearResourcePathCache);
      builder.append(", lockChangeInfo=");
      builder.append(lockChangeInfo);
      builder.append("]");
      return builder.toString();
    }
  }
}

Back to the top