1 23 24 28 29 package org.apache.tools.ant.taskdefs.optional.sun.appserv; 30 31 import java.util.Hashtable ; 32 import java.io.File ; 33 import java.net.URL ; 34 import java.net.URLClassLoader ; 35 import java.net.MalformedURLException ; 36 37 38 public class AppservClassLoader extends URLClassLoader { 39 private Hashtable hashTable = new Hashtable (3); 41 42 public AppservClassLoader() throws MalformedURLException , RuntimeException { 43 super(new URL [0], AppservClassLoader.class.getClassLoader()); 44 } 45 46 public void addURL(File f) throws MalformedURLException , RuntimeException { 47 if (f.isFile()){ 48 addURL(f.toURI().toURL()); 49 } 52 else{ 53 } 55 } 56 57 58 public static AppservClassLoader getClassLoader() { 59 60 AppservClassLoader loader = null; 61 62 try { 63 loader = new AppservClassLoader(); 64 String installRoot = System.getProperty("com.sun.aas.installRoot"); 65 if (installRoot == null) { 66 installRoot = "."; 68 } 69 70 File f; 71 72 final String classpathPrefix = System.getProperty("com.sun.ant.classpath.prefix"); 73 if (classpathPrefix != null) { 74 f = new File (classpathPrefix); 75 loader.addURL(f); 76 } 77 78 final String derbyRoot = System.getProperty("derby.root"); 79 if (derbyRoot != null) { 80 f = new File (derbyRoot+"/lib/derby.jar"); 82 loader.addURL(f); 83 } 84 85 f = new File (installRoot+"/lib"); 86 loader.addURL(f); 87 f = new File (installRoot+"/lib/appserv-ws.jar"); 88 loader.addURL(f); 89 f = new File (installRoot+"/lib/appserv-se.jar"); 90 loader.addURL(f); 91 f = new File (installRoot+"/lib/appserv-admin.jar"); 92 loader.addURL(f); 93 f = new File (installRoot+"/lib/appserv-ext.jar"); 94 loader.addURL(f); 95 f = new File (installRoot+"/lib/appserv-rt.jar"); 96 loader.addURL(f); 97 f = new File (installRoot+"/lib/appserv-cmp.jar"); 98 loader.addURL(f); 99 f = new File (installRoot+"/lib/admin-cli.jar"); 100 loader.addURL(f); 101 f = new File (installRoot+"/lib/commons-launcher.jar"); 102 loader.addURL(f); 103 f = new File (installRoot+"/lib/javaee.jar"); 104 loader.addURL(f); 105 f = new File (installRoot+"/lib/install/applications/jmsra/imqjmsra.jar"); 106 loader.addURL(f); 107 }catch (Exception ex) { 108 ex.printStackTrace(); 109 } 111 return loader; 112 } 113 114 } 115 | Popular Tags |