1 /**********************************************************************
2 * SerializeAdapter.java
3 * created on 08.08.2004 by netseeker
4 * $Source: /cvsroot/ejoe/EJOE/src/de/netseeker/ejoe/adapter/SerializeAdapter.java,v $
5 * $Date: 2006/11/05 16:33:38 $
6 * $Revision: 1.15 $
7 *
8 * ====================================================================
9 *
10 * Copyright 2005-2006 netseeker aka Michael Manske
11 *
12 * Licensed under the Apache License, Version 2.0 (the "License");
13 * you may not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 * http://www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 * ====================================================================
24 *
25 * This file is part of the ejoe framework.
26 * For more information on the author, please see
27 * <http://www.manskes.de/>.
28 *
29 *********************************************************************/
30
31 package de.netseeker.ejoe.adapter;
32
33 import java.io.InputStream;
34 import java.io.OutputStream;
35 import java.io.Serializable;
36
37 /***
38 * Interface defining all methods required by a (de)serialize adapter.
39 *
40 * @author netseeker aka Michael Manske
41 * @since 0.3.0
42 */
43 public interface SerializeAdapter extends Serializable
44 {
45 /***
46 * Deserializes an object out of an given InputStream
47 *
48 * @param in the input stream to use for deserialization
49 * @return a deserialized object instance
50 * @throws Exception
51 */
52 public Object read( InputStream in ) throws Exception;
53
54 /***
55 * Serializes an object into an output stream
56 *
57 * @param obj object that should get serialized
58 * @param out the outputstream into which the object should serialized
59 * @throws Exception
60 */
61 public void write( Object obj, OutputStream out ) throws Exception;
62
63 /***
64 * Signals a change of the ContextClassLoader of the current thread to the adapter. This method will be called when
65 * the EJOE client is started with support for remote classloading.
66 *
67 * @param classLoader
68 */
69 public void handleClassLoaderChange( ClassLoader classLoader );
70
71 /***
72 * Signals if this adapter has problems with EJOE's UncloseableInputStreams and requires a really closed Stream
73 * (which EJOE prevents to ensure that an adapter can not close the underlying socket unintentionally). If the
74 * adapter requires closed streams, EJOE will append a custom EOF signature at the end of the stream and return -1
75 * in Inputstream#read when EOF is reached.
76 *
77 * @return true if the adapter requires EOF to detect the end of the stream
78 * @see <a href="http://forum.java.sun.com/thread.jspa?threadID=535062&messageID=2585304">XMLEncoder/Decoder over sockets</a>
79 */
80 public boolean requiresCustomEOFHandling();
81
82 /***
83 * Indicates that the adapter uses a StreamBuffer mechanism and doesn't require a buffered input stream
84 *
85 * @return true if the adapter doesn't require a buffered inputstream, otherwise false
86 */
87 public boolean isSelfBuffered();
88
89 /***
90 * @return A recognized mime type
91 * @see <a href="http://www.iana.org/assignments/media-types/">mime type list of IANA</a>
92 */
93 public String getContentType();
94 }