EMFModelResourceFactory: allow subclasses to override resource factory / load options
diff --git a/core/plugins/org.eclipse.hawk.emf/src/org/eclipse/hawk/emf/model/EMFModelResourceFactory.java b/core/plugins/org.eclipse.hawk.emf/src/org/eclipse/hawk/emf/model/EMFModelResourceFactory.java
index 767f75d..7b65394 100644
--- a/core/plugins/org.eclipse.hawk.emf/src/org/eclipse/hawk/emf/model/EMFModelResourceFactory.java
+++ b/core/plugins/org.eclipse.hawk.emf/src/org/eclipse/hawk/emf/model/EMFModelResourceFactory.java
@@ -18,7 +18,9 @@
package org.eclipse.hawk.emf.model;
import java.io.File;
+import java.util.Collections;
import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
import org.eclipse.emf.common.util.URI;
@@ -40,9 +42,8 @@
/**
* Property that can be set to a comma-separated list of extensions (e.g.
- * ".railway,.myext") that should be supported in addition to the default
- * ones (".xmi" and ".model"). Composite extensions are allowed (e.g.
- * ".rail.way").
+ * ".railway,.myext") that should be supported in addition to the default ones
+ * (".xmi" and ".model"). Composite extensions are allowed (e.g. ".rail.way").
*/
public static final String PROPERTY_EXTRA_EXTENSIONS = "org.eclipse.hawk.emf.model.extraExtensions";
@@ -92,13 +93,9 @@
// Try to use the globally registered factory, use XMI factory as fallback
final URI fileURI = URI.createFileURI(f.getCanonicalPath());
- Factory factory = resourceSet.getResourceFactoryRegistry().getFactory(fileURI);
- if (factory == null) {
- factory = new XMIResourceFactoryImpl();
- }
-
+ final Factory factory = createResourceFactory(resourceSet, fileURI);
r = factory.createResource(fileURI);
- r.load(null);
+ r.load(createEMFLoadOptions());
ret = new EMFModelResource(r, new EMFWrapperFactory(), this);
} catch (Exception e) {
LOGGER.error("Failed to parse " + f.getAbsolutePath(), e);
@@ -118,6 +115,19 @@
return modelExtensions;
}
+ protected Factory createResourceFactory(ResourceSet resourceSet, URI fileURI) {
+ Factory factory = resourceSet.getResourceFactoryRegistry().getFactory(fileURI);
+ if (factory == null) {
+ return new XMIResourceFactoryImpl();
+ } else {
+ return factory;
+ }
+ }
+
+ protected Map<?, ?> createEMFLoadOptions() {
+ return Collections.emptyMap();
+ }
+
@Override
public boolean canParse(File f) {
String[] split = f.getPath().split("\\.");