View Javadoc

1   /**********************************************************************
2    * JavaBeansXmlAdapter.java
3    * created on 10.03.2005 by netseeker
4    * $Source: /cvsroot/ejoe/EJOE/src/de/netseeker/ejoe/adapter/JavaBeansXmlAdapter.java,v $
5    * $Date: 2006/02/04 14:16:49 $
6    * $Revision: 1.3 $
7    *********************************************************************/
8   package de.netseeker.ejoe.adapter;
9   
10  import java.beans.XMLDecoder;
11  import java.beans.XMLEncoder;
12  import java.io.IOException;
13  import java.io.InputStream;
14  import java.io.OutputStream;
15  
16  /***
17   * Simple SerializeAdapter implementation using the XmlEncoder/XmlDecoder
18   * classes of the Java Beans API
19   * 
20   * @author netseeker
21   */
22  public class JavaBeansXmlAdapter implements SerializeAdapter
23  {
24  	/*
25  	 * (non-Javadoc)
26  	 * 
27  	 * @see de.netseeker.ejoe.adapter.SerializeAdapter#read(java.io.InputStream)
28  	 */
29  	public Object read(InputStream in) throws IOException
30  	{
31  		XMLDecoder decoder = new XMLDecoder(in);
32  		return decoder.readObject();
33  	}
34  
35  	/*
36  	 * (non-Javadoc)
37  	 * 
38  	 * @see de.netseeker.ejoe.adapter.SerializeAdapter#write(java.lang.Object,
39  	 *      java.io.OutputStream)
40  	 */
41  	public void write(Object obj, OutputStream out) throws IOException
42  	{
43  		XMLEncoder encoder = new XMLEncoder(out);
44  		encoder.writeObject(obj);
45  	}
46  
47  	/*
48  	 * (non-Javadoc)
49  	 * 
50  	 * @see de.netseeker.ejoe.adapter.SerializeAdapter#handleClassLoaderChange(java.lang.ClassLoader)
51  	 */
52  	public void handleClassLoaderChange(ClassLoader classLoader)
53  	{
54  		// nothing to do, we use method-locale encoder/decoder instances
55  	}
56  }