You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2008/06/01 15:18:56 UTC

svn commit: r662211 - /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/util/ResourceLocator.java

Author: aadamchik
Date: Sun Jun  1 06:18:56 2008
New Revision: 662211

URL: http://svn.apache.org/viewvc?rev=662211&view=rev
Log:
CAY-1061 ResourceFinder: abstract API for looking up resources, including multiple resources for a given name
(ResourceLocator implements ResourceFinder)

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/util/ResourceLocator.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/util/ResourceLocator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/util/ResourceLocator.java?rev=662211&r1=662210&r2=662211&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/util/ResourceLocator.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/util/ResourceLocator.java Sun Jun  1 06:18:56 2008
@@ -26,8 +26,11 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
 
+import org.apache.cayenne.conf.ResourceFinder;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -36,7 +39,7 @@
  * 
  * @author Andrus Adamchik
  */
-public class ResourceLocator {
+public class ResourceLocator implements ResourceFinder {
 
     private static Log logObj = LogFactory.getLog(ResourceLocator.class);
 
@@ -268,6 +271,22 @@
     }
 
     /**
+     * @since 3.0
+     */
+    public URL getResource(String name) {
+        return findResource(name);
+    }
+
+    /**
+     * @since 3.0
+     */
+    public Collection<URL> getResources(String name) {
+        URL resource = getResource(name);
+        return resource != null ? Collections.<URL> singleton(resource) : Collections
+                .<URL> emptySet();
+    }
+
+    /**
      * Returns a resource URL using the lookup strategy configured for this
      * Resourcelocator or <code>null</code> if no readable resource can be found for the
      * given name.