1 16 package org.apache.axis.utils; 17 18 import java.io.ByteArrayOutputStream ; 19 import java.io.FileInputStream ; 20 import java.io.FileNotFoundException ; 21 import java.io.IOException ; 22 import java.io.InputStream ; 23 24 33 public class JWSClassLoader extends ClassLoader { 34 35 private String classFile = null; 36 private String name = null; 37 38 50 public JWSClassLoader(String name, ClassLoader cl, String classFile) 51 throws FileNotFoundException , IOException 52 { 53 super(cl); 54 55 this.name = name + ".class"; 56 this.classFile = classFile; 57 58 FileInputStream fis = new FileInputStream ( classFile ); 59 ByteArrayOutputStream baos = new ByteArrayOutputStream(); 60 byte buf[] = new byte[1024]; 61 for(int i = 0; (i = fis.read(buf)) != -1; ) 62 baos.write(buf, 0, i); 63 fis.close(); 64 baos.close(); 65 66 67 68 byte[] data = baos.toByteArray(); 69 defineClass( name, data, 0, data.length ); 70 71 ClassUtils.setClassLoader(name,this); 72 } 73 74 82 public InputStream getResourceAsStream(String resourceName) { 83 try { 84 if (resourceName.equals(name)) 85 return new FileInputStream ( classFile ); 86 } catch (FileNotFoundException e) { 87 } 89 return null; 90 } 91 } 92 | Popular Tags |