diff --git a/bundles/org.eclipse.sirius.emfjson.ide/META-INF/MANIFEST.MF b/bundles/org.eclipse.sirius.emfjson.ide/META-INF/MANIFEST.MF
index 801cc25..903ed56 100644
--- a/bundles/org.eclipse.sirius.emfjson.ide/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.sirius.emfjson.ide/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.sirius.emfjson.ide;singleton:=true
-Bundle-Version: 2.3.6.qualifier
+Bundle-Version: 2.3.7.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-Localization: bundle
Require-Bundle: org.eclipse.sirius.emfjson;bundle-version="2.1.0",
diff --git a/bundles/org.eclipse.sirius.emfjson.ide/pom.xml b/bundles/org.eclipse.sirius.emfjson.ide/pom.xml
index 684810e..2cbe4be 100644
--- a/bundles/org.eclipse.sirius.emfjson.ide/pom.xml
+++ b/bundles/org.eclipse.sirius.emfjson.ide/pom.xml
@@ -18,13 +18,13 @@
org.eclipse.sirius.emfjson
org.eclipse.sirius.emfjson.releng
- 2.3.6-SNAPSHOT
+ 2.3.7-SNAPSHOT
../../releng/org.eclipse.sirius.emfjson.releng
org.eclipse.sirius.emfjson.ide
- 2.3.6-SNAPSHOT
+ 2.3.7-SNAPSHOT
eclipse-plugin
Sirius EMF JSON - IDE Integration
diff --git a/bundles/org.eclipse.sirius.emfjson/META-INF/MANIFEST.MF b/bundles/org.eclipse.sirius.emfjson/META-INF/MANIFEST.MF
index 341667c..c6eef82 100644
--- a/bundles/org.eclipse.sirius.emfjson/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.sirius.emfjson/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.sirius.emfjson
-Bundle-Version: 2.3.6.qualifier
+Bundle-Version: 2.3.7.qualifier
Bundle-Vendor: %Bundle-Vendor
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-Localization: bundle
diff --git a/bundles/org.eclipse.sirius.emfjson/pom.xml b/bundles/org.eclipse.sirius.emfjson/pom.xml
index 2d14452..7f4f851 100644
--- a/bundles/org.eclipse.sirius.emfjson/pom.xml
+++ b/bundles/org.eclipse.sirius.emfjson/pom.xml
@@ -18,13 +18,13 @@
org.eclipse.sirius.emfjson
org.eclipse.sirius.emfjson.releng
- 2.3.6-SNAPSHOT
+ 2.3.7-SNAPSHOT
../../releng/org.eclipse.sirius.emfjson.releng
org.eclipse.sirius.emfjson
- 2.3.6-SNAPSHOT
+ 2.3.7-SNAPSHOT
eclipse-plugin
Sirius EMF JSON
diff --git a/bundles/org.eclipse.sirius.emfjson/src/main/java/org/eclipse/sirius/emfjson/resource/JsonResource.java b/bundles/org.eclipse.sirius.emfjson/src/main/java/org/eclipse/sirius/emfjson/resource/JsonResource.java
index 89057c1..84b08ef 100644
--- a/bundles/org.eclipse.sirius.emfjson/src/main/java/org/eclipse/sirius/emfjson/resource/JsonResource.java
+++ b/bundles/org.eclipse.sirius.emfjson/src/main/java/org/eclipse/sirius/emfjson/resource/JsonResource.java
@@ -22,6 +22,7 @@
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.resource.Resource;
@@ -425,6 +426,75 @@ interface IEObjectHandler {
*/
Object OPTION_SAVE_FEATURES_ORDER_COMPARATOR = "OPTION_SAVE_FEATURES_ORDER_COMPARATOR"; //$NON-NLS-1$
+ /**
+ * An option to provide an ISerializationListener.
+ */
+ String OPTION_SERIALIZATION_LISTENER = "OPTION_SERIALIZATION_LISTENER"; //$NON-NLS-1$
+
+ /**
+ * Used to listen to various events during the serialization.
+ *
+ * @author Stephane Begaudeau
+ */
+ interface ISerializationListener {
+
+ /**
+ * Called when an entry is added to the namespace header.
+ *
+ * @param nsPrefix
+ * The prefix of the ePackage added
+ * @param nsURI
+ * The URI of the ePackage added
+ */
+ void onNsHeaderEntryAdded(String nsPrefix, String nsURI);
+
+ /**
+ * Called when an object is serialized.
+ *
+ * @param eObject
+ * The EObject serialized
+ * @param jsonElement
+ * The serialization of the EObject
+ */
+ void onObjectSerialized(EObject eObject, JsonElement jsonElement);
+
+ /**
+ * Called when a proxy to an object located in another resource has been created.
+ *
+ * @param eObject
+ * The object for which the URI is created
+ * @param eReference
+ * The reference containing the object
+ * @param uri
+ * The uri created
+ */
+ void onCrossReferenceURICreated(EObject eObject, EReference eReference, String uri);
+
+ /**
+ * Implementation of the listener which does nothing.
+ *
+ * @author Stephane Begaudeau
+ */
+ class NoOp implements ISerializationListener {
+
+ @Override
+ public void onNsHeaderEntryAdded(String nsPrefix, String nsURI) {
+ // Do nothing
+ }
+
+ @Override
+ public void onObjectSerialized(EObject eObject, JsonElement jsonElement) {
+ // Do nothing
+ }
+
+ @Override
+ public void onCrossReferenceURICreated(EObject eObject, EReference eReference, String uri) {
+ // Do nothing
+ }
+
+ }
+ }
+
/**
* Associate an ID to the {@link EObject}.
*
@@ -434,4 +504,5 @@ interface IEObjectHandler {
* the id
*/
void setID(EObject eObject, String id);
+
}
diff --git a/bundles/org.eclipse.sirius.emfjson/src/main/java/org/eclipse/sirius/emfjson/utils/GsonEObjectSerializer.java b/bundles/org.eclipse.sirius.emfjson/src/main/java/org/eclipse/sirius/emfjson/utils/GsonEObjectSerializer.java
index 87442ab..a22cec8 100644
--- a/bundles/org.eclipse.sirius.emfjson/src/main/java/org/eclipse/sirius/emfjson/utils/GsonEObjectSerializer.java
+++ b/bundles/org.eclipse.sirius.emfjson/src/main/java/org/eclipse/sirius/emfjson/utils/GsonEObjectSerializer.java
@@ -65,6 +65,7 @@
import org.eclipse.sirius.emfjson.resource.JsonResource;
import org.eclipse.sirius.emfjson.resource.JsonResource.EStructuralFeaturesFilter;
import org.eclipse.sirius.emfjson.resource.JsonResource.IEObjectHandler;
+import org.eclipse.sirius.emfjson.resource.JsonResource.ISerializationListener;
import org.eclipse.sirius.emfjson.resource.JsonResource.ResourceEntityHandler;
import org.eclipse.sirius.emfjson.resource.exception.DanglingHREFException;
@@ -127,6 +128,8 @@ public class GsonEObjectSerializer implements JsonSerializer> {
*/
private IEObjectHandler eObjectHandler;
+ private ISerializationListener serializationListener;
+
/**
* The constructor.
*
@@ -166,7 +169,11 @@ public GsonEObjectSerializer(Resource resource, Map, ?> options) {
this.helper.setExtendedMetaData(this.extendedMetaData);
}
- this.eObjectHandler = (JsonResource.IEObjectHandler) serializedOptions.get(JsonResource.OPTION_EOBJECT_HANDLER);
+ this.eObjectHandler = (IEObjectHandler) serializedOptions.get(JsonResource.OPTION_EOBJECT_HANDLER);
+ this.serializationListener = (ISerializationListener) serializedOptions.get(JsonResource.OPTION_SERIALIZATION_LISTENER);
+ if (this.serializationListener == null) {
+ this.serializationListener = new ISerializationListener.NoOp();
+ }
this.declareSchemaLocation = Boolean.TRUE.equals(options.get(JsonResource.OPTION_SCHEMA_LOCATION));
@@ -236,6 +243,8 @@ private JsonElement createData(EObject eObject) {
this.eObjectHandler.processSerializedContent(jsonElement, eObject);
}
+ this.serializationListener.onObjectSerialized(eObject, jsonElement);
+
return jsonElement;
}
@@ -835,6 +844,7 @@ private JsonElement createNsHeader() {
List nsPrefixes = this.helper.getPrefixes(ePackage);
for (String nsPrefix : nsPrefixes) {
jsonObject.add(nsPrefix, new JsonPrimitive(nsURI));
+ this.serializationListener.onNsHeaderEntryAdded(nsPrefix, nsURI);
}
}
}
@@ -1381,7 +1391,7 @@ private JsonElement serializeMultipleNonContainmentEReference(EObject eObject, E
break;
case CROSS_DOC:
if (value != null) {
- jsonArray.add(new JsonPrimitive(this.saveHref(value, null)));
+ jsonArray.add(new JsonPrimitive(this.saveHref(value, eReference)));
}
break;
default:
@@ -1495,6 +1505,7 @@ private String saveHref(EObject object, EReference eReference) {
// TODO: element Handler if statement : look at XMLSaveImpl line 2308
value += href;
}
+ this.serializationListener.onCrossReferenceURICreated(object, eReference, value);
return value;
}
@@ -1540,8 +1551,8 @@ private int docKindSingle(EObject eObject, EReference eReference) {
}
/**
- * Return the the URI fragment if the pointed resource URI schema is the same of the Resource URI schema. Return the
- * all URI otherwise.
+ * Return the URI fragment if the pointed resource URI schema is the same of the Resource URI schema. Return the all
+ * URI otherwise.
*
* @param pointedResourceUri
* the pointed resource URI
diff --git a/features/org.eclipse.sirius.emfjson.feature.ide/feature.xml b/features/org.eclipse.sirius.emfjson.feature.ide/feature.xml
index a6198e5..6a7de8f 100644
--- a/features/org.eclipse.sirius.emfjson.feature.ide/feature.xml
+++ b/features/org.eclipse.sirius.emfjson.feature.ide/feature.xml
@@ -2,7 +2,7 @@
diff --git a/features/org.eclipse.sirius.emfjson.feature.ide/pom.xml b/features/org.eclipse.sirius.emfjson.feature.ide/pom.xml
index 845721c..4b03a65 100644
--- a/features/org.eclipse.sirius.emfjson.feature.ide/pom.xml
+++ b/features/org.eclipse.sirius.emfjson.feature.ide/pom.xml
@@ -20,13 +20,13 @@
org.eclipse.sirius.emfjson
org.eclipse.sirius.emfjson.releng
- 2.3.6-SNAPSHOT
+ 2.3.7-SNAPSHOT
../../releng/org.eclipse.sirius.emfjson.releng
org.eclipse.sirius.emfjson.feature.ide
- 2.3.6-SNAPSHOT
+ 2.3.7-SNAPSHOT
eclipse-feature
Sirius EMF JSON - IDE Integration Feature
diff --git a/features/org.eclipse.sirius.emfjson.feature/feature.xml b/features/org.eclipse.sirius.emfjson.feature/feature.xml
index 01521d0..5e2b2b4 100644
--- a/features/org.eclipse.sirius.emfjson.feature/feature.xml
+++ b/features/org.eclipse.sirius.emfjson.feature/feature.xml
@@ -2,7 +2,7 @@
diff --git a/features/org.eclipse.sirius.emfjson.feature/pom.xml b/features/org.eclipse.sirius.emfjson.feature/pom.xml
index 3db1306..07f47d8 100644
--- a/features/org.eclipse.sirius.emfjson.feature/pom.xml
+++ b/features/org.eclipse.sirius.emfjson.feature/pom.xml
@@ -20,13 +20,13 @@
org.eclipse.sirius.emfjson
org.eclipse.sirius.emfjson.releng
- 2.3.6-SNAPSHOT
+ 2.3.7-SNAPSHOT
../../releng/org.eclipse.sirius.emfjson.releng
org.eclipse.sirius.emfjson.feature
- 2.3.6-SNAPSHOT
+ 2.3.7-SNAPSHOT
eclipse-feature
Sirius EMF JSON Feature
diff --git a/releng/org.eclipse.sirius.emfjson.releng/pom.xml b/releng/org.eclipse.sirius.emfjson.releng/pom.xml
index 1dc8f9d..8d70ff4 100644
--- a/releng/org.eclipse.sirius.emfjson.releng/pom.xml
+++ b/releng/org.eclipse.sirius.emfjson.releng/pom.xml
@@ -20,7 +20,7 @@
org.eclipse.sirius.emfjson
org.eclipse.sirius.emfjson.releng
- 2.3.6-SNAPSHOT
+ 2.3.7-SNAPSHOT
pom
Sirius EMF JSON
diff --git a/releng/org.eclipse.sirius.emfjson.targetplatforms/2019-06/pom.xml b/releng/org.eclipse.sirius.emfjson.targetplatforms/2019-06/pom.xml
index 5b6d01a..55920e4 100644
--- a/releng/org.eclipse.sirius.emfjson.targetplatforms/2019-06/pom.xml
+++ b/releng/org.eclipse.sirius.emfjson.targetplatforms/2019-06/pom.xml
@@ -6,13 +6,13 @@
org.eclipse.sirius.emfjson
org.eclipse.sirius.emfjson.releng
- 2.3.6-SNAPSHOT
+ 2.3.7-SNAPSHOT
../../org.eclipse.sirius.emfjson.releng
org.eclipse.sirius.emfjson
emfjson-2019-06
- 2.3.6-SNAPSHOT
+ 2.3.7-SNAPSHOT
eclipse-target-definition
\ No newline at end of file
diff --git a/releng/org.eclipse.sirius.emfjson.targetplatforms/luna/pom.xml b/releng/org.eclipse.sirius.emfjson.targetplatforms/luna/pom.xml
index 6a72b50..eff457a 100644
--- a/releng/org.eclipse.sirius.emfjson.targetplatforms/luna/pom.xml
+++ b/releng/org.eclipse.sirius.emfjson.targetplatforms/luna/pom.xml
@@ -6,13 +6,13 @@
org.eclipse.sirius.emfjson
org.eclipse.sirius.emfjson.releng
- 2.3.6-SNAPSHOT
+ 2.3.7-SNAPSHOT
../../org.eclipse.sirius.emfjson.releng
org.eclipse.sirius.emfjson
emfjson-luna
- 2.3.6-SNAPSHOT
+ 2.3.7-SNAPSHOT
eclipse-target-definition
\ No newline at end of file
diff --git a/repositories/org.eclipse.sirius.emfjson.repository/pom.xml b/repositories/org.eclipse.sirius.emfjson.repository/pom.xml
index ea947d5..ce07baf 100644
--- a/repositories/org.eclipse.sirius.emfjson.repository/pom.xml
+++ b/repositories/org.eclipse.sirius.emfjson.repository/pom.xml
@@ -19,7 +19,7 @@
org.eclipse.sirius.emfjson
org.eclipse.sirius.emfjson.releng
- 2.3.6-SNAPSHOT
+ 2.3.7-SNAPSHOT
../../releng/org.eclipse.sirius.emfjson.releng
diff --git a/tests/org.eclipse.sirius.emfjson.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.sirius.emfjson.tests/META-INF/MANIFEST.MF
index 115f357..dbd496e 100644
--- a/tests/org.eclipse.sirius.emfjson.tests/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.sirius.emfjson.tests/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.sirius.emfjson.tests
-Bundle-Version: 2.3.6.qualifier
+Bundle-Version: 2.3.7.qualifier
Bundle-Vendor: %Bundle-Vendor
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-Localization: bundle
diff --git a/tests/org.eclipse.sirius.emfjson.tests/pom.xml b/tests/org.eclipse.sirius.emfjson.tests/pom.xml
index ad0a0e1..d7cc3d9 100644
--- a/tests/org.eclipse.sirius.emfjson.tests/pom.xml
+++ b/tests/org.eclipse.sirius.emfjson.tests/pom.xml
@@ -20,13 +20,13 @@
org.eclipse.sirius.emfjson
org.eclipse.sirius.emfjson.releng
- 2.3.6-SNAPSHOT
+ 2.3.7-SNAPSHOT
../../releng/org.eclipse.sirius.emfjson.releng
org.eclipse.sirius.emfjson.tests
- 2.3.6-SNAPSHOT
+ 2.3.7-SNAPSHOT
eclipse-test-plugin
Sirius EMF JSON - Tests
diff --git a/tests/org.eclipse.sirius.emfjson.tests/src/main/java/org/eclipse/sirius/emfjson/tests/internal/AbstractEMFJsonTests.java b/tests/org.eclipse.sirius.emfjson.tests/src/main/java/org/eclipse/sirius/emfjson/tests/internal/AbstractEMFJsonTests.java
index 5ff1c6a..589d625 100644
--- a/tests/org.eclipse.sirius.emfjson.tests/src/main/java/org/eclipse/sirius/emfjson/tests/internal/AbstractEMFJsonTests.java
+++ b/tests/org.eclipse.sirius.emfjson.tests/src/main/java/org/eclipse/sirius/emfjson/tests/internal/AbstractEMFJsonTests.java
@@ -34,6 +34,7 @@
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
@@ -67,6 +68,11 @@ public abstract class AbstractEMFJsonTests {
*/
protected Map