-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing bug of includes from subclasses, including major refactor of X…
…StreamSerializer. Closes gh-400
- Loading branch information
Showing
7 changed files
with
339 additions
and
136 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
vraptor-core/src/main/java/br/com/caelum/vraptor/serialization/xstream/ProxyConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package br.com.caelum.vraptor.serialization.xstream; | ||
|
||
import br.com.caelum.vraptor.serialization.ProxyInitializer; | ||
|
||
import com.thoughtworks.xstream.XStream; | ||
import com.thoughtworks.xstream.converters.Converter; | ||
import com.thoughtworks.xstream.converters.MarshallingContext; | ||
import com.thoughtworks.xstream.converters.UnmarshallingContext; | ||
import com.thoughtworks.xstream.io.HierarchicalStreamReader; | ||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter; | ||
|
||
public final class ProxyConverter implements Converter { | ||
private final ProxyInitializer initializer; | ||
private final XStream xstream; | ||
|
||
public ProxyConverter(ProxyInitializer initializer, XStream xstream) { | ||
this.initializer = initializer; | ||
this.xstream = xstream; | ||
} | ||
public boolean canConvert(Class clazz) { | ||
return initializer.isProxy(clazz); | ||
} | ||
|
||
public Object unmarshal(HierarchicalStreamReader reader, | ||
UnmarshallingContext context) { | ||
throw new AssertionError(); | ||
} | ||
|
||
public void marshal(Object value, HierarchicalStreamWriter writer, | ||
MarshallingContext context) { | ||
Converter converter = xstream.getConverterLookup().lookupConverterForType(initializer.getActualClass(value)); | ||
initializer.initialize(value); | ||
converter.marshal(value, writer, context); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
vraptor-core/src/main/java/br/com/caelum/vraptor/serialization/xstream/Serializee.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package br.com.caelum.vraptor.serialization.xstream; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import com.google.common.collect.Lists; | ||
|
||
public class Serializee { | ||
private Object root; | ||
private Class<?> rootClass; | ||
private List<String> includes = Lists.newArrayList(); | ||
private List<String> excludes = Lists.newArrayList(); | ||
private Set<Class<?>> elementTypes; | ||
private boolean recursive; | ||
|
||
public Object getRoot() { | ||
return root; | ||
} | ||
public void setRoot(Object root) { | ||
this.root = root; | ||
} | ||
public Class<?> getRootClass() { | ||
return rootClass; | ||
} | ||
public void setRootClass(Class<?> rootClass) { | ||
this.rootClass = rootClass; | ||
} | ||
public List<String> getIncludes() { | ||
return includes; | ||
} | ||
public List<String> getExcludes() { | ||
return excludes; | ||
} | ||
public Set<Class<?>> getElementTypes() { | ||
return elementTypes; | ||
} | ||
public void setElementTypes(Set<Class<?>> elementTypes) { | ||
this.elementTypes = elementTypes; | ||
} | ||
public boolean isRecursive() { | ||
return recursive; | ||
} | ||
public void setRecursive(boolean recursive) { | ||
this.recursive = recursive; | ||
} | ||
public void excludeAll(List<String> names) { | ||
checkPresenceOf(names); | ||
excludes.addAll(names); | ||
} | ||
public void includeAll(List<String> names) { | ||
checkPresenceOf(names); | ||
includes.addAll(names); | ||
} | ||
|
||
private void checkPresenceOf(List<String> names) { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.