1 16 17 18 package org.apache.catalina.cluster.session; 19 20 import java.io.InputStream ; 21 import java.io.IOException ; 22 import java.io.ObjectInputStream ; 23 import java.io.ObjectStreamClass ; 24 25 34 35 public final class ReplicationStream 36 extends ObjectInputStream { 37 38 39 42 private ClassLoader classLoader = null; 43 44 52 public ReplicationStream(InputStream stream, 53 ClassLoader classLoader) 54 throws IOException { 55 56 super(stream); 57 this.classLoader = classLoader; 58 } 59 60 69 public Class resolveClass(ObjectStreamClass classDesc) 70 throws ClassNotFoundException , IOException { 71 String name = classDesc.getName(); 72 boolean tryRepFirst = name.startsWith("org.apache.catalina.cluster"); 73 try 74 { 75 if ( tryRepFirst ) return findReplicationClass(name); 76 else return findWebappClass(name); 77 } 78 catch ( Exception x ) 79 { 80 if ( tryRepFirst ) return findWebappClass(name); 81 else return findReplicationClass(name); 82 } 83 } 84 85 public Class findReplicationClass(String name) 86 throws ClassNotFoundException , IOException { 87 return Class.forName(name, false, getClass().getClassLoader()); 88 } 89 90 public Class findWebappClass(String name) 91 throws ClassNotFoundException , IOException { 92 return Class.forName(name, false, classLoader); 93 } 94 95 96 } 97 | Popular Tags |