1 /**********************************************************************
2 * XStreamAdapter.java
3 * created on 08.08.2004 by netseeker
4 * $Source: /cvsroot/ejoe/EJOE/src/de/netseeker/ejoe/adapter/XStreamAdapter.java,v $
5 * $Date: 2006/02/04 16:14:06 $
6 * $Revision: 1.21 $
7 *********************************************************************/
8
9 package de.netseeker.ejoe.adapter;
10
11 import java.io.IOException;
12 import java.io.InputStream;
13 import java.io.OutputStream;
14
15 import com.thoughtworks.xstream.XStream;
16
17 /***
18 * An adapter for (de)serializing objects via the great XStream library
19 *
20 * @author netseeker aka Michael Manske
21 * @link http://xstream.codehaus.org
22 */
23 public class XStreamAdapter implements SerializeAdapter
24 {
25 private static XStream xstream = new XStream();
26
27
28
29
30
31
32 public Object read(InputStream in) throws IOException
33 {
34 return xstream.fromXML(in);
35 }
36
37
38
39
40
41
42
43 public void write(Object obj, OutputStream out) throws IOException
44 {
45 xstream.toXML(obj, out);
46 }
47
48
49
50
51
52
53 public void handleClassLoaderChange(ClassLoader classLoader)
54 {
55 xstream.setClassLoader(classLoader);
56 }
57 }