KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > internal > helper > CustomObjectInputStream


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2005, Oracle. All rights reserved.
22
package oracle.toplink.essentials.internal.helper;
23
24 import java.lang.Class JavaDoc;
25 import java.lang.ClassNotFoundException JavaDoc;
26 import java.io.IOException JavaDoc;
27 import java.io.InputStream JavaDoc;
28 import java.io.ObjectStreamClass JavaDoc;
29 import java.io.ObjectInputStream JavaDoc;
30 import oracle.toplink.essentials.sessions.Session;
31 import oracle.toplink.essentials.internal.helper.ConversionManager;
32
33 /**
34  * INTERNAL:
35  * Defines a custom ObjectInputStream that is used with SerializedObjectMappings
36  * to ensure the correct class loader is used.
37  * BUG# 2813583
38  *
39  * @auther Guy Pelletier
40  * @version 1.0 March 25/03
41  */

42 public class CustomObjectInputStream extends ObjectInputStream JavaDoc {
43     Session m_session;
44
45     public CustomObjectInputStream(InputStream JavaDoc stream, Session session) throws IOException JavaDoc {
46         super(stream);
47         m_session = session;
48     }
49
50     public Class JavaDoc resolveClass(ObjectStreamClass JavaDoc classDesc) throws ClassNotFoundException JavaDoc, IOException JavaDoc {
51         ConversionManager cm = m_session.getDatasourceLogin().getDatasourcePlatform().getConversionManager();
52         return (Class JavaDoc)cm.convertObject(classDesc.getName(), Class JavaDoc.class);
53     }
54 }
55
Popular Tags