Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CDOCompare.java62
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EMFCompareTest.java16
2 files changed, 61 insertions, 17 deletions
diff --git a/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CDOCompare.java b/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CDOCompare.java
index 2e7093dbe6..975e6c6168 100644
--- a/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CDOCompare.java
+++ b/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CDOCompare.java
@@ -33,6 +33,7 @@ import org.eclipse.emf.compare.match.IEqualityHelperFactory;
import org.eclipse.emf.compare.match.IMatchEngine;
import org.eclipse.emf.compare.match.eobject.IEObjectMatcher;
import org.eclipse.emf.compare.match.eobject.IdentifierEObjectMatcher;
+import org.eclipse.emf.compare.match.impl.MatchEngineFactoryRegistryImpl;
import org.eclipse.emf.compare.postprocessor.IPostProcessor;
import org.eclipse.emf.compare.req.IReqEngine;
import org.eclipse.emf.compare.scope.IComparisonScope;
@@ -85,10 +86,11 @@ public class CDOCompare
{
Builder builder = EMFCompare.builder();
- IMatchEngine matchEngine = createMatchEngine(matcher, comparisonFactory);
- if (matchEngine != null)
+ IMatchEngine.Factory.Registry matchEngineFactoryRegistry = createMatchEngineFactoryRegistry(matcher,
+ comparisonFactory);
+ if (matchEngineFactoryRegistry != null)
{
- builder.setMatchEngine(matchEngine);
+ builder.setMatchEngineFactoryRegistry(matchEngineFactoryRegistry);
}
IDiffEngine diffEngine = createDiffEngine();
@@ -124,9 +126,12 @@ public class CDOCompare
return builder.build();
}
- protected CDOMatchEngine createMatchEngine(IEObjectMatcher matcher, IComparisonFactory comparisonFactory)
+ protected IMatchEngine.Factory.Registry createMatchEngineFactoryRegistry(IEObjectMatcher matcher,
+ IComparisonFactory comparisonFactory)
{
- return new CDOMatchEngine(matcher, comparisonFactory);
+ IMatchEngine.Factory.Registry registry = new MatchEngineFactoryRegistryImpl();
+ registry.add(new CDOMatchEngine.Factory(matcher, comparisonFactory));
+ return registry;
}
protected IDiffEngine createDiffEngine()
@@ -188,7 +193,7 @@ public class CDOCompare
*
* @author Eike Stepper
*/
- public static final class CDOMatchEngine extends DefaultMatchEngine
+ public static class CDOMatchEngine extends DefaultMatchEngine
{
CDOMatchEngine(IEObjectMatcher matcher, IComparisonFactory comparisonFactory)
{
@@ -201,6 +206,51 @@ public class CDOCompare
{
match(comparison, scope, (EObject)left, (EObject)right, (EObject)origin, monitor);
}
+
+ /**
+ * @author Eike Stepper
+ */
+ public static class Factory implements IMatchEngine.Factory
+ {
+ private final IMatchEngine matchEngine;
+
+ private int ranking;
+
+ public Factory(IEObjectMatcher matcher, IComparisonFactory comparisonFactory)
+ {
+ matchEngine = createMatchEngine(matcher, comparisonFactory);
+ }
+
+ protected Factory(IMatchEngine matchEngine)
+ {
+ this.matchEngine = matchEngine;
+ }
+
+ protected CDOMatchEngine createMatchEngine(IEObjectMatcher matcher, IComparisonFactory comparisonFactory)
+ {
+ return new CDOMatchEngine(matcher, comparisonFactory);
+ }
+
+ public IMatchEngine getMatchEngine()
+ {
+ return matchEngine;
+ }
+
+ public int getRanking()
+ {
+ return ranking;
+ }
+
+ public void setRanking(int ranking)
+ {
+ this.ranking = ranking;
+ }
+
+ public boolean isMatchEngineFactoryFor(IComparisonScope scope)
+ {
+ return scope instanceof CDOComparisonScope;
+ }
+ }
}
/**
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EMFCompareTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EMFCompareTest.java
index 6329c1f02e..ef2e46f808 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EMFCompareTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EMFCompareTest.java
@@ -37,14 +37,7 @@ import org.eclipse.emf.compare.diff.DefaultDiffEngine;
import org.eclipse.emf.compare.diff.DiffBuilder;
import org.eclipse.emf.compare.diff.FeatureFilter;
import org.eclipse.emf.compare.diff.IDiffEngine;
-import org.eclipse.emf.compare.match.DefaultComparisonFactory;
-import org.eclipse.emf.compare.match.DefaultEqualityHelperFactory;
-import org.eclipse.emf.compare.match.DefaultMatchEngine;
-import org.eclipse.emf.compare.match.IComparisonFactory;
-import org.eclipse.emf.compare.match.IMatchEngine;
-import org.eclipse.emf.compare.match.eobject.IEObjectMatcher;
import org.eclipse.emf.compare.scope.IComparisonScope;
-import org.eclipse.emf.compare.utils.UseIdentifiers;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -180,10 +173,11 @@ public class EMFCompareTest extends AbstractCDOTest
IComparisonScope scope = EMFCompare.createDefaultScope(resourceSetA, resourceSetB);
// Configure EMF Compare
- IEObjectMatcher matcher = DefaultMatchEngine.createDefaultEObjectMatcher(UseIdentifiers.NEVER);
- IComparisonFactory comparisonFactory = new DefaultComparisonFactory(new DefaultEqualityHelperFactory());
- IMatchEngine matchEngine = new DefaultMatchEngine(matcher, comparisonFactory);
- EMFCompare comparator = EMFCompare.builder().setMatchEngine(matchEngine).build();
+ // IEObjectMatcher matcher = DefaultMatchEngine.createDefaultEObjectMatcher(UseIdentifiers.NEVER);
+ // IComparisonFactory comparisonFactory = new DefaultComparisonFactory(new DefaultEqualityHelperFactory());
+ // IMatchEngine matchEngine = new DefaultMatchEngine(matcher, comparisonFactory);
+ // EMFCompare comparator = EMFCompare.builder().setMatchEngine(matchEngine).build();
+ EMFCompare comparator = EMFCompare.builder().build();
// Compare the two models
Comparison comparison = comparator.compare(scope);

Back to the top