| Summary: | Provide custom CrossReferencer delegation | ||
|---|---|---|---|
| Product: | [Modeling] EMF | Reporter: | Victor Roldan Betancort <vroldanbet> |
| Component: | Core | Assignee: | Ed Merks <Ed.Merks> |
| Status: | NEW --- | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | Ed.Merks, knut.wannheden, stepper, vroldanbet |
| Version: | 2.7.0 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
|
Description
Victor Roldan Betancort
Please Ed, if you find any other requirements as the framework provider, feel free to add them here! So this is mostly about the UsageCrossReferencer? The only place the EMF framework itself uses this in the DeleteCommand. Is that your primary concern? We might make the static finalAll methods (the resource and resource set ones) look for an adapter (on the resource or resource set)... Or is ECrossReferenceAdapter also a concern? It's not used in the framework... We might support some type of adapter lookup mechanism there as well, but Ed, some comments below, (In reply to comment #2) > So this is mostly about the UsageCrossReferencer? The only place the EMF > framework itself uses this in the DeleteCommand. Is that your primary concern? DeleteCommand is a concern, yes, but not the only one. The EMF framework, as you say, does not make any extensive use of the CrossReferncing utilities provided in EcoreUtils. However, frameworks depending on EMF do make use of these utilities. Just some examples: org.eclipse.gmf.runtime.emf.core.util.CrossReferenceAdapter (extends ECrossReferenceAdapter) org.eclipse.m2m.internal.qvt.oml.ast.env.ModelParameterExtent.delete(List<EObject>, EObject) calls: org.eclipse.emf.ecore.util.EcoreUtil.UsageCrossReferencer.findAll(Collection<?>, Collection<?>) org.eclipse.emf.compare.diff.engine.GenericDiffEngine.doDiff(MatchModel, boolean) calls: org.eclipse.emf.ecore.util.EcoreUtil.CrossReferencer.CrossReferencer(EObject) and I'm sure I could find more, but I dont have all EMF based frameworks in my target platform ;) So CrossReferencing is something offered in the EMF framework that ended up being a basic operation for many frameworks. This is fine, but when dealing with models persisted in a CDO repository, that implies an important performance overhead, specially with large models. The assumption of "my models are on memory" are no longer valid with CDO fine-grained and lazy-load basics. > We might make the static finalAll methods (the resource and resource set ones) > look for an adapter (on the resource or resource set)... > That sounds like a nice solution, I had doubts on how could those adapters be automatically installed (specially when those frameworks control a great deal of the execution flow), but that could be done in the Resource.Factory (right?) > Or is ECrossReferenceAdapter also a concern? It's not used in the framework... > We might support some type of adapter lookup mechanism there as well, but Yes, ECrossReferenceAdapter is a concern (as shown above) and it's also a whole different story. I had to sub-class it and substitute with specialized logic. So it looks like there should be ECrossReferenceAdapter delegation mechanism too (I guess it's late to add factories...). So if we changed DeleteCommand.findReferences to the following then it would reuse a cross reference adapter, if there is one on the resource set
protected Map<EObject, Collection<EStructuralFeature.Setting>> findReferences(Collection<EObject> eObjects)
{
ResourceSet resourceSet = domain.getResourceSet();
ECrossReferenceAdapter crossReferenceAdapter = ECrossReferenceAdapter.getCrossReferenceAdapter(resourceSet);
if (crossReferenceAdapter != null)
{
Map<EObject, Collection<EStructuralFeature.Setting>> result = new HashMap<EObject, Collection<EStructuralFeature.Setting>>();
for (EObject eObject : eObjects)
{
result.put(eObject, crossReferenceAdapter.getInverseReferences(eObject, true));
}
return result;
}
else
{
return EcoreUtil.UsageCrossReferencer.findAll(eObjects, resourceSet);
}
}
That appears to be sufficient to address the issue in the core framework, but it's not clear that solves the downstream problems. But those are in other frameworks, so I'm not sure what to do about those. As long as they make sure they install an adapter on the resource set that derives from ECrossReferenceAdapter, it's perhaps sufficient.
Does this help?
Hi Ed,
sorry for not giving any feedback on this. 2013 is been a weird year :P
As you said, your suggestion may help for the core framework, but it wont to any other frameworks using EcoreUtil. CrossReferencer and subclasses are API and may be used anywhere. I haven't made an analysis of how much is it used, and sure your proposal would help.
Here's a simple and apparently innocuous proposal. Modification of org.eclipse.emf.ecore.util.EcoreUtil.UsageCrossReferencer.find(EObject, EObject)
public static Collection<EStructuralFeature.Setting> find(EObject eObjectOfInterest, EObject eObject)
{
CrossReferencerFactory factory = CrossReferencerFactory.Registry.INSTANCE.getFactoryFor(eObject);
if (factory != null) {
return factory.createUsageCrossReferencer(eObject).findUsage(eObjectOfInterest);
}
return new UsageCrossReferencer(eObject).findUsage(eObjectOfInterest);
}
If it looks good to you, I have a working prototype ready for review. |