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 2009/12/13 23:17:20 UTC

svn commit: r890131 [1/2] - in /cayenne/main/trunk: framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/ framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conn/ framework/cayenne-jdk1.5-unpublished/sr...

Author: aadamchik
Date: Sun Dec 13 22:17:19 2009
New Revision: 890131

URL: http://svn.apache.org/viewvc?rev=890131&view=rev
Log:
CAY-1329 DI-based cayenne-project module

* Dropping .driver.xml file, instead storing data source info in cayenne.xml under <data-source> tag
* Actually saving the project to XML

Added:
    cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/upgrade/
    cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/upgrade/DataSourceInfoLoader_3_0_0_1.java
      - copied, changed from r890067, cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/XMLPoolingDataSourceFactory.java
Removed:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/XMLPoolingDataSourceFactoryTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/org/apache/cayenne/configuration/testConfigNode3.driver.xml
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/org/apache/cayenne/configuration/testNode1.driver.xml
    cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSaveableGetter.java
    cayenne/main/trunk/framework/cayenne-project-unpublished/src/test/resources/org/apache/cayenne/project2/testProjectNode1.driver.xml
    cayenne/main/trunk/framework/cayenne-project-unpublished/src/test/resources/org/apache/cayenne/project2/testProjectNode2.driver.xml
    cayenne/main/trunk/itests/cayenne-di-stack/src/main/resources/PoolingDSNode.driver.xml
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/ConfigurationNodeVisitor.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DBCPDataSourceFactory.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DataChannelDescriptor.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DataNodeDescriptor.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DefaultConfigurationNameMapper.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DefaultDataSourceFactoryLoader.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/JNDIDataSourceFactory.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/SAXNestedTagHandler.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/XMLDataChannelDescriptorLoader.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/XMLPoolingDataSourceFactory.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conn/DataSourceInfo.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DataMap.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/runtime/DataDomainProvider.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/DBCPDataSourceFactoryTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/DefaultDataSourceFactoryLoaderTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/JNDIDataSourceFactoryTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/XMLDataChannelDescriptorLoaderTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/runtime/DataDomainProviderTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/org/apache/cayenne/configuration/cayenne-testConfig3.xml
    cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationLocationSetter.java
    cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationNodesGetter.java
    cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSaver.java
    cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSourceGetter.java
    cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSourceSetter.java
    cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/FileProjectSaver.java
    cayenne/main/trunk/framework/cayenne-project-unpublished/src/test/java/org/apache/cayenne/project2/DataChannelProjectSaverTest.java
    cayenne/main/trunk/framework/cayenne-project-unpublished/src/test/resources/org/apache/cayenne/project2/cayenne-PROJECT1.xml
    cayenne/main/trunk/framework/cayenne-project-unpublished/src/test/resources/org/apache/cayenne/project2/cayenne-PROJECT2.xml
    cayenne/main/trunk/itests/cayenne-di-stack/src/main/resources/cayenne-DEFAULT.xml

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/ConfigurationNodeVisitor.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/ConfigurationNodeVisitor.java?rev=890131&r1=890130&r2=890131&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/ConfigurationNodeVisitor.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/ConfigurationNodeVisitor.java Sun Dec 13 22:17:19 2009
@@ -30,7 +30,5 @@
 
     T visitDataChannelDescriptor(DataChannelDescriptor node);
 
-    T visitDataNodeDescriptor(DataNodeDescriptor node);
-
     T visitDataMap(DataMap node);
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DBCPDataSourceFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DBCPDataSourceFactory.java?rev=890131&r1=890130&r2=890131&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DBCPDataSourceFactory.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DBCPDataSourceFactory.java Sun Dec 13 22:17:19 2009
@@ -40,6 +40,8 @@
  */
 public class DBCPDataSourceFactory implements DataSourceFactory {
 
+    private static final String DBCP_PROPERTIES = "dbcp.properties";
+
     private static final Log logger = LogFactory.getLog(DBCPDataSourceFactory.class);
 
     @Inject
@@ -47,7 +49,16 @@
 
     public DataSource getDataSource(DataNodeDescriptor nodeDescriptor) throws Exception {
 
-        Resource dbcpConfiguration = nodeDescriptor.getConfigurationSource();
+        String location = nodeDescriptor.getParameters();
+        if (location == null) {
+            logger.debug("No explicit DBCP config location, will use default location: "
+                    + DBCP_PROPERTIES);
+            location = DBCP_PROPERTIES;
+        }
+
+        DataChannelDescriptor parent = nodeDescriptor.getParent();
+        Resource dbcpConfiguration = parent.getConfigurationSource().getRelativeResource(
+                location);
         if (dbcpConfiguration == null) {
             throw new CayenneRuntimeException(
                     "Null 'configurationResource' for nodeDescriptor '%s'",

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DataChannelDescriptor.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DataChannelDescriptor.java?rev=890131&r1=890130&r2=890131&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DataChannelDescriptor.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DataChannelDescriptor.java Sun Dec 13 22:17:19 2009
@@ -25,13 +25,15 @@
 
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.resource.Resource;
+import org.apache.cayenne.util.XMLEncoder;
+import org.apache.cayenne.util.XMLSerializable;
 
 /**
  * A descriptor of a DataChannel normally loaded from XML configuration.
  * 
  * @since 3.1
  */
-public class DataChannelDescriptor implements ConfigurationNode {
+public class DataChannelDescriptor implements ConfigurationNode, XMLSerializable {
 
     protected String name;
     protected String version;
@@ -45,7 +47,10 @@
         dataMaps = new ArrayList<DataMap>(5);
         dataNodeDescriptors = new ArrayList<DataNodeDescriptor>(3);
     }
-    
+
+    public void encodeAsXML(XMLEncoder encoder) {
+    }
+
     public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor) {
         return visitor.visitDataChannelDescriptor(this);
     }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DataNodeDescriptor.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DataNodeDescriptor.java?rev=890131&r1=890130&r2=890131&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DataNodeDescriptor.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DataNodeDescriptor.java Sun Dec 13 22:17:19 2009
@@ -22,31 +22,38 @@
 import java.util.Collection;
 
 import org.apache.cayenne.access.DataNode;
-import org.apache.cayenne.resource.Resource;
+import org.apache.cayenne.conn.DataSourceInfo;
+import org.apache.cayenne.util.XMLEncoder;
+import org.apache.cayenne.util.XMLSerializable;
 
 /**
- * A descriptor of a {@link DataNode}, normally loaded from XML.
+ * A descriptor of a {@link DataNode}.
  * 
  * @since 3.1
  */
-public class DataNodeDescriptor implements ConfigurationNode {
+public class DataNodeDescriptor implements XMLSerializable {
 
+    protected DataChannelDescriptor parent;
     protected String name;
     protected Collection<String> dataMapNames;
 
-    protected String location;
+    protected String parameters;
     protected String adapterType;
     protected String dataSourceFactoryType;
     protected String schemaUpdateStrategyType;
-
-    protected Resource configurationSource;
+    protected DataSourceInfo dataSourceDescriptor;
 
     public DataNodeDescriptor() {
-        dataMapNames = new ArrayList<String>();
+        this(null);
+    }
+
+    public DataNodeDescriptor(DataChannelDescriptor parent) {
+        this.parent = parent;
+        this.dataMapNames = new ArrayList<String>();
     }
 
-    public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor) {
-        return visitor.visitDataNodeDescriptor(this);
+    public void encodeAsXML(XMLEncoder encoder) {
+        throw new UnsupportedOperationException("TODO");
     }
 
     public String getName() {
@@ -61,12 +68,22 @@
         return dataMapNames;
     }
 
-    public String getLocation() {
-        return location;
-    }
-
-    public void setLocation(String location) {
-        this.location = location;
+    /**
+     * Returns extra DataNodeDescriptor parameters. This property is often used by custom
+     * {@link DataSourceFactory} to configure a DataSource. E.g. JNDIDataSoirceFactory may
+     * treat parameters String as a JNDI location of the DataSource, etc.
+     */
+    public String getParameters() {
+        return parameters;
+    }
+
+    /**
+     * Sets extra DataNodeDescriptor parameters. This property is often used by custom
+     * {@link DataSourceFactory} to configure a DataSource. E.g. JNDIDataSoirceFactory may
+     * treat parameters String as a JNDI location of the DataSource, etc.
+     */
+    public void setParameters(String location) {
+        this.parameters = location;
     }
 
     public String getAdapterType() {
@@ -85,14 +102,6 @@
         this.dataSourceFactoryType = dataSourceFactory;
     }
 
-    public Resource getConfigurationSource() {
-        return configurationSource;
-    }
-
-    public void setConfigurationSource(Resource descriptorResource) {
-        this.configurationSource = descriptorResource;
-    }
-
     public String getSchemaUpdateStrategyType() {
         return schemaUpdateStrategyType;
     }
@@ -100,4 +109,20 @@
     public void setSchemaUpdateStrategyType(String schemaUpdateStrategyClass) {
         this.schemaUpdateStrategyType = schemaUpdateStrategyClass;
     }
+
+    public DataSourceInfo getDataSourceDescriptor() {
+        return dataSourceDescriptor;
+    }
+
+    public void setDataSourceDescriptor(DataSourceInfo dataSourceDescriptor) {
+        this.dataSourceDescriptor = dataSourceDescriptor;
+    }
+
+    public DataChannelDescriptor getParent() {
+        return parent;
+    }
+
+    public void setParent(DataChannelDescriptor parent) {
+        this.parent = parent;
+    }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DefaultConfigurationNameMapper.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DefaultConfigurationNameMapper.java?rev=890131&r1=890130&r2=890131&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DefaultConfigurationNameMapper.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DefaultConfigurationNameMapper.java Sun Dec 13 22:17:19 2009
@@ -30,7 +30,6 @@
     private static final String CAYENNE_SUFFIX = ".xml";
 
     private static final String DATA_MAP_SUFFIX = ".map.xml";
-    private static final String DATA_NODE_SUFFIX = ".driver.xml";
 
     protected ConfigurationNodeVisitor<String> nameMapper;
 
@@ -42,22 +41,23 @@
         return node.acceptVisitor(nameMapper);
     }
 
-    public String configurationLocation(Class<? extends ConfigurationNode> type, String name) {
+    public String configurationLocation(
+            Class<? extends ConfigurationNode> type,
+            String name) {
         if (DataChannelDescriptor.class.isAssignableFrom(type)) {
             return getDataChannelName(name);
         }
         else if (DataMap.class.isAssignableFrom(type)) {
             return getDataMapName(name);
         }
-        else if (DataNodeDescriptor.class.isAssignableFrom(type)) {
-            return getDataNodeName(name);
-        }
 
         throw new IllegalArgumentException("Unrecognized configuration type: "
                 + type.getName());
     }
 
-    public String configurationNodeName(Class<? extends ConfigurationNode> type, Resource resource) {
+    public String configurationNodeName(
+            Class<? extends ConfigurationNode> type,
+            Resource resource) {
 
         String path = resource.getURL().getPath();
         if (path == null || path.length() == 0) {
@@ -89,12 +89,6 @@
             }
             return path.substring(0, path.length() - DATA_MAP_SUFFIX.length());
         }
-        else if (DataNodeDescriptor.class.isAssignableFrom(type)) {
-            if (!path.endsWith(DATA_NODE_SUFFIX)) {
-                return null;
-            }
-            return path.substring(0, path.length() - DATA_NODE_SUFFIX.length());
-        }
 
         throw new IllegalArgumentException("Unrecognized configuration type: "
                 + type.getName());
@@ -116,14 +110,6 @@
         return name + DATA_MAP_SUFFIX;
     }
 
-    protected String getDataNodeName(String name) {
-        if (name == null) {
-            throw new NullPointerException("Null DataNode name");
-        }
-
-        return name + DATA_NODE_SUFFIX;
-    }
-
     final class NameMapper implements ConfigurationNodeVisitor<String> {
 
         public String visitDataChannelDescriptor(DataChannelDescriptor descriptor) {
@@ -133,9 +119,5 @@
         public String visitDataMap(DataMap dataMap) {
             return getDataMapName(dataMap.getName());
         }
-
-        public String visitDataNodeDescriptor(DataNodeDescriptor descriptor) {
-            return getDataNodeName(descriptor.getName());
-        }
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DefaultDataSourceFactoryLoader.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DefaultDataSourceFactoryLoader.java?rev=890131&r1=890130&r2=890131&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DefaultDataSourceFactoryLoader.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DefaultDataSourceFactoryLoader.java Sun Dec 13 22:17:19 2009
@@ -24,8 +24,8 @@
 /**
  * A {@link DataSourceFactoryLoader} that loads factories explicitly configured in the
  * {@link DataNodeDescriptor}. If the factory class is not explicitly configured, and the
- * descriptor has a configuration resource attached to it, {@link XMLPoolingDataSourceFactory}
- * is returned.
+ * descriptor has a configuration resource attached to it,
+ * {@link XMLPoolingDataSourceFactory} is returned.
  * 
  * @since 3.1
  */
@@ -38,14 +38,14 @@
         String typeName = nodeDescriptor.getDataSourceFactoryType();
 
         if (typeName == null) {
-            if (nodeDescriptor.getConfigurationSource() != null) {
+            if (nodeDescriptor.getDataSourceDescriptor() != null) {
                 return objectFactory.newInstance(
                         DataSourceFactory.class,
                         XMLPoolingDataSourceFactory.class.getName());
             }
             else {
                 throw new CayenneRuntimeException(
-                        "DataNodeDescriptor '%s' has no explicit DataSourceFactoryType set and has no configuration resource",
+                        "DataNodeDescriptor '%s' has null 'dataSourceFactoryType' and 'dataSourceDescriptor' properties",
                         nodeDescriptor.getName());
             }
         }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/JNDIDataSourceFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/JNDIDataSourceFactory.java?rev=890131&r1=890130&r2=890131&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/JNDIDataSourceFactory.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/JNDIDataSourceFactory.java Sun Dec 13 22:17:19 2009
@@ -39,7 +39,7 @@
 
     public DataSource getDataSource(DataNodeDescriptor nodeDescriptor) throws Exception {
 
-        String location = nodeDescriptor.getLocation();
+        String location = nodeDescriptor.getParameters();
         if (location == null) {
             throw new CayenneRuntimeException(
                     "Null 'location' for nodeDescriptor '%s'",

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/SAXNestedTagHandler.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/SAXNestedTagHandler.java?rev=890131&r1=890130&r2=890131&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/SAXNestedTagHandler.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/SAXNestedTagHandler.java Sun Dec 13 22:17:19 2009
@@ -34,7 +34,7 @@
  * 
  * @since 3.1
  */
-class SAXNestedTagHandler extends DefaultHandler {
+public class SAXNestedTagHandler extends DefaultHandler {
 
     private final static Locator NOOP_LOCATOR = new Locator() {
 
@@ -59,7 +59,7 @@
     protected ContentHandler parentHandler;
     protected Locator locator;
 
-    SAXNestedTagHandler(XMLReader parser, SAXNestedTagHandler parentHandler) {
+    public SAXNestedTagHandler(XMLReader parser, SAXNestedTagHandler parentHandler) {
         this.parentHandler = parentHandler;
         this.parser = parser;
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/XMLDataChannelDescriptorLoader.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/XMLDataChannelDescriptorLoader.java?rev=890131&r1=890130&r2=890131&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/XMLDataChannelDescriptorLoader.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/XMLDataChannelDescriptorLoader.java Sun Dec 13 22:17:19 2009
@@ -18,13 +18,18 @@
  ****************************************************************/
 package org.apache.cayenne.configuration;
 
+import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.cayenne.ConfigurationException;
+import org.apache.cayenne.conf.PasswordEncoding;
+import org.apache.cayenne.conn.DataSourceInfo;
 import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.resource.Resource;
@@ -48,6 +53,7 @@
     static final String NODE_TAG = "node";
     static final String PROPERTY_TAG = "property";
     static final String MAP_REF_TAG = "map-ref";
+    static final String DATA_SOURCE_TAG = "data-source";
 
     private static final Map<String, String> dataSourceFactoryLegacyNameMapping;
 
@@ -64,6 +70,63 @@
                 DBCPDataSourceFactory.class.getName());
     }
 
+    /**
+     * @deprecated the caller should use password resolving strategy instead of resolving
+     *             the password on the spot. For one thing this can be used in the Modeler
+     *             and no password may be available.
+     */
+    private static String passwordFromURL(URL url) {
+        InputStream inputStream = null;
+        String password = null;
+
+        try {
+            inputStream = url.openStream();
+            password = passwordFromInputStream(inputStream);
+        }
+        catch (IOException exception) {
+            // Log the error while trying to open the stream. A null
+            // password will be returned as a result.
+            logger.warn(exception);
+        }
+
+        return password;
+    }
+
+    /**
+     * @deprecated the caller should use password resolving strategy instead of resolving
+     *             the password on the spot. For one thing this can be used in the Modeler
+     *             and no password may be available.
+     */
+    private static String passwordFromInputStream(InputStream inputStream) {
+        BufferedReader bufferedReader = null;
+        String password = null;
+
+        try {
+            bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
+            password = bufferedReader.readLine();
+        }
+        catch (IOException exception) {
+            logger.warn(exception);
+        }
+        finally {
+            try {
+                if (bufferedReader != null) {
+                    bufferedReader.close();
+                }
+            }
+            catch (Exception exception) {
+            }
+
+            try {
+                inputStream.close();
+            }
+            catch (IOException exception) {
+            }
+        }
+
+        return password;
+    }
+
     @Inject
     protected DataMapLoader dataMapLoader;
 
@@ -189,10 +252,11 @@
             else if (localName.equals(MAP_TAG)) {
 
                 String dataMapName = attributes.getValue("", "name");
-                String dataMapLocation = attributes.getValue("", "location");
-
                 Resource baseResource = descriptor.getConfigurationSource();
 
+                String dataMapLocation = nameMapper.configurationLocation(
+                        DataMap.class,
+                        dataMapName);
                 Resource dataMapResource = baseResource
                         .getRelativeResource(dataMapLocation);
 
@@ -210,14 +274,14 @@
                     throw new ConfigurationException("Error: <node> without 'name'.");
                 }
 
-                DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor();
+                DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor(descriptor);
                 descriptor.getDataNodeDescriptors().add(nodeDescriptor);
 
                 nodeDescriptor.setName(nodeName);
                 nodeDescriptor.setAdapterType(attributes.getValue("", "adapter"));
 
-                String location = attributes.getValue("", "datasource");
-                nodeDescriptor.setLocation(location);
+                String parameters = attributes.getValue("", "parameters");
+                nodeDescriptor.setParameters(parameters);
 
                 String dataSourceFactory = attributes.getValue("", "factory");
                 nodeDescriptor
@@ -226,14 +290,6 @@
                         "",
                         "schema-update-strategy"));
 
-                // this may be bogus for some nodes, such as JNDI, but here we can't
-                // tell for sure
-                if (location != null) {
-                    nodeDescriptor.setConfigurationSource(descriptor
-                            .getConfigurationSource()
-                            .getRelativeResource(location));
-                }
-
                 return new DataNodeChildrenHandler(parser, this, nodeDescriptor);
             }
 
@@ -263,6 +319,157 @@
                 String mapName = attributes.getValue("", "name");
                 nodeDescriptor.getDataMapNames().add(mapName);
             }
+            else if (localName.equals(DATA_SOURCE_TAG)) {
+
+                DataSourceInfo dataSourceDescriptor = new DataSourceInfo();
+                nodeDescriptor.setDataSourceDescriptor(dataSourceDescriptor);
+                return new DataSourceChildrenHandler(parser, this, dataSourceDescriptor);
+            }
+
+            return super.createChildTagHandler(namespaceURI, localName, name, attributes);
+        }
+    }
+
+    class DataSourceChildrenHandler extends SAXNestedTagHandler {
+
+        private DataSourceInfo dataSourceDescriptor;
+
+        DataSourceChildrenHandler(XMLReader parser,
+                DataNodeChildrenHandler parentHandler, DataSourceInfo dataSourceDescriptor) {
+            super(parser, parentHandler);
+            this.dataSourceDescriptor = dataSourceDescriptor;
+        }
+
+        @Override
+        protected ContentHandler createChildTagHandler(
+                String namespaceURI,
+                String localName,
+                String name,
+                Attributes attributes) {
+
+            if (localName.equals("driver")) {
+                String className = attributes.getValue("", "value");
+                dataSourceDescriptor.setJdbcDriver(className);
+            }
+            else if (localName.equals("login")) {
+
+                logger.info("loading user name and password.");
+
+                String encoderClass = attributes.getValue("encoderClass");
+
+                String encoderKey = attributes.getValue("encoderKey");
+                if (encoderKey == null) {
+                    encoderKey = attributes.getValue("encoderSalt");
+                }
+
+                String password = attributes.getValue("password");
+                String passwordLocation = attributes.getValue("passwordLocation");
+                String passwordSource = attributes.getValue("passwordSource");
+                if (passwordSource == null) {
+                    passwordSource = DataSourceInfo.PASSWORD_LOCATION_MODEL;
+                }
+
+                String username = attributes.getValue("userName");
+
+                dataSourceDescriptor.setPasswordEncoderClass(encoderClass);
+                dataSourceDescriptor.setPasswordEncoderKey(encoderKey);
+                dataSourceDescriptor.setPasswordLocation(passwordLocation);
+                dataSourceDescriptor.setPasswordSource(passwordSource);
+                dataSourceDescriptor.setUserName(username);
+
+                // Replace {} in passwordSource with encoderSalt -- useful for EXECUTABLE
+                // & URL options
+                if (encoderKey != null) {
+                    passwordSource = passwordSource.replaceAll("\\{\\}", encoderKey);
+                }
+
+                PasswordEncoding passwordEncoder = dataSourceDescriptor
+                        .getPasswordEncoder();
+
+                if (passwordLocation != null) {
+                    if (passwordLocation
+                            .equals(DataSourceInfo.PASSWORD_LOCATION_CLASSPATH)) {
+
+                        ClassLoader classLoader = Thread
+                                .currentThread()
+                                .getContextClassLoader();
+                        URL url = classLoader.getResource(username);
+                        if (url != null) {
+                            password = passwordFromURL(url);
+                        }
+                        else {
+                            logger.error("Could not find resource in CLASSPATH: "
+                                    + passwordSource);
+                        }
+                    }
+                    else if (passwordLocation
+                            .equals(DataSourceInfo.PASSWORD_LOCATION_URL)) {
+                        try {
+                            password = passwordFromURL(new URL(passwordSource));
+                        }
+                        catch (MalformedURLException exception) {
+                            logger.warn(exception);
+                        }
+                    }
+                    else if (passwordLocation
+                            .equals(DataSourceInfo.PASSWORD_LOCATION_EXECUTABLE)) {
+                        if (passwordSource != null) {
+                            try {
+                                Process process = Runtime.getRuntime().exec(
+                                        passwordSource);
+                                password = passwordFromInputStream(process
+                                        .getInputStream());
+                                process.waitFor();
+                            }
+                            catch (IOException exception) {
+                                logger.warn(exception);
+                            }
+                            catch (InterruptedException exception) {
+                                logger.warn(exception);
+                            }
+                        }
+                    }
+                }
+
+                if (password != null && passwordEncoder != null) {
+                    dataSourceDescriptor.setPassword(passwordEncoder.decodePassword(
+                            password,
+                            encoderKey));
+                }
+            }
+            else if (localName.equals("url")) {
+                dataSourceDescriptor.setDataSourceUrl(attributes.getValue("value"));
+            }
+            else if (localName.equals("connectionPool")) {
+                String min = attributes.getValue("min");
+                if (min != null) {
+                    try {
+                        dataSourceDescriptor.setMinConnections(Integer.parseInt(min));
+                    }
+                    catch (NumberFormatException nfex) {
+                        logger.info("Non-numeric 'min' attribute", nfex);
+                        throw new ConfigurationException(
+                                "Non-numeric 'min' attribute '%s'",
+                                nfex,
+                                min);
+                    }
+                }
+
+                String max = attributes.getValue("max");
+                if (max != null) {
+                    try {
+                        dataSourceDescriptor.setMaxConnections(Integer.parseInt(max));
+                    }
+                    catch (NumberFormatException nfex) {
+                        logger.info("Non-numeric 'max' attribute", nfex);
+                        throw new ConfigurationException(
+                                "Non-numeric 'max' attribute '%s'",
+                                nfex,
+                                max);
+                    }
+                }
+            }
+
             return super.createChildTagHandler(namespaceURI, localName, name, attributes);
         }
     }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/XMLPoolingDataSourceFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/XMLPoolingDataSourceFactory.java?rev=890131&r1=890130&r2=890131&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/XMLPoolingDataSourceFactory.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/XMLPoolingDataSourceFactory.java Sun Dec 13 22:17:19 2009
@@ -18,32 +18,17 @@
  ****************************************************************/
 package org.apache.cayenne.configuration;
 
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Collection;
-
 import javax.sql.DataSource;
 
 import org.apache.cayenne.ConfigurationException;
 import org.apache.cayenne.access.ConnectionLogger;
 import org.apache.cayenne.access.QueryLogger;
-import org.apache.cayenne.conf.PasswordEncoding;
 import org.apache.cayenne.conn.DataSourceInfo;
 import org.apache.cayenne.conn.PoolManager;
 import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.resource.Resource;
 import org.apache.cayenne.resource.ResourceLocator;
-import org.apache.cayenne.util.Util;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.XMLReader;
 
 /**
  * A {@link DataSourceFactory} that loads JDBC connection information from an XML resource
@@ -62,38 +47,16 @@
 
     public DataSource getDataSource(DataNodeDescriptor nodeDescriptor) throws Exception {
 
-        logger.info("loading driver information from '"
-                + nodeDescriptor.getLocation()
-                + "'.");
-
-        Resource resource = nodeDescriptor.getConfigurationSource();
+        DataSourceInfo dataSourceDescriptor = nodeDescriptor.getDataSourceDescriptor();
 
-        if (resource == null) {
-            String message = "Null configuration resource for node descriptor with location '"
-                    + nodeDescriptor.getLocation()
+        if (dataSourceDescriptor == null) {
+            String message = "Null dataSourceDescriptor for nodeDescriptor '"
+                    + nodeDescriptor.getName()
                     + "'";
             logger.info(message);
             throw new ConfigurationException(message);
         }
 
-        DataSourceInfo dataSourceDescriptor = new DataSourceInfo();
-
-        XMLReader parser = Util.createXmlReader();
-
-        DriverHandler handler = new DriverHandler(dataSourceDescriptor, parser);
-        parser.setContentHandler(handler);
-        parser.setErrorHandler(handler);
-        parser.parse(new InputSource(resource.getURL().openStream()));
-
-        return createDataSource(dataSourceDescriptor);
-    }
-
-    /**
-     * Returns an instance of {@link PoolManager}.
-     */
-    protected DataSource createDataSource(DataSourceInfo dataSourceDescriptor)
-            throws Exception {
-
         ConnectionLogger logger = new ConnectionLogger();
         try {
             return new PoolManager(
@@ -110,214 +73,4 @@
             throw e;
         }
     }
-
-    private static String passwordFromURL(URL url) {
-        InputStream inputStream = null;
-        String password = null;
-
-        try {
-            inputStream = url.openStream();
-            password = passwordFromInputStream(inputStream);
-        }
-        catch (IOException exception) {
-            // Log the error while trying to open the stream. A null
-            // password will be returned as a result.
-            logger.warn(exception);
-        }
-
-        return password;
-    }
-
-    private static String passwordFromInputStream(InputStream inputStream) {
-        BufferedReader bufferedReader = null;
-        String password = null;
-
-        try {
-            bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
-            password = bufferedReader.readLine();
-        }
-        catch (IOException exception) {
-            logger.warn(exception);
-        }
-        finally {
-            try {
-                if (bufferedReader != null) {
-                    bufferedReader.close();
-                }
-            }
-            catch (Exception exception) {
-            }
-
-            try {
-                inputStream.close();
-            }
-            catch (IOException exception) {
-            }
-        }
-
-        return password;
-    }
-
-    private class DriverHandler extends SAXNestedTagHandler {
-
-        private DataSourceInfo dataSourceDescriptor;
-
-        DriverHandler(DataSourceInfo dataSourceDescriptor, XMLReader parser) {
-            super(parser, null);
-            this.dataSourceDescriptor = dataSourceDescriptor;
-        }
-
-        @Override
-        protected ContentHandler createChildTagHandler(
-                String namespaceURI,
-                String localName,
-                String name,
-                Attributes attributes) {
-
-            if (localName.equals("driver")) {
-                String className = attributes.getValue("", "class");
-                logger.info("loading driver " + className);
-                dataSourceDescriptor.setJdbcDriver(className);
-                return new DriverChildrenHandler(parser, this);
-            }
-
-            return super.createChildTagHandler(namespaceURI, localName, name, attributes);
-        }
-    }
-
-    private class DriverChildrenHandler extends SAXNestedTagHandler {
-
-        private DataSourceInfo dataSourceDescriptor;
-
-        DriverChildrenHandler(XMLReader parser, DriverHandler parentHandler) {
-            super(parser, parentHandler);
-            this.dataSourceDescriptor = parentHandler.dataSourceDescriptor;
-        }
-
-        @Override
-        protected ContentHandler createChildTagHandler(
-                String namespaceURI,
-                String localName,
-                String name,
-                Attributes attributes) {
-
-            if (localName.equals("login")) {
-
-                logger.info("loading user name and password.");
-
-                String encoderClass = attributes.getValue("encoderClass");
-
-                String encoderKey = attributes.getValue("encoderKey");
-                if (encoderKey == null) {
-                    encoderKey = attributes.getValue("encoderSalt");
-                }
-
-                String password = attributes.getValue("password");
-                String passwordLocation = attributes.getValue("passwordLocation");
-                String passwordSource = attributes.getValue("passwordSource");
-                if (passwordSource == null) {
-                    passwordSource = DataSourceInfo.PASSWORD_LOCATION_MODEL;
-                }
-
-                String username = attributes.getValue("userName");
-
-                dataSourceDescriptor.setPasswordEncoderClass(encoderClass);
-                dataSourceDescriptor.setPasswordEncoderKey(encoderKey);
-                dataSourceDescriptor.setPasswordLocation(passwordLocation);
-                dataSourceDescriptor.setPasswordSource(passwordSource);
-                dataSourceDescriptor.setUserName(username);
-
-                // Replace {} in passwordSource with encoderSalt -- useful for EXECUTABLE
-                // & URL options
-                if (encoderKey != null) {
-                    passwordSource = passwordSource.replaceAll("\\{\\}", encoderKey);
-                }
-
-                PasswordEncoding passwordEncoder = dataSourceDescriptor
-                        .getPasswordEncoder();
-
-                if (passwordLocation != null) {
-                    if (passwordLocation
-                            .equals(DataSourceInfo.PASSWORD_LOCATION_CLASSPATH)) {
-                        Collection<Resource> urls = resourceLocator
-                                .findResources(passwordLocation);
-                        if (urls.size() > 0) {
-                            password = passwordFromURL(urls.iterator().next().getURL());
-                        }
-                        else {
-                            logger.error("Could not find resource in CLASSPATH: "
-                                    + passwordSource);
-                        }
-                    }
-                    else if (passwordLocation
-                            .equals(DataSourceInfo.PASSWORD_LOCATION_URL)) {
-                        try {
-                            password = passwordFromURL(new URL(passwordSource));
-                        }
-                        catch (MalformedURLException exception) {
-                            logger.warn(exception);
-                        }
-                    }
-                    else if (passwordLocation
-                            .equals(DataSourceInfo.PASSWORD_LOCATION_EXECUTABLE)) {
-                        if (passwordSource != null) {
-                            try {
-                                Process process = Runtime.getRuntime().exec(
-                                        passwordSource);
-                                password = passwordFromInputStream(process
-                                        .getInputStream());
-                                process.waitFor();
-                            }
-                            catch (IOException exception) {
-                                logger.warn(exception);
-                            }
-                            catch (InterruptedException exception) {
-                                logger.warn(exception);
-                            }
-                        }
-                    }
-                }
-
-                if (password != null && passwordEncoder != null) {
-                    dataSourceDescriptor.setPassword(passwordEncoder.decodePassword(
-                            password,
-                            encoderKey));
-                }
-            }
-            else if (localName.equals("url")) {
-                dataSourceDescriptor.setDataSourceUrl(attributes.getValue("value"));
-            }
-            else if (localName.equals("connectionPool")) {
-                String min = attributes.getValue("min");
-                if (min != null) {
-                    try {
-                        dataSourceDescriptor.setMinConnections(Integer.parseInt(min));
-                    }
-                    catch (NumberFormatException nfex) {
-                        logger.info("Non-numeric 'min' attribute", nfex);
-                        throw new ConfigurationException(
-                                "Non-numeric 'min' attribute '%s'",
-                                nfex,
-                                min);
-                    }
-                }
-
-                String max = attributes.getValue("max");
-                if (max != null) {
-                    try {
-                        dataSourceDescriptor.setMaxConnections(Integer.parseInt(max));
-                    }
-                    catch (NumberFormatException nfex) {
-                        logger.info("Non-numeric 'max' attribute", nfex);
-                        throw new ConfigurationException(
-                                "Non-numeric 'max' attribute '%s'",
-                                nfex,
-                                max);
-                    }
-                }
-            }
-
-            return super.createChildTagHandler(namespaceURI, localName, name, attributes);
-        }
-    }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conn/DataSourceInfo.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conn/DataSourceInfo.java?rev=890131&r1=890130&r2=890131&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conn/DataSourceInfo.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conn/DataSourceInfo.java Sun Dec 13 22:17:19 2009
@@ -29,7 +29,6 @@
 
 /**
  * Helper JavaBean class that holds DataSource login information.
- * 
  */
 public class DataSourceInfo implements Cloneable, Serializable {
 
@@ -110,39 +109,6 @@
         }
     }
 
-    @Override
-    public String toString() {
-        StringBuilder buf = new StringBuilder();
-        buf.append("[").append(this.getClass().getName()).append(":").append(
-                "\n   user name: ").append(userName).append("\n   password: ");
-
-        buf.append("**********");
-        buf
-                .append("\n   driver: ")
-                .append(jdbcDriver)
-                .append("\n   db adapter class: ")
-                .append(adapterClassName)
-                .append("\n   url: ")
-                .append(dataSourceUrl)
-                .append("\n   min. connections: ")
-                .append(minConnections)
-                .append("\n   max. connections: ")
-                .append(maxConnections);
-
-        if (!PlainTextPasswordEncoder.class.getName().equals(passwordEncoderClass)) {
-            buf.append("\n   encoder class: ").append(passwordEncoderClass).append(
-                    "\n   encoder key: ").append(passwordEncoderKey);
-        }
-
-        if (!PASSWORD_LOCATION_MODEL.equals(passwordLocation)) {
-            buf.append("\n   password location: ").append(passwordLocation).append(
-                    "\n   password source: ").append(getPasswordSource());
-        }
-
-        buf.append("\n]");
-        return buf.toString();
-    }
-
     public String getAdapterClassName() {
         return adapterClassName;
     }
@@ -201,8 +167,9 @@
 
     public PasswordEncoding getPasswordEncoder() {
         try {
-            return (PasswordEncoding)
-                Util.getJavaClass(getPasswordEncoderClass()).newInstance();
+            return (PasswordEncoding) Util
+                    .getJavaClass(getPasswordEncoderClass())
+                    .newInstance();
         }
         catch (InstantiationException e) {
             ; // Swallow it -- no need to throw/etc.
@@ -214,8 +181,9 @@
             ; // Swallow it -- no need to throw/etc.
         }
 
-        logger.error("Failed to obtain specified Password Encoder '" +
-                     getPasswordEncoderClass() + "' -- please check CLASSPATH");
+        logger.error("Failed to obtain specified Password Encoder '"
+                + getPasswordEncoderClass()
+                + "' -- please check CLASSPATH");
 
         return null;
     }
@@ -339,4 +307,37 @@
         else
             this.passwordLocation = passwordLocation;
     }
+
+    @Override
+    public String toString() {
+        StringBuilder buf = new StringBuilder();
+        buf.append("[").append(this.getClass().getName()).append(":").append(
+                "\n   user name: ").append(userName).append("\n   password: ");
+
+        buf.append("**********");
+        buf
+                .append("\n   driver: ")
+                .append(jdbcDriver)
+                .append("\n   db adapter class: ")
+                .append(adapterClassName)
+                .append("\n   url: ")
+                .append(dataSourceUrl)
+                .append("\n   min. connections: ")
+                .append(minConnections)
+                .append("\n   max. connections: ")
+                .append(maxConnections);
+
+        if (!PlainTextPasswordEncoder.class.getName().equals(passwordEncoderClass)) {
+            buf.append("\n   encoder class: ").append(passwordEncoderClass).append(
+                    "\n   encoder key: ").append(passwordEncoderKey);
+        }
+
+        if (!PASSWORD_LOCATION_MODEL.equals(passwordLocation)) {
+            buf.append("\n   password location: ").append(passwordLocation).append(
+                    "\n   password source: ").append(getPasswordSource());
+        }
+
+        buf.append("\n]");
+        return buf.toString();
+    }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DataMap.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DataMap.java?rev=890131&r1=890130&r2=890131&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DataMap.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DataMap.java Sun Dec 13 22:17:19 2009
@@ -133,13 +133,12 @@
     private SortedMap<String, SQLResult> results;
 
     private List<EntityListener> defaultEntityListeners;
-    
+
     /**
      * @since 3.1
      */
     protected Resource configurationSource;
 
-
     /**
      * Creates a new unnamed DataMap.
      */
@@ -165,7 +164,7 @@
         setName(mapName);
         initWithProperties(properties);
     }
-    
+
     /**
      * @since 3.1
      */
@@ -267,6 +266,8 @@
      * document.
      * 
      * @since 1.1
+     * @deprecated since 3.1, as {@link XMLSerializable} objects should only save XML
+     *             segments. Saving full XML files is responsibilty of the callers.
      */
     public void encodeAsXML(PrintWriter pw) {
         XMLEncoder encoder = new XMLEncoder(pw, "\t");

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/runtime/DataDomainProvider.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/runtime/DataDomainProvider.java?rev=890131&r1=890130&r2=890131&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/runtime/DataDomainProvider.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/runtime/DataDomainProvider.java Sun Dec 13 22:17:19 2009
@@ -156,7 +156,7 @@
         for (DataNodeDescriptor nodeDescriptor : descriptor.getDataNodeDescriptors()) {
             DataNode dataNode = new DataNode(nodeDescriptor.getName());
 
-            dataNode.setDataSourceLocation(nodeDescriptor.getLocation());
+            dataNode.setDataSourceLocation(nodeDescriptor.getParameters());
 
             DataSourceFactory dataSourceFactory = dataSourceFactoryLoader
                     .getDataSourceFactory(nodeDescriptor);

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/DBCPDataSourceFactoryTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/DBCPDataSourceFactoryTest.java?rev=890131&r1=890130&r2=890131&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/DBCPDataSourceFactoryTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/DBCPDataSourceFactoryTest.java Sun Dec 13 22:17:19 2009
@@ -33,12 +33,14 @@
     public void testGetDataSource() throws Exception {
 
         String baseUrl = getClass().getPackage().getName().replace('.', '/');
-        URL url = getClass().getClassLoader().getResource(
-                baseUrl + "/testDBCP.properties");
+        URL url = getClass().getClassLoader().getResource(baseUrl + "/");
         assertNotNull(url);
 
-        DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor();
-        nodeDescriptor.setConfigurationSource(new URLResource(url));
+        DataChannelDescriptor channelDescriptor = new DataChannelDescriptor();
+        channelDescriptor.setConfigurationSource(new URLResource(url));
+
+        DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor(channelDescriptor);
+        nodeDescriptor.setParameters("testDBCP.properties");
 
         DBCPDataSourceFactory factory = new DBCPDataSourceFactory();
         DataSource dataSource = factory.getDataSource(nodeDescriptor);
@@ -56,16 +58,18 @@
         assertEquals(10000, basicDataSource.getMaxWait());
         assertEquals("select 1 from xyz;", basicDataSource.getValidationQuery());
     }
-    
+
     public void testGetDataSource_LegacyConfig() throws Exception {
 
         String baseUrl = getClass().getPackage().getName().replace('.', '/');
-        URL url = getClass().getClassLoader().getResource(
-                baseUrl + "/testDBCP_legacy.properties");
+        URL url = getClass().getClassLoader().getResource(baseUrl + "/");
         assertNotNull(url);
 
-        DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor();
-        nodeDescriptor.setConfigurationSource(new URLResource(url));
+        DataChannelDescriptor channelDescriptor = new DataChannelDescriptor();
+        channelDescriptor.setConfigurationSource(new URLResource(url));
+
+        DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor(channelDescriptor);
+        nodeDescriptor.setParameters("testDBCP_legacy.properties");
 
         DBCPDataSourceFactory factory = new DBCPDataSourceFactory();
         DataSource dataSource = factory.getDataSource(nodeDescriptor);
@@ -87,13 +91,14 @@
     public void testGetDataSource_InvalidLocation() throws Exception {
 
         String baseUrl = getClass().getPackage().getName().replace('.', '/');
-        URL url = getClass().getClassLoader().getResource(
-                baseUrl + "/testDBCP.properties");
+        URL url = getClass().getClassLoader().getResource(baseUrl + "/");
         assertNotNull(url);
-        url = new URL(url, ".nosuchfile");
 
-        DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor();
-        nodeDescriptor.setConfigurationSource(new URLResource(url));
+        DataChannelDescriptor channelDescriptor = new DataChannelDescriptor();
+        channelDescriptor.setConfigurationSource(new URLResource(url));
+
+        DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor(channelDescriptor);
+        nodeDescriptor.setParameters("testDBCP.properties.nosuchfile");
 
         DBCPDataSourceFactory factory = new DBCPDataSourceFactory();
 
@@ -104,7 +109,6 @@
         catch (IOException ex) {
             // expected
         }
-
     }
 
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/DefaultDataSourceFactoryLoaderTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/DefaultDataSourceFactoryLoaderTest.java?rev=890131&r1=890130&r2=890131&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/DefaultDataSourceFactoryLoaderTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/DefaultDataSourceFactoryLoaderTest.java Sun Dec 13 22:17:19 2009
@@ -18,30 +18,24 @@
  ****************************************************************/
 package org.apache.cayenne.configuration;
 
-import java.net.URL;
-
 import junit.framework.TestCase;
 
 import org.apache.cayenne.configuration.mock.MockDataSourceFactory1;
+import org.apache.cayenne.conn.DataSourceInfo;
 import org.apache.cayenne.di.Binder;
 import org.apache.cayenne.di.DIBootstrap;
 import org.apache.cayenne.di.Injector;
 import org.apache.cayenne.di.Module;
 import org.apache.cayenne.resource.ResourceLocator;
-import org.apache.cayenne.resource.URLResource;
 import org.apache.cayenne.resource.mock.MockResourceLocator;
 
 public class DefaultDataSourceFactoryLoaderTest extends TestCase {
 
     public void testGetDataSourceFactory_Implicit() throws Exception {
-        String baseUrl = getClass().getPackage().getName().replace('.', '/');
-        URL url = getClass().getClassLoader().getResource(
-                baseUrl + "/testNode1.driver.xml");
-        assertNotNull(url);
 
         DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor();
         nodeDescriptor.setName("node1");
-        nodeDescriptor.setConfigurationSource(new URLResource(url));
+        nodeDescriptor.setDataSourceDescriptor(new DataSourceInfo());
 
         Module testModule = new Module() {
 
@@ -62,14 +56,9 @@
     }
 
     public void testGetDataSourceFactory_Explicit() throws Exception {
-        String baseUrl = getClass().getPackage().getName().replace('.', '/');
-        URL url = getClass().getClassLoader().getResource(
-                baseUrl + "/testNode1.driver.xml");
-        assertNotNull(url);
 
         DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor();
         nodeDescriptor.setName("node1");
-        nodeDescriptor.setConfigurationSource(new URLResource(url));
         nodeDescriptor.setDataSourceFactoryType(MockDataSourceFactory1.class.getName());
 
         Module testModule = new Module() {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/JNDIDataSourceFactoryTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/JNDIDataSourceFactoryTest.java?rev=890131&r1=890130&r2=890131&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/JNDIDataSourceFactoryTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/JNDIDataSourceFactoryTest.java Sun Dec 13 22:17:19 2009
@@ -32,13 +32,13 @@
     public void testGetDataSource_NameBound() throws Exception {
 
         DataNodeDescriptor descriptor = new DataNodeDescriptor();
-        descriptor.setLocation("jdbc/TestDS");
+        descriptor.setParameters("jdbc/TestDS");
 
         JNDISetup.doSetup();
 
         MockDataSource dataSource = new MockDataSource();
         InitialContext context = new InitialContext();
-        context.bind(descriptor.getLocation(), dataSource);
+        context.bind(descriptor.getParameters(), dataSource);
 
         try {
 
@@ -47,20 +47,20 @@
         }
         finally {
             // since the context is shared, must clear it after the test
-            context.unbind(descriptor.getLocation());
+            context.unbind(descriptor.getParameters());
         }
     }
 
     public void testGetDataSource_NameBoundWithPrefix() throws Exception {
 
         DataNodeDescriptor descriptor = new DataNodeDescriptor();
-        descriptor.setLocation("jdbc/TestDS");
+        descriptor.setParameters("jdbc/TestDS");
 
         JNDISetup.doSetup();
 
         MockDataSource dataSource = new MockDataSource();
         InitialContext context = new InitialContext();
-        context.bind("java:comp/env/" + descriptor.getLocation(), dataSource);
+        context.bind("java:comp/env/" + descriptor.getParameters(), dataSource);
 
         try {
 
@@ -69,14 +69,14 @@
         }
         finally {
             // since the context is shared, must clear it after the test
-            context.unbind("java:comp/env/" + descriptor.getLocation());
+            context.unbind("java:comp/env/" + descriptor.getParameters());
         }
     }
 
     public void testGetDataSource_NameNotBound() throws Exception {
 
         DataNodeDescriptor descriptor = new DataNodeDescriptor();
-        descriptor.setLocation("jdbc/TestDS");
+        descriptor.setParameters("jdbc/TestDS");
 
         JNDISetup.doSetup();
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/XMLDataChannelDescriptorLoaderTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/XMLDataChannelDescriptorLoaderTest.java?rev=890131&r1=890130&r2=890131&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/XMLDataChannelDescriptorLoaderTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/XMLDataChannelDescriptorLoaderTest.java Sun Dec 13 22:17:19 2009
@@ -42,7 +42,8 @@
 
             public void configure(Binder binder) {
                 binder.bind(DataMapLoader.class).to(XMLDataMapLoader.class);
-                binder.bind(ConfigurationNameMapper.class).to(DefaultConfigurationNameMapper.class);
+                binder.bind(ConfigurationNameMapper.class).to(
+                        DefaultConfigurationNameMapper.class);
             }
         };
 
@@ -70,7 +71,8 @@
 
             public void configure(Binder binder) {
                 binder.bind(DataMapLoader.class).to(XMLDataMapLoader.class);
-                binder.bind(ConfigurationNameMapper.class).to(DefaultConfigurationNameMapper.class);
+                binder.bind(ConfigurationNameMapper.class).to(
+                        DefaultConfigurationNameMapper.class);
             }
         };
 
@@ -97,7 +99,8 @@
 
             public void configure(Binder binder) {
                 binder.bind(DataMapLoader.class).to(XMLDataMapLoader.class);
-                binder.bind(ConfigurationNameMapper.class).to(DefaultConfigurationNameMapper.class);
+                binder.bind(ConfigurationNameMapper.class).to(
+                        DefaultConfigurationNameMapper.class);
             }
         };
 
@@ -131,7 +134,8 @@
 
             public void configure(Binder binder) {
                 binder.bind(DataMapLoader.class).to(XMLDataMapLoader.class);
-                binder.bind(ConfigurationNameMapper.class).to(DefaultConfigurationNameMapper.class);
+                binder.bind(ConfigurationNameMapper.class).to(
+                        DefaultConfigurationNameMapper.class);
             }
         };
 
@@ -169,12 +173,10 @@
 
         DataNodeDescriptor node1 = nodes.iterator().next();
         assertEquals("testConfigNode3", node1.getName());
-        assertEquals("testConfigNode3.driver.xml", node1.getLocation());
-        assertNotNull(node1.getConfigurationSource());
-        assertEquals(descriptor.getConfigurationSource().getRelativeResource(
-                "testConfigNode3.driver.xml").getURL(), node1
-                .getConfigurationSource()
-                .getURL());
+        assertNull(node1.getParameters());
+        assertNotNull(node1.getDataSourceDescriptor());
+        assertEquals(1, node1.getDataSourceDescriptor().getMinConnections());
+        assertEquals(1, node1.getDataSourceDescriptor().getMaxConnections());
 
         assertEquals("org.example.test.Adapter", node1.getAdapterType());
         assertEquals("org.example.test.DataSourceFactory", node1

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/runtime/DataDomainProviderTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/runtime/DataDomainProviderTest.java?rev=890131&r1=890130&r2=890131&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/runtime/DataDomainProviderTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/runtime/DataDomainProviderTest.java Sun Dec 13 22:17:19 2009
@@ -76,7 +76,7 @@
         nodeDescriptor1.getDataMapNames().add("map1");
         nodeDescriptor1.setAdapterType(OracleAdapter.class.getName());
         nodeDescriptor1.setDataSourceFactoryType(MockDataSourceFactory.class.getName());
-        nodeDescriptor1.setLocation("jdbc/testDataNode1");
+        nodeDescriptor1.setParameters("jdbc/testDataNode1");
         nodeDescriptor1
                 .setSchemaUpdateStrategyType(ThrowOnPartialOrCreateSchemaStrategy.class
                         .getName());
@@ -85,7 +85,7 @@
         DataNodeDescriptor nodeDescriptor2 = new DataNodeDescriptor();
         nodeDescriptor2.setName("node2");
         nodeDescriptor2.getDataMapNames().add("map2");
-        nodeDescriptor2.setLocation("testDataNode2.driver.xml");
+        nodeDescriptor2.setParameters("testDataNode2.driver.xml");
         testDescriptor.getDataNodeDescriptors().add(nodeDescriptor2);
 
         final ResourceLocator locator = new ResourceLocator() {
@@ -169,7 +169,7 @@
         assertEquals(nodeDescriptor1.getDataSourceFactoryType(), node1
                 .getDataSourceFactory());
         assertNotNull(node1.getDataSource());
-        assertEquals(nodeDescriptor1.getLocation(), node1.getDataSourceLocation());
+        assertEquals(nodeDescriptor1.getParameters(), node1.getDataSourceLocation());
 
         assertEquals(nodeDescriptor1.getSchemaUpdateStrategyType(), node1
                 .getSchemaUpdateStrategyName());
@@ -189,7 +189,7 @@
         assertSame(node2, domain.lookupDataNode(map2));
         assertNull(node2.getDataSourceFactory());
         assertNotNull(node2.getDataSource());
-        assertEquals(nodeDescriptor2.getLocation(), node2.getDataSourceLocation());
+        assertEquals(nodeDescriptor2.getParameters(), node2.getDataSourceLocation());
         assertEquals(SkipSchemaUpdateStrategy.class.getName(), node2
                 .getSchemaUpdateStrategyName());
         assertNotNull(node2.getSchemaUpdateStrategy());

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/org/apache/cayenne/configuration/cayenne-testConfig3.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/org/apache/cayenne/configuration/cayenne-testConfig3.xml?rev=890131&r1=890130&r2=890131&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/org/apache/cayenne/configuration/cayenne-testConfig3.xml (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/org/apache/cayenne/configuration/cayenne-testConfig3.xml Sun Dec 13 22:17:19 2009
@@ -3,9 +3,12 @@
 	<map name="testConfigMap3_1" location="testConfigMap3_1.map.xml" />
 	<map name="testConfigMap3_2" location="testConfigMap3_2.map.xml" />
 
-	<node name="testConfigNode3" datasource="testConfigNode3.driver.xml"
-		adapter="org.example.test.Adapter" factory="org.example.test.DataSourceFactory"
-		schema-update-strategy="org.example.test.SchemaUpdateStartegy">
+	<node name="testConfigNode3" adapter="org.example.test.Adapter"
+		factory="org.example.test.DataSourceFactory" schema-update-strategy="org.example.test.SchemaUpdateStartegy">
 		<map-ref name="testConfigMap3_2" />
+		<data-source>
+			<connectionPool min="1" max="1" />
+			<login />
+		</data-source>
 	</node>
 </domain>

Modified: cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationLocationSetter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationLocationSetter.java?rev=890131&r1=890130&r2=890131&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationLocationSetter.java (original)
+++ cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationLocationSetter.java Sun Dec 13 22:17:19 2009
@@ -20,7 +20,6 @@
 
 import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
 import org.apache.cayenne.configuration.DataChannelDescriptor;
-import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.map.DataMap;
 
 /**
@@ -45,9 +44,4 @@
         node.setLocation(location);
         return null;
     }
-
-    public Void visitDataNodeDescriptor(DataNodeDescriptor node) {
-        node.setLocation(location);
-        return null;
-    }
 }

Modified: cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationNodesGetter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationNodesGetter.java?rev=890131&r1=890130&r2=890131&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationNodesGetter.java (original)
+++ cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationNodesGetter.java Sun Dec 13 22:17:19 2009
@@ -25,7 +25,6 @@
 import org.apache.cayenne.configuration.ConfigurationNode;
 import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
 import org.apache.cayenne.configuration.DataChannelDescriptor;
-import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.map.DataMap;
 
 /**
@@ -44,18 +43,10 @@
             nodes.add(map);
         }
 
-        for (DataNodeDescriptor node : descriptor.getDataNodeDescriptors()) {
-            nodes.add(node);
-        }
         return nodes;
     }
 
     public Collection<ConfigurationNode> visitDataMap(DataMap dataMap) {
         return Collections.<ConfigurationNode> singletonList(dataMap);
     }
-
-    public Collection<ConfigurationNode> visitDataNodeDescriptor(
-            DataNodeDescriptor descriptor) {
-        return Collections.<ConfigurationNode> singletonList(descriptor);
-    }
 }

Modified: cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSaver.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSaver.java?rev=890131&r1=890130&r2=890131&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSaver.java (original)
+++ cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSaver.java Sun Dec 13 22:17:19 2009
@@ -22,8 +22,8 @@
 
 import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
 import org.apache.cayenne.configuration.DataChannelDescriptor;
-import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.util.XMLEncoder;
 
 /**
  * @since 3.1
@@ -37,14 +37,16 @@
     }
 
     public Void visitDataChannelDescriptor(DataChannelDescriptor node) {
+        XMLEncoder encoder = new XMLEncoder(printWriter, "\t");
+        encoder.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
+        node.encodeAsXML(encoder);
         return null;
     }
 
     public Void visitDataMap(DataMap node) {
-        return null;
-    }
-
-    public Void visitDataNodeDescriptor(DataNodeDescriptor node) {
+        XMLEncoder encoder = new XMLEncoder(printWriter, "\t");
+        encoder.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
+        node.encodeAsXML(encoder);
         return null;
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSourceGetter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSourceGetter.java?rev=890131&r1=890130&r2=890131&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSourceGetter.java (original)
+++ cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSourceGetter.java Sun Dec 13 22:17:19 2009
@@ -20,7 +20,6 @@
 
 import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
 import org.apache.cayenne.configuration.DataChannelDescriptor;
-import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.resource.Resource;
 
@@ -38,8 +37,4 @@
     public Resource visitDataMap(DataMap dataMap) {
         return dataMap.getConfigurationSource();
     }
-
-    public Resource visitDataNodeDescriptor(DataNodeDescriptor descriptor) {
-        return descriptor.getConfigurationSource();
-    }
 }

Modified: cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSourceSetter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSourceSetter.java?rev=890131&r1=890130&r2=890131&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSourceSetter.java (original)
+++ cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSourceSetter.java Sun Dec 13 22:17:19 2009
@@ -20,7 +20,6 @@
 
 import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
 import org.apache.cayenne.configuration.DataChannelDescriptor;
-import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.resource.Resource;
 
@@ -44,9 +43,4 @@
         node.setConfigurationSource(configurationSource);
         return null;
     }
-
-    public Void visitDataNodeDescriptor(DataNodeDescriptor node) {
-        node.setConfigurationSource(configurationSource);
-        return null;
-    }
 }

Modified: cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/FileProjectSaver.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/FileProjectSaver.java?rev=890131&r1=890130&r2=890131&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/FileProjectSaver.java (original)
+++ cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/FileProjectSaver.java Sun Dec 13 22:17:19 2009
@@ -51,13 +51,11 @@
 
     protected ConfigurationNodeVisitor<Resource> resourceGetter;
     protected ConfigurationNodeVisitor<Collection<ConfigurationNode>> nodesGetter;
-    protected ConfigurationNodeVisitor<Boolean> saveableGetter;
     protected String fileEncoding;
 
     public FileProjectSaver() {
         resourceGetter = new ConfigurationSourceGetter();
         nodesGetter = new ConfigurationNodesGetter();
-        saveableGetter = new ConfigurationSaveableGetter();
         fileEncoding = "UTF-8";
     }
 
@@ -114,12 +112,6 @@
         unit.node = node;
         unit.sourceConfiguration = node.acceptVisitor(resourceGetter);
 
-        // some configuration nodes don't require their own files to be saved, so check
-        // for that first; still return such units as we may need to delete the old files.
-        if (!node.acceptVisitor(saveableGetter)) {
-            return unit;
-        }
-
         if (baseResource == null) {
             baseResource = unit.sourceConfiguration;
         }
@@ -161,9 +153,6 @@
         for (SaveUnit unit : units) {
 
             File targetFile = unit.targetFile;
-            if (targetFile == null) {
-                continue;
-            }
 
             File parent = targetFile.getParentFile();
             if (!parent.exists()) {
@@ -192,17 +181,12 @@
 
         for (SaveUnit unit : units) {
 
-            File targetFile = unit.targetFile;
-            if (targetFile == null) {
-                continue;
-            }
-
-            String name = targetFile.getName();
+            String name = unit.targetFile.getName();
             if (name == null || name.length() < 3) {
                 name = "cayenne-project";
             }
 
-            File parent = targetFile.getParentFile();
+            File parent = unit.targetFile.getParentFile();
 
             try {
                 unit.targetTempFile = File.createTempFile(name, null, parent);
@@ -255,9 +239,6 @@
         for (SaveUnit unit : units) {
 
             File targetFile = unit.targetFile;
-            if (targetFile == null) {
-                continue;
-            }
 
             if (targetFile.exists()) {
                 if (!targetFile.delete()) {