/[Apache-SVN]/cocoon/blocks/spring-app/trunk/java/org/apache/cocoon/spring/CocoonApplicationContext.java
ViewVC logotype

Diff of /cocoon/blocks/spring-app/trunk/java/org/apache/cocoon/spring/CocoonApplicationContext.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- cocoon/blocks/spring-app/trunk/java/org/apache/cocoon/spring/CocoonApplicationContext.java	2005/05/04 05:30:01	168073
+++ cocoon/blocks/spring-app/trunk/java/org/apache/cocoon/spring/CocoonApplicationContext.java	2005/05/04 05:36:19	168074
@@ -20,10 +20,10 @@ import java.net.MalformedURLException;
 
 import org.apache.avalon.framework.CascadingRuntimeException;
 import org.apache.cocoon.environment.internal.EnvironmentHelper;
+import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceResolver;
 import org.springframework.core.io.Resource;
 import org.springframework.core.io.UrlResource;
-import org.springframework.web.context.support.ServletContextResource;
 import org.springframework.web.context.support.XmlWebApplicationContext;
 
 /**
@@ -38,7 +38,6 @@ public class CocoonApplicationContext
     public static final String DEFAULT_SPRING_CONFIG = "conf/applicationContext.xml";
 
     protected SourceResolver resolver;
-    protected EnvironmentHelper environmentHelper;
     protected String baseURL;
 
     public void setSourceResolver(SourceResolver aResolver) {
@@ -46,8 +45,7 @@ public class CocoonApplicationContext
     }
 
     public void setEnvironmentHelper(EnvironmentHelper eh) {
-        this.environmentHelper = eh;
-        this.baseURL = this.environmentHelper.getContext();
+        this.baseURL = eh.getContext();
         if ( !this.baseURL.endsWith("/") ) {
             this.baseURL = this.baseURL + '/';
         }
@@ -79,14 +77,18 @@ public class CocoonApplicationContext
      * @return The default config locations if they exist otherwise an empty array.
      */
     protected String[] getDefaultConfigLocations() {
+        Source testSource = null;
         try {
-            if(resolver.resolveURI(DEFAULT_SPRING_CONFIG).exists()) {
+            testSource = this.resolver.resolveURI(DEFAULT_SPRING_CONFIG);
+            if (testSource.exists()) {
                 return new String[] {DEFAULT_SPRING_CONFIG};
             }
         } catch(MalformedURLException e) {
             throw new CascadingRuntimeException("Malformed URL when resolving Spring default config location [ " + DEFAULT_SPRING_CONFIG + "]. This is an unrecoverable programming error. Check the code where this exception was thrown.", e);
         } catch(IOException e) {
             throw new CascadingRuntimeException("Cannot resolve default config location ["+ DEFAULT_SPRING_CONFIG + "] due to an IOException. See cause for details.", e);
+        } finally {
+            this.resolver.release(testSource);
         }
         
         return new String[]{};

 

infrastructure at apache.org
ViewVC Help
Powered by ViewVC 1.1.26