1 55 package org.jboss.axis.utils; 56 57 import java.io.ByteArrayOutputStream ; 58 import java.io.FileInputStream ; 59 import java.io.FileNotFoundException ; 60 import java.io.IOException ; 61 import java.io.InputStream ; 62 63 72 public class JWSClassLoader extends ClassLoader 73 { 74 75 private String classFile = null; 76 private String name = null; 77 78 90 public JWSClassLoader(String name, ClassLoader cl, String classFile) 91 throws FileNotFoundException , IOException 92 { 93 super(cl); 94 95 this.name = name + ".class"; 96 this.classFile = classFile; 97 98 FileInputStream fis = new FileInputStream (classFile); 99 ByteArrayOutputStream baos = new ByteArrayOutputStream (); 100 byte buf[] = new byte[1024]; 101 for (int i = 0; (i = fis.read(buf)) != -1;) 102 baos.write(buf, 0, i); 103 fis.close(); 104 baos.close(); 105 106 107 108 byte[] data = baos.toByteArray(); 109 defineClass(name, data, 0, data.length); 110 111 ClassUtils.setClassLoader(name, this); 112 } 113 114 122 public InputStream getResourceAsStream(String resourceName) 123 { 124 try 125 { 126 if (resourceName.equals(name)) 127 return new FileInputStream (classFile); 128 } 129 catch (FileNotFoundException e) 130 { 131 } 133 return null; 134 } 135 } 136 | Popular Tags |