brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [05/11] brooklyn-server git commit: make mappers static in prep for refactoring
Date Thu, 08 Jun 2017 09:37:39 GMT
make mappers static in prep for refactoring


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/11a26d6c
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/11a26d6c
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/11a26d6c

Branch: refs/heads/master
Commit: 11a26d6cf828e045743ca4b5a59f637eb59845e4
Parents: 3b39ca6
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Wed Jun 7 11:31:42 2017 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Wed Jun 7 11:31:42 2017 +0100

----------------------------------------------------------------------
 .../core/mgmt/persist/XmlMementoSerializer.java         | 12 ++++++++----
 .../brooklyn/util/core/xstream/XmlSerializer.java       |  4 +++-
 2 files changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/11a26d6c/core/src/main/java/org/apache/brooklyn/core/mgmt/persist/XmlMementoSerializer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/persist/XmlMementoSerializer.java
b/core/src/main/java/org/apache/brooklyn/core/mgmt/persist/XmlMementoSerializer.java
index 2218c56..77c1dc9 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/persist/XmlMementoSerializer.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/persist/XmlMementoSerializer.java
@@ -69,6 +69,7 @@ import org.slf4j.LoggerFactory;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Optional;
+import com.thoughtworks.xstream.XStream;
 import com.thoughtworks.xstream.converters.Converter;
 import com.thoughtworks.xstream.converters.MarshallingContext;
 import com.thoughtworks.xstream.converters.SingleValueConverter;
@@ -140,10 +141,11 @@ public class XmlMementoSerializer<T> extends XmlSerializer<T>
implements Memento
     }
     
     // Warning: this is called in the super-class constructor, so before this constructor!
+    // xstream will be set, but other firelds might not be
     @Override
     protected MapperWrapper wrapMapperForNormalUsage(Mapper next) {
         MapperWrapper mapper = super.wrapMapperForNormalUsage(next);
-        mapper = new OsgiClassnameMapper(mapper);
+        mapper = new OsgiClassnameMapper(xstream, mapper);
         mapper = new CustomMapper(mapper, Entity.class, "entityProxy");
         mapper = new CustomMapper(mapper, Location.class, "locationProxy");
         mapper = new UnwantedStateLoggingMapper(mapper);
@@ -177,7 +179,7 @@ public class XmlMementoSerializer<T> extends XmlSerializer<T>
implements Memento
      * 
      * @author aled
      */
-    public class CustomMapper extends MapperWrapper {
+    public static class CustomMapper extends MapperWrapper {
         private final Class<?> clazz;
         private final String alias;
 
@@ -399,11 +401,13 @@ public class XmlMementoSerializer<T> extends XmlSerializer<T>
implements Memento
         }
     }
 
-    public class OsgiClassnameMapper extends MapperWrapper {
+    public static class OsgiClassnameMapper extends MapperWrapper {
         private final OsgiClassPrefixer prefixer;
+        private final XStream xstream;
         
-        OsgiClassnameMapper(MapperWrapper mapper) {
+        OsgiClassnameMapper(XStream xstream, MapperWrapper mapper) {
             super(mapper);
+            this.xstream = xstream;
             prefixer = new OsgiClassPrefixer();
         }
         

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/11a26d6c/core/src/main/java/org/apache/brooklyn/util/core/xstream/XmlSerializer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/util/core/xstream/XmlSerializer.java b/core/src/main/java/org/apache/brooklyn/util/core/xstream/XmlSerializer.java
index db8e9c6..bb9755d 100644
--- a/core/src/main/java/org/apache/brooklyn/util/core/xstream/XmlSerializer.java
+++ b/core/src/main/java/org/apache/brooklyn/util/core/xstream/XmlSerializer.java
@@ -115,7 +115,9 @@ public class XmlSerializer<T> {
                 return xstream.getClassLoaderReference().getReference();
             }
         };
-        return new ClassRenamingMapper(result, deserializingClassRenames, classLoaderSupplier);
+        result = new ClassRenamingMapper(result, deserializingClassRenames, classLoaderSupplier);
+//        result = new OsgiClassnameMapper(xstream, result);
+        return result;
     }
     /** Extension point where sub-classes can add mappers wanted when instances of a class
are serialized, 
      * including {@link #wrapMapperForAllLowLevelMentions(Mapper)}, plus any usual domain
mappings. */


Mime
View raw message