1 50 package org.apache.avalon.excalibur.io; 51 52 import java.io.IOException ; 53 import java.io.InputStream ; 54 import java.io.ObjectInputStream ; 55 import java.io.ObjectStreamClass ; 56 import java.io.StreamCorruptedException ; 57 58 65 public class ClassLoaderObjectInputStream 66 extends ObjectInputStream 67 { 68 private ClassLoader m_classLoader; 69 70 public ClassLoaderObjectInputStream( final ClassLoader classLoader, 71 final InputStream inputStream ) 72 throws IOException , StreamCorruptedException 73 { 74 super( inputStream ); 75 m_classLoader = classLoader; 76 } 77 78 protected Class resolveClass( final ObjectStreamClass objectStreamClass ) 79 throws IOException , ClassNotFoundException 80 { 81 final Class clazz = 82 Class.forName( objectStreamClass.getName(), false, m_classLoader ); 83 84 if( null != clazz ) 85 { 86 return clazz; } 88 else 89 { 90 return super.resolveClass( objectStreamClass ); 92 } 93 } 94 } 95 | Popular Tags |