1 package org.andromda.maven.plugin.configuration;
2
3 import java.net.URL;
4 import java.net.URLClassLoader;
5
6
7
8
9
10
11
12 public class ConfigurationClassLoader
13 extends URLClassLoader
14 {
15
16
17
18
19 public ConfigurationClassLoader(
20 final URL[] urls,
21 final ClassLoader parent)
22 {
23 super(urls, parent);
24 }
25
26
27
28
29 public Class loadClass(final String name)
30 throws ClassNotFoundException
31 {
32 return this.loadClass(
33 name,
34 false);
35 }
36
37
38
39
40 protected synchronized Class loadClass(
41 final String name,
42 final boolean resolve)
43 throws ClassNotFoundException
44 {
45
46 Class loadedClass = this.findLoadedClass(name);
47
48
49 if (loadedClass == null)
50 {
51 final ClassLoader parent = this.getParent();
52 if (parent != null)
53 {
54 try
55 {
56 loadedClass = parent.loadClass(name);
57 }
58 catch (final ClassNotFoundException exception)
59 {
60
61 }
62 }
63 else
64 {
65 loadedClass = getSystemClassLoader().loadClass(name);
66 }
67 }
68
69
70 if (loadedClass == null)
71 {
72 loadedClass = findClass(name);
73 }
74
75 if (resolve)
76 {
77 this.resolveClass(loadedClass);
78 }
79
80 return loadedClass;
81 }
82 }