Author: roku
Date: Tue Apr 26 12:08:14 2005
New Revision: 164861

URL: http://svn.apache.org/viewcvs?rev=164861&view=rev
Log:
Added support for an empty application context if the default config locations 
do not exist.

Modified:
    
cocoon/blocks/spring-app/trunk/java/org/apache/cocoon/spring/CocoonApplicationContext.java

Modified: 
cocoon/blocks/spring-app/trunk/java/org/apache/cocoon/spring/CocoonApplicationContext.java
URL: 
http://svn.apache.org/viewcvs/cocoon/blocks/spring-app/trunk/java/org/apache/cocoon/spring/CocoonApplicationContext.java?rev=164861&r1=164860&r2=164861&view=diff
==============================================================================
--- 
cocoon/blocks/spring-app/trunk/java/org/apache/cocoon/spring/CocoonApplicationContext.java
 (original)
+++ 
cocoon/blocks/spring-app/trunk/java/org/apache/cocoon/spring/CocoonApplicationContext.java
 Tue Apr 26 12:08:14 2005
@@ -15,12 +15,15 @@
  */
 package org.apache.cocoon.spring;
 
+import java.io.IOException;
 import java.net.MalformedURLException;
 
+import org.apache.avalon.framework.CascadingRuntimeException;
 import org.apache.cocoon.environment.internal.EnvironmentHelper;
 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;
 
 /**
@@ -73,9 +76,19 @@
     /**
      * The default location for the context is "conf/applicationContext.xml"
      * which is searched relative to the current sitemap.
+     * @return The default config locations if they exist otherwise an empty 
array.
      */
     protected String[] getDefaultConfigLocations() {
-        return new String[] {DEFAULT_SPRING_CONFIG};
+        try {
+            if(resolver.resolveURI(DEFAULT_SPRING_CONFIG).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);
+        }
+        
+        return new String[]{};
     }
-
 }


Reply via email to