Skip to content
Permalink
Browse files
Fix catalog XML deserializing
Fixes the serialized XML format so it can be deserialized later.
  • Loading branch information
neykov committed Jan 14, 2016
1 parent 58337c4 commit f9591d9f2da776deb51536dba2e064989dbeda87
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
@@ -36,7 +36,8 @@ public CatalogXmlSerializer() {
super(DeserializingClassRenamesProvider.loadDeserializingClassRenames());

xstream.addDefaultImplementation(ArrayList.class, Collection.class);


//Doesn't work well for non-standard lists, like Lists.transform results
xstream.aliasType("list", List.class);
xstream.aliasType("map", Map.class);

@@ -19,6 +19,7 @@
package org.apache.brooklyn.core.mgmt;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.codehaus.jackson.annotate.JsonIgnore;
@@ -85,11 +86,17 @@ public int hashCode() {

public static class TraitsTag extends ListTag<String> {
public TraitsTag(List<Class<?>> interfaces) {
super(Lists.transform(interfaces, new Function<Class<?>, String>() {
@Override public String apply(Class<?> input) {
return input.getName();
}
}));
// The transformed list is a view, meaning that it references
// the instances list. This means that it will serialize
// the list of classes along with the anonymous function which
// is not what we want. Force eager evaluation instead, using
// a simple list, supported by {@link CatalogXmlSerializer}.
super(new ArrayList<String>(
Lists.transform(interfaces, new Function<Class<?>, String>() {
@Override public String apply(Class<?> input) {
return input.getName();
}
})));
}

@JsonProperty("traits")

0 comments on commit f9591d9

Please sign in to comment.