|
Removed
Link Here
|
| 1 |
/*************************************************************************** |
| 2 |
* Copyright (c) 2004 - 2007 Eike Stepper, Germany. |
| 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 |
* Simon McDuff - initial API and implementation |
| 10 |
* Eike Stepper - maintenance |
| 11 |
**************************************************************************/ |
| 12 |
package org.eclipse.emf.internal.cdo.analyzer; |
| 13 |
|
| 14 |
import org.eclipse.emf.cdo.analyzer.CDOFetchRuleManager; |
| 15 |
import org.eclipse.emf.cdo.internal.protocol.analyzer.CDOFetchRule; |
| 16 |
import org.eclipse.emf.cdo.protocol.CDOID; |
| 17 |
|
| 18 |
import org.eclipse.net4j.internal.util.concurrent.QueueWorkerWorkSerializer; |
| 19 |
import org.eclipse.net4j.util.concurrent.IWorkSerializer; |
| 20 |
|
| 21 |
import org.eclipse.emf.internal.cdo.CDOSessionImpl; |
| 22 |
import org.eclipse.emf.internal.cdo.CDOViewImpl; |
| 23 |
|
| 24 |
import java.util.ArrayList; |
| 25 |
import java.util.Collection; |
| 26 |
import java.util.Iterator; |
| 27 |
import java.util.List; |
| 28 |
import java.util.Set; |
| 29 |
|
| 30 |
/** |
| 31 |
* @author Eike Stepper |
| 32 |
*/ |
| 33 |
public class CDOReadAhead |
| 34 |
{ |
| 35 |
private IWorkSerializer workSerializer = new QueueWorkerWorkSerializer(); |
| 36 |
|
| 37 |
private CDOViewImpl view; |
| 38 |
|
| 39 |
public CDOReadAhead(CDOViewImpl view) |
| 40 |
{ |
| 41 |
this.view = view; |
| 42 |
} |
| 43 |
|
| 44 |
public CDOViewImpl getView() |
| 45 |
{ |
| 46 |
return view; |
| 47 |
} |
| 48 |
|
| 49 |
public void addIDs(Set<CDOID> ids) |
| 50 |
{ |
| 51 |
CDODynamicFetchRuleAnalyzer dynamic = (CDODynamicFetchRuleAnalyzer)getView().getFeatureAnalyzer(); |
| 52 |
if (dynamic.getCurrentGraph().getFeatureRule().isActive()) |
| 53 |
{ |
| 54 |
workSerializer.addWork(new ReceiverWork(ids)); |
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* @author Eike Stepper |
| 60 |
*/ |
| 61 |
private final class ReceiverWork implements Runnable |
| 62 |
{ |
| 63 |
private Set<CDOID> ids; |
| 64 |
|
| 65 |
private CDODynamicFetchRuleAnalyzer dynamic; |
| 66 |
|
| 67 |
private CDOGraph graph; |
| 68 |
|
| 69 |
private CDOID context; |
| 70 |
|
| 71 |
/** |
| 72 |
* TODO Remove? |
| 73 |
*/ |
| 74 |
private Test test = new Test(); |
| 75 |
|
| 76 |
private ReceiverWork(Set<CDOID> ids) |
| 77 |
{ |
| 78 |
this.ids = ids; |
| 79 |
dynamic = (CDODynamicFetchRuleAnalyzer)getView().getFeatureAnalyzer(); |
| 80 |
graph = dynamic.getCurrentGraph(); |
| 81 |
context = dynamic.getContext(); |
| 82 |
} |
| 83 |
|
| 84 |
public void run() |
| 85 |
{ |
| 86 |
CDODynamicFetchRuleManager.join(test); |
| 87 |
CDOSessionImpl s = getView().getSession(); |
| 88 |
s.getRevisionManager().getRevisions(ids, s.getReferenceChunkSize()); |
| 89 |
} |
| 90 |
|
| 91 |
/** |
| 92 |
* TODO Remove? |
| 93 |
* |
| 94 |
* @author Eike Stepper |
| 95 |
*/ |
| 96 |
@Deprecated |
| 97 |
private final class Test implements CDOFetchRuleManager |
| 98 |
{ |
| 99 |
public Test() |
| 100 |
{ |
| 101 |
} |
| 102 |
|
| 103 |
public CDOID getContext() |
| 104 |
{ |
| 105 |
return context; |
| 106 |
} |
| 107 |
|
| 108 |
public List<CDOFetchRule> getFetchRules(Collection<CDOID> ids) |
| 109 |
{ |
| 110 |
List<CDOFetchRule> list = new ArrayList<CDOFetchRule>(); |
| 111 |
for (Iterator<CDOFetchRule> it = graph.getFeatureRule().iterator(); it.hasNext();) |
| 112 |
{ |
| 113 |
CDOFetchRule fetchRule = it.next(); |
| 114 |
list.add(fetchRule); |
| 115 |
} |
| 116 |
|
| 117 |
return list; |
| 118 |
} |
| 119 |
} |
| 120 |
} |
| 121 |
} |