KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > iapi > services > io > ApplicationObjectInputStream


1 /*
2
3    Derby - Class org.apache.derby.iapi.services.io.ApplicationObjectInputStream
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.iapi.services.io;
23
24 import org.apache.derby.iapi.services.loader.ClassFactory;
25
26 import java.io.ObjectStreamClass JavaDoc;
27 import java.io.ObjectInputStream JavaDoc;
28 import java.io.IOException JavaDoc;
29 import java.io.InputStream JavaDoc;
30
31 /**
32     An object input stream that implements resolve class in order
33     to load the class through the ClassFactory.loadApplicationClass method.
34 */

35 class ApplicationObjectInputStream extends ObjectInputStream JavaDoc
36     implements ErrorObjectInput
37 {
38
39     protected ClassFactory cf;
40     protected ObjectStreamClass JavaDoc initialClass;
41
42     ApplicationObjectInputStream(InputStream JavaDoc in, ClassFactory cf)
43         throws IOException JavaDoc {
44         super(in);
45         this.cf = cf;
46     }
47
48     protected Class JavaDoc resolveClass(ObjectStreamClass JavaDoc v)
49         throws IOException JavaDoc, ClassNotFoundException JavaDoc {
50
51         if (initialClass == null)
52             initialClass = v;
53
54         if (cf != null)
55             return cf.loadApplicationClass(v);
56
57         throw new ClassNotFoundException JavaDoc(v.getName());
58     }
59
60     public String JavaDoc getErrorInfo() {
61         if (initialClass == null)
62             return "";
63
64         return initialClass.getName() + " (serialVersionUID="
65             + initialClass.getSerialVersionUID() + ")";
66     }
67
68     public Exception JavaDoc getNestedException() {
69         return null;
70     }
71
72 }
73
Popular Tags