This project has retired. For details please refer to its
        
        Attic page.
      
 
ClassUtil xref
1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  
17  package org.apache.juddi;
18  
19  import java.net.URL;
20  
21  
22  
23  
24  
25  public class ClassUtil {
26     
27  	public static Class<?> forName(String name, Class<?> caller)
28      	throws ClassNotFoundException
29      {
30  	    ClassLoader threadClassLoader = Thread.currentThread().getContextClassLoader();
31  	    if (threadClassLoader != null) {
32  	        try {
33  	            return Class.forName(name, true, threadClassLoader) ;
34  	        } catch (ClassNotFoundException cnfe) {
35  	        	if (cnfe.getException() != null) {
36  	        		throw cnfe;
37  	        	}
38  	        }
39  	    }
40      
41  	    ClassLoader callerClassLoader = caller.getClassLoader();
42  	    if (callerClassLoader != null) {
43  	        try {
44  	            return Class.forName(name, true, callerClassLoader) ;
45  	        } catch (final ClassNotFoundException cnfe) {
46  	            if (cnfe.getException() != null) {
47  	                throw cnfe ;
48  	            }
49  	        }
50  	    }
51  	    
52  	    return Class.forName(name, true, ClassLoader.getSystemClassLoader()) ;
53      }
54  	
55  	public static URL getResource(String name, Class<?> caller)
56  	{
57  		ClassLoader threadClassLoader = Thread.currentThread().getContextClassLoader();
58  		if (threadClassLoader != null) {
59  
60  			URL url = threadClassLoader.getResource(name);
61  
62  			if (url != null)
63  				return url;
64  
65  		}
66  
67  		ClassLoader callerClassLoader = caller.getClassLoader();
68  
69  		return callerClassLoader.getResource(name);
70  	}
71  }