cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r662223 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne: conf/ project/
Date Sun, 01 Jun 2008 14:38:40 GMT
Author: aadamchik
Date: Sun Jun  1 07:38:40 2008
New Revision: 662223

URL: http://svn.apache.org/viewvc?rev=662223&view=rev
Log:
CAY-943 Support multiple cayenne.xml files in the project
(switching to ResourceFinder)

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/DBCPDataSourceFactory.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/DBCPDataSourceProperties.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/DefaultConfiguration.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/DriverDataSourceFactory.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/FileConfiguration.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/ServletUtil.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/project/ProjectConfiguration.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/DBCPDataSourceFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/DBCPDataSourceFactory.java?rev=662223&r1=662222&r2=662223&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/DBCPDataSourceFactory.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/DBCPDataSourceFactory.java
Sun Jun  1 07:38:40 2008
@@ -65,21 +65,22 @@
      */
     public DataSource getDataSource(String location) throws Exception {
 
-        ResourceLocator resourceLocator;
+        ResourceFinder resourceFinder;
 
         if (parentConfiguration != null) {
-            resourceLocator = parentConfiguration.getResourceLocator();
+            resourceFinder = parentConfiguration.getResourceFinder();
         }
         else {
-            resourceLocator = new ResourceLocator();
+            ResourceLocator resourceLocator = new ResourceLocator();
             resourceLocator.setSkipAbsolutePath(false);
             resourceLocator.setSkipHomeDirectory(true);
             resourceLocator.setSkipClasspath(false);
             resourceLocator.setSkipCurrentDirectory(false);
+            resourceFinder = resourceLocator;
         }
 
         DBCPDataSourceProperties properties = new DBCPDataSourceProperties(
-                resourceLocator,
+                resourceFinder,
                 location);
 
         if (logger.isDebugEnabled()) {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/DBCPDataSourceProperties.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/DBCPDataSourceProperties.java?rev=662223&r1=662222&r2=662223&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/DBCPDataSourceProperties.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/DBCPDataSourceProperties.java
Sun Jun  1 07:38:40 2008
@@ -20,11 +20,11 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.URL;
 import java.sql.Connection;
 import java.util.Properties;
 
 import org.apache.cayenne.ConfigurationException;
-import org.apache.cayenne.util.ResourceLocator;
 import org.apache.commons.pool.impl.GenericObjectPool;
 
 /**
@@ -42,22 +42,23 @@
     /**
      * Loads properties from the specified location.
      */
-    static Properties loadProperties(ResourceLocator resourceLocator, String location)
+    static Properties loadProperties(ResourceFinder resourceLocator, String location)
             throws IOException {
 
-        InputStream in = resourceLocator.findResourceStream(location);
+        URL url = resourceLocator.getResource(location);
 
         // try appending ".properties" extension..
-        if (in == null && !location.endsWith(".properties")) {
-            in = resourceLocator.findResourceStream(location + ".properties");
+        if (url == null && !location.endsWith(".properties")) {
+            url = resourceLocator.getResource(location + ".properties");
         }
 
-        if (in == null) {
+        if (url == null) {
             throw new ConfigurationException("DBCP properties file not found: "
                     + location);
         }
 
         Properties properties = new Properties();
+        InputStream in = url.openStream();
         try {
             properties.load(in);
         }
@@ -72,7 +73,7 @@
         return properties;
     }
 
-    DBCPDataSourceProperties(ResourceLocator resourceLocator, String location)
+    DBCPDataSourceProperties(ResourceFinder resourceLocator, String location)
             throws IOException {
         this(loadProperties(resourceLocator, location));
     }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/DefaultConfiguration.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/DefaultConfiguration.java?rev=662223&r1=662222&r2=662223&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/DefaultConfiguration.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/DefaultConfiguration.java
Sun Jun  1 07:38:40 2008
@@ -36,10 +36,7 @@
 
     private static Log logger = LogFactory.getLog(DefaultConfiguration.class);
 
-    /**
-     * the default ResourceLocator used for CLASSPATH loading
-     */
-    private ResourceLocator locator;
+    protected ResourceLocator locator;
 
     /**
      * Default constructor. Simply calls
@@ -105,7 +102,7 @@
      * </pre>
      */
     public void addClassPath(String customPath) {
-        this.getResourceLocator().addClassPath(customPath);
+        locator.addClassPath(customPath);
     }
 
     /**
@@ -118,7 +115,7 @@
      * @since 1.2 moved from subclass - FileConfiguration.
      */
     public void addResourcePath(String path) {
-        this.getResourceLocator().addFilesystemPath(path);
+        locator.addFilesystemPath(path);
     }
 
     @Override

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/DriverDataSourceFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/DriverDataSourceFactory.java?rev=662223&r1=662222&r2=662223&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/DriverDataSourceFactory.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/DriverDataSourceFactory.java
Sun Jun  1 07:38:40 2008
@@ -104,7 +104,14 @@
                     "No parent Configuration set - cannot continue.");
         }
 
-        return this.parentConfiguration.getResourceLocator().findResourceStream(location);
+        URL url = parentConfiguration.getResourceFinder().getResource(location);
+
+        try {
+            return url != null ? url.openStream() : null;
+        }
+        catch (IOException e) {
+            throw new ConfigurationException("Error reading URL " + url, e);
+        }
     }
 
     /**
@@ -327,8 +334,7 @@
             // locations
             {
                 if (passwordLocation.equals(DataSourceInfo.PASSWORD_LOCATION_CLASSPATH))
{
-                    URL url = parentConfiguration.getResourceLocator().findResource(
-                            passwordSource);
+                    URL url = parentConfiguration.getResourceFinder().getResource(passwordLocation);
 
                     if (url != null)
                         password = passwordFromURL(url);

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/FileConfiguration.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/FileConfiguration.java?rev=662223&r1=662222&r2=662223&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/FileConfiguration.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/FileConfiguration.java
Sun Jun  1 07:38:40 2008
@@ -22,7 +22,6 @@
 import java.io.File;
 
 import org.apache.cayenne.ConfigurationException;
-import org.apache.cayenne.util.ResourceLocator;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -67,7 +66,6 @@
         this.projectFile = new File(domainConfigurationName);
 
         // configure the ResourceLocator for plain files
-        ResourceLocator locator = this.getResourceLocator();
         locator.setSkipAbsolutePath(false);
         locator.setSkipClasspath(true);
         locator.setSkipCurrentDirectory(false);
@@ -93,10 +91,9 @@
         logger.debug("using domain file: " + domainConfigurationFile);
 
         // set the project file
-        this.setProjectFile(domainConfigurationFile);
+        setProjectFile(domainConfigurationFile);
 
         // configure the ResourceLocator for plain files
-        ResourceLocator locator = this.getResourceLocator();
         locator.setSkipAbsolutePath(false);
         locator.setSkipClasspath(true);
         locator.setSkipCurrentDirectory(false);
@@ -127,7 +124,7 @@
      * @throws IllegalArgumentException if <code>path</code> is <code>null</code>.
      */
     public void addFilesystemPath(String path) {
-        this.getResourceLocator().addFilesystemPath(path);
+        locator.addFilesystemPath(path);
     }
 
     /**
@@ -138,7 +135,7 @@
      *             not a directory or not readable.
      */
     public void addFilesystemPath(File path) {
-        this.getResourceLocator().addFilesystemPath(path);
+        locator.addFilesystemPath(path);
     }
 
     /**

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/ServletUtil.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/ServletUtil.java?rev=662223&r1=662222&r2=662223&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/ServletUtil.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/ServletUtil.java
Sun Jun  1 07:38:40 2008
@@ -69,7 +69,7 @@
         Configuration oldConfig = Configuration.sharedConfiguration;
         if (oldConfig instanceof DefaultConfiguration) {
 
-            ResourceLocator locator = oldConfig.getResourceLocator();
+            ResourceFinder locator = oldConfig.getResourceFinder();
 
             if (locator instanceof WebApplicationResourceLocator) {
                 if (((WebApplicationResourceLocator) locator).getServletContext() == context)
{

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/project/ProjectConfiguration.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/project/ProjectConfiguration.java?rev=662223&r1=662222&r2=662223&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/project/ProjectConfiguration.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/project/ProjectConfiguration.java
Sun Jun  1 07:38:40 2008
@@ -25,7 +25,6 @@
 import org.apache.cayenne.conf.DataSourceFactory;
 import org.apache.cayenne.conf.DriverDataSourceFactory;
 import org.apache.cayenne.conf.FileConfiguration;
-import org.apache.cayenne.util.ResourceLocator;
 
 /**
  * Subclass of FileConfiguration used in the project model.
@@ -47,7 +46,6 @@
         this.setIgnoringLoadFailures(true);
 
         // configure deterministic file opening rules
-        ResourceLocator locator = this.getResourceLocator();
         locator.setSkipAbsolutePath(false);
         locator.setSkipClasspath(true);
         locator.setSkipCurrentDirectory(true);



Mime
View raw message