KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > mobilitools > smi > SMIObjectInputStream


1 /*
2 * MobiliTools: an implementation of the Object Management Group's
3 * Mobile Agent Facility specification.
4 * Copyright (C) 2003 France Telecom R&D
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * MobiliTools $Name: $
21 *
22 * Contact: mobilitools-smi@lists.debian-sf.objectweb.org
23 *
24 * Authors: Bruno Dillenseger
25 */

26
27
28 package org.objectweb.mobilitools.smi;
29
30
31 import java.io.*;
32 import org.omg.CfMAF.MAFAgentSystem;
33 import org.omg.CfMAF.AgentProfile;
34
35
36 /**
37  * MobiliTools $Name: $, $Id: SMIObjectInputStream.java,v 1.1.1.1 2003/03/28 14:48:05 dillense Exp $
38  * <P>
39  * Responsible for deserializing (with a specific classloader) agents
40  * received by an agency.
41 */

42 public class SMIObjectInputStream extends ObjectInputStream
43 {
44     ClassLoader JavaDoc my_loader;
45
46
47     public SMIObjectInputStream(
48         InputStream stream,
49         ClassLoader JavaDoc loader)
50         throws StreamCorruptedException, IOException
51     {
52         super(stream);
53         my_loader = loader;
54     }
55
56
57     public SMIObjectInputStream(
58         InputStream stream,
59         String JavaDoc codebase,
60         AgentProfile profile,
61         MAFAgentSystem provider)
62         throws StreamCorruptedException, IOException
63     {
64         super(stream);
65         my_loader = Misc.getClassLoader(
66             Thread.currentThread().getContextClassLoader(),
67             codebase,
68             profile,
69             provider);
70     }
71
72
73     protected Class JavaDoc resolveClass (ObjectStreamClass classDesc)
74         throws IOException, ClassNotFoundException JavaDoc
75     {
76         try
77         {
78             return super.resolveClass(classDesc);
79         }
80         catch (ClassNotFoundException JavaDoc e)
81         {
82             return my_loader.loadClass(classDesc.getName());
83         }
84     }
85 }
86
Popular Tags