01: /*
02:
03: Derby - Class org.apache.derby.iapi.services.io.ApplicationObjectInputStream
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to you under the Apache License, Version 2.0
09: (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;
27: import java.io.ObjectInputStream;
28: import java.io.IOException;
29: import java.io.InputStream;
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 implements
36: ErrorObjectInput {
37:
38: protected ClassFactory cf;
39: protected ObjectStreamClass initialClass;
40:
41: ApplicationObjectInputStream(InputStream in, ClassFactory cf)
42: throws IOException {
43: super (in);
44: this .cf = cf;
45: }
46:
47: protected Class resolveClass(ObjectStreamClass v)
48: throws IOException, ClassNotFoundException {
49:
50: if (initialClass == null)
51: initialClass = v;
52:
53: if (cf != null)
54: return cf.loadApplicationClass(v);
55:
56: throw new ClassNotFoundException(v.getName());
57: }
58:
59: public String getErrorInfo() {
60: if (initialClass == null)
61: return "";
62:
63: return initialClass.getName() + " (serialVersionUID="
64: + initialClass.getSerialVersionUID() + ")";
65: }
66:
67: public Exception getNestedException() {
68: return null;
69: }
70:
71: }
|