X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.slc.core%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fspring%2FSpringUtils.java;h=798b5648e28e1f35bfe6433866f17f0ba8384e3a;hb=7a8f034133c1112e187e2a2bfd2c56a8d2452345;hp=e31dbcc59670f1e3ab6e503c34ca67acf71b4bca;hpb=aaa6551ed00ba292b33a19183058c5e8ec97ef64;p=gpl%2Fargeo-slc.git diff --git a/org.argeo.slc.core/src/main/java/org/argeo/slc/spring/SpringUtils.java b/org.argeo.slc.core/src/main/java/org/argeo/slc/spring/SpringUtils.java index e31dbcc59..798b5648e 100644 --- a/org.argeo.slc.core/src/main/java/org/argeo/slc/spring/SpringUtils.java +++ b/org.argeo.slc.core/src/main/java/org/argeo/slc/spring/SpringUtils.java @@ -2,13 +2,11 @@ package org.argeo.slc.spring; import java.io.IOException; import java.net.URI; -import java.net.URL; import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.argeo.slc.core.SlcException; -import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.beans.factory.ListableBeanFactory; import org.springframework.core.io.DefaultResourceLoader; @@ -21,9 +19,16 @@ public class SpringUtils { Class clss) { // Map beans = context.getBeansOfType(clss); Map beans = BeanFactoryUtils.beansOfTypeIncludingAncestors( - context, clss); + context, clss, false, false); if (beans.size() == 1) { return beans.values().iterator().next(); + } else if (beans.size() > 1) { + if (log.isDebugEnabled()) { + log + .debug(("Found more that on bean for type " + clss + + ": " + beans.keySet())); + } + return null; } else { return null; } @@ -50,9 +55,9 @@ public class SpringUtils { public static String extractRelativePath(Resource ancestor, Resource child) { try { - return ancestor.getURI().relativize(child.getURI()).normalize() - .toString(); - } catch (IOException e) { + return ancestor.getURL().toURI().relativize(child.getURL().toURI()) + .normalize().toString(); + } catch (Exception e) { throw new SlcException("Cannot extract relative path of " + child + " based on " + ancestor, e); }