1 19 20 package org.netbeans.modules.search; 21 22 import java.io.IOException ; 23 import java.io.InputStream ; 24 25 50 class SearchTypeInputStream extends java.io.ObjectInputStream { 51 52 59 private Class extSearchType = null; 60 65 private ClassLoader extClassLoader = null; 66 67 68 public SearchTypeInputStream(InputStream in) throws IOException { 69 super(in); 70 } 71 72 79 protected Class resolveClass(java.io.ObjectStreamClass objectStreamClass) 80 throws IOException , ClassNotFoundException { 81 try { 82 return super.resolveClass(objectStreamClass); 83 } catch (ClassNotFoundException ex) { 84 Class extClass = resolveExtClass(objectStreamClass.getName()); 85 if (extClass != null) { 86 return extClass; 87 } else { 88 throw ex; 89 } 90 } 91 } 92 93 104 private Class resolveExtClass(final String className) { 105 if (extSearchType == null) { 106 107 108 extSearchType = Utils.searchTypeForName(className); 109 return extSearchType; 110 } 111 112 116 if (extClassLoader == null) { 117 try { 118 extClassLoader = extSearchType.getClassLoader(); 119 } catch (SecurityException ex) { 120 return null; 121 } 122 } 123 try { 124 return extClassLoader.loadClass(className); 125 } catch (ClassNotFoundException ex) { 126 return null; 127 } 128 } 129 130 } 131 | Popular Tags |