-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Customizando serializer e desserializer de JSON
- Loading branch information
Showing
14 changed files
with
96 additions
and
183 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package br.com.caelum.model; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.thoughtworks.xstream.annotations.XStreamAlias; | ||
import com.thoughtworks.xstream.annotations.XStreamImplicit; | ||
|
||
import br.com.caelum.cadastro.modelo.Aluno; | ||
|
||
@XStreamAlias("alunos") | ||
public class Alunos { | ||
|
||
@XStreamImplicit(itemFieldName="lista")//, keyFieldName="aluno") | ||
private List<Aluno> lista = new ArrayList<Aluno>(); | ||
|
||
@Override | ||
public String toString() { | ||
return this.lista.toString(); | ||
} | ||
|
||
public void addAlunos(List<Aluno> alunos) { | ||
this.lista.addAll(alunos); | ||
} | ||
|
||
public void setLista(List<Aluno> lista) { | ||
this.lista = lista; | ||
} | ||
|
||
public List<Aluno> getLista() { | ||
return lista; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
81 changes: 0 additions & 81 deletions
81
src/main/java/br/com/caelum/models/SincronismoServerPost.java
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
src/main/java/br/com/caelum/support/AnnotatedXStreamClasses.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,13 @@ | ||
package br.com.caelum.support; | ||
|
||
import br.com.caelum.cadastro.modelo.Aluno; | ||
import br.com.caelum.vraptor.ioc.Component; | ||
|
||
@Component | ||
public class AnnotatedXStreamClasses { | ||
private Class<?>[] types = {Aluno.class}; | ||
|
||
public Class<?>[] getTypes() { | ||
return types; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/br/com/caelum/support/CustomJSONSerializer.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,30 @@ | ||
package br.com.caelum.support; | ||
|
||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import br.com.caelum.vraptor.interceptor.TypeNameExtractor; | ||
import br.com.caelum.vraptor.ioc.Component; | ||
import br.com.caelum.vraptor.serialization.ProxyInitializer; | ||
import br.com.caelum.vraptor.serialization.xstream.XStreamJSONSerialization; | ||
|
||
import com.thoughtworks.xstream.XStream; | ||
import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; | ||
|
||
@Component | ||
public class CustomJSONSerializer extends XStreamJSONSerialization { | ||
private AnnotatedXStreamClasses classes; | ||
|
||
public CustomJSONSerializer(HttpServletResponse response, | ||
TypeNameExtractor extractor, ProxyInitializer initializer, AnnotatedXStreamClasses classes) { | ||
|
||
super(response, extractor, initializer); | ||
this.classes = classes; | ||
} | ||
|
||
@Override | ||
protected XStream getXStream() { | ||
XStream xStream = new XStream(new JettisonMappedXmlDriver()); | ||
xStream.processAnnotations(classes.getTypes()); | ||
return xStream; | ||
} | ||
} |
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
Binary file not shown.
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 |
---|---|---|
@@ -1,14 +1,6 @@ | ||
/*C6*/SET SCHEMA PUBLIC | ||
INSERT INTO ALUNO VALUES(3,'Rua Eca de Queiros 279 Vila Mariana SP','GUI',9.8E0,'aqui','4523452') | ||
COMMIT | ||
/*C5*/SET SCHEMA PUBLIC | ||
/*C33*/SET SCHEMA PUBLIC | ||
DISCONNECT | ||
/*C7*/SET SCHEMA PUBLIC | ||
/*C32*/SET SCHEMA PUBLIC | ||
DISCONNECT | ||
/*C6*/DISCONNECT | ||
/*C9*/SET SCHEMA PUBLIC | ||
DISCONNECT | ||
/*C8*/SET SCHEMA PUBLIC | ||
DISCONNECT | ||
/*C10*/SET SCHEMA PUBLIC | ||
/*C34*/SET SCHEMA PUBLIC | ||
DISCONNECT |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#HSQL Database Engine 2.2.4 | ||
#Mon Dec 19 14:30:43 BRST 2011 | ||
#Wed Dec 21 17:04:36 BRST 2011 | ||
version=2.2.4 | ||
modified=yes |
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