|
|
|
@ -1,11 +1,11 @@
|
|
|
|
|
/* |
|
|
|
|
* Copyright 2012 Decebal Suiu |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with |
|
|
|
|
* the License. You may obtain a copy of the License in the LICENSE file, or at: |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
|
|
|
|
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
|
|
|
|
* specific language governing permissions and limitations under the License. |
|
|
|
@ -23,7 +23,7 @@ import java.util.Set;
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* A class loader that has multiple loaders and uses them for loading classes and resources. |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* @author Decebal Suiu |
|
|
|
|
*/ |
|
|
|
|
public class CompoundClassLoader extends ClassLoader { |
|
|
|
@ -34,6 +34,10 @@ public class CompoundClassLoader extends ClassLoader {
|
|
|
|
|
loaders.add(loader); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void removeLoader(ClassLoader loader) { |
|
|
|
|
loaders.remove(loader); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Class<?> findClass(String name) throws ClassNotFoundException { |
|
|
|
|
for (ClassLoader loader : loaders) { |
|
|
|
@ -43,7 +47,7 @@ public class CompoundClassLoader extends ClassLoader {
|
|
|
|
|
// try next
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
throw new ClassNotFoundException(name); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -55,7 +59,7 @@ public class CompoundClassLoader extends ClassLoader {
|
|
|
|
|
return url; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -65,8 +69,8 @@ public class CompoundClassLoader extends ClassLoader {
|
|
|
|
|
for (ClassLoader loader : loaders) { |
|
|
|
|
resources.addAll(Collections.list(loader.getResources(name))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Collections.enumeration(resources); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|