|
1 | 1 | /* |
2 | | - * Copyright 2002-2015 the original author or authors. |
| 2 | + * Copyright 2002-2016 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
@@ -91,6 +91,8 @@ public class GenericApplicationContext extends AbstractApplicationContext implem |
91 | 91 |
|
92 | 92 | private ResourceLoader resourceLoader; |
93 | 93 |
|
| 94 | + private boolean customClassLoader = false; |
| 95 | + |
94 | 96 | private final AtomicBoolean refreshed = new AtomicBoolean(); |
95 | 97 |
|
96 | 98 |
|
@@ -198,6 +200,10 @@ public void setResourceLoader(ResourceLoader resourceLoader) { |
198 | 200 | } |
199 | 201 |
|
200 | 202 |
|
| 203 | + //--------------------------------------------------------------------- |
| 204 | + // ResourceLoader / ResourcePatternResolver override if necessary |
| 205 | + //--------------------------------------------------------------------- |
| 206 | + |
201 | 207 | /** |
202 | 208 | * This implementation delegates to this context's ResourceLoader if set, |
203 | 209 | * falling back to the default superclass behavior else. |
@@ -225,6 +231,20 @@ public Resource[] getResources(String locationPattern) throws IOException { |
225 | 231 | return super.getResources(locationPattern); |
226 | 232 | } |
227 | 233 |
|
| 234 | + @Override |
| 235 | + public void setClassLoader(ClassLoader classLoader) { |
| 236 | + super.setClassLoader(classLoader); |
| 237 | + this.customClassLoader = true; |
| 238 | + } |
| 239 | + |
| 240 | + @Override |
| 241 | + public ClassLoader getClassLoader() { |
| 242 | + if (this.resourceLoader != null && !this.customClassLoader) { |
| 243 | + return this.resourceLoader.getClassLoader(); |
| 244 | + } |
| 245 | + return super.getClassLoader(); |
| 246 | + } |
| 247 | + |
228 | 248 |
|
229 | 249 | //--------------------------------------------------------------------- |
230 | 250 | // Implementations of AbstractApplicationContext's template methods |
|
0 commit comments