cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r890150 - in /cayenne/main/trunk/framework: cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/ cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/ cayenne-jdk1.5-unpublished/src/main/java/org/apache/cay...
Date Mon, 14 Dec 2009 00:27:09 GMT
Author: aadamchik
Date: Mon Dec 14 00:27:08 2009
New Revision: 890150

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

* cleanup and refactoring
* finally - actual XML generation from the domain/node model objects

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/PasswordEncoding.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/PlainTextPasswordEncoder.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/Rot13PasswordEncoder.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/Rot47PasswordEncoder.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/XMLDataChannelDescriptorLoader.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/main/java/org/apache/cayenne/util/XMLEncoder.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/XMLDataChannelDescriptorLoaderTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/runtime/DataDomainProviderTest.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/datanode/PasswordEncoderEditor.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/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/resources/org/apache/cayenne/project2/cayenne-PROJECT2.xml

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/PasswordEncoding.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/PasswordEncoding.java?rev=890150&r1=890149&r2=890150&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/PasswordEncoding.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/PasswordEncoding.java Mon Dec 14 00:27:08 2009
@@ -17,46 +17,43 @@
  *  under the License.
  ****************************************************************/
 
-
 package org.apache.cayenne.conf;
 
 /**
- * Password encoders are used to translate the text of the database password,
- * on loading and on saving, from one form to another.  It can facilitate
- * the obscuring of the password text to make database connection information
- * less obvious to someone who stumbles onto the password.
- * 
- * Cayenne only includes facilities to obscure, not encrypt, the database
- * password.  The mechanism is user-extensible, though, so should stronger
- * security features be required, they can be added and integrated into
- * both the modeler and framework.
+ * Password encoders are used to translate the text of the database password, on loading
+ * and on saving, from one form to another. It can facilitate the obscuring of the
+ * password text to make database connection information less obvious to someone who
+ * stumbles onto the password. Cayenne only includes facilities to obscure, not encrypt,
+ * the database password. The mechanism is user-extensible, though, so should stronger
+ * security features be required, they can be added and integrated into both the modeler
+ * and framework.
  * 
  * @since 3.0
  */
-public interface PasswordEncoding
-{
-  final String[] standardEncoders =
-    new String[] { PlainTextPasswordEncoder.class.getName(),
-                   Rot13PasswordEncoder.class.getName(),
-                   Rot47PasswordEncoder.class.getName() };
+public interface PasswordEncoding {
+
+    final String[] standardEncoders = new String[] {
+            PlainTextPasswordEncoder.class.getName(),
+            Rot13PasswordEncoder.class.getName(), Rot47PasswordEncoder.class.getName()
+    };
 
-  /**
-   * Decodes an encoded database password.
-   * 
-   * @param encodedPassword - The encoded password to be decoded
-   * @param key - An optional data element which can be used to unlock the password.
-   *        Some encoders may require the key.
-   * @return The decoded normal/plain plassword.
-   */
-  public String decodePassword(String encodedPassword, String key);
+    /**
+     * Decodes an encoded database password.
+     * 
+     * @param encodedPassword - The encoded password to be decoded
+     * @param key - An optional data element which can be used to unlock the password.
+     *            Some encoders may require the key.
+     * @return The decoded normal/plain plassword.
+     */
+    String decodePassword(String encodedPassword, String key);
 
-  /**
-   * Encodes a normal/plain database password.
-   * 
-   * @param normalPassword - The normal/plain password to be encoded
-   * @param key - An optional data element which can be used to lock the password.
-   *        Some encoders may require the key.
-   * @return The encoded password.
-   */
-  public String encodePassword(String normalPassword, String key);
+    /**
+     * Encodes a normal/plain database password.
+     * 
+     * @param normalPassword - The normal/plain password to be encoded
+     * @param key - An optional data element which can be used to lock the password. Some
+     *            encoders may require the key.
+     * @return The encoded password.
+     */
+    String encodePassword(String normalPassword, String key);
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/PlainTextPasswordEncoder.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/PlainTextPasswordEncoder.java?rev=890150&r1=890149&r2=890150&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/PlainTextPasswordEncoder.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/PlainTextPasswordEncoder.java Mon Dec 14 00:27:08 2009
@@ -17,32 +17,22 @@
  *  under the License.
  ****************************************************************/
 
-
 package org.apache.cayenne.conf;
 
 /**
  * The plain text password encoder passes the text of the database password
- * straight-through without any alteration.  This is identical to the
- * behavior of pre-3.0 versions of Cayenne, where the password was stored
- * in the XML model in clear text.
+ * straight-through without any alteration. This is identical to the behavior of pre-3.0
+ * versions of Cayenne, where the password was stored in the XML model in clear text.
  * 
  * @since 3.0
  */
-public class PlainTextPasswordEncoder implements PasswordEncoding
-{
-  /* (non-Javadoc)
-   * @see org.apache.cayenne.conf.PasswordEncoding#decodePassword(java.lang.String, java.lang.String)
-   */
-  public String decodePassword(String encodedPassword, String key)
-  {
-    return encodedPassword;
-  }
+public class PlainTextPasswordEncoder implements PasswordEncoding {
+
+    public String decodePassword(String encodedPassword, String key) {
+        return encodedPassword;
+    }
 
-  /* (non-Javadoc)
-   * @see org.apache.cayenne.conf.PasswordEncoding#encodePassword(java.lang.String, java.lang.String)
-   */
-  public String encodePassword(String normalPassword, String key)
-  {
-    return normalPassword;
-  }
+    public String encodePassword(String normalPassword, String key) {
+        return normalPassword;
+    }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/Rot13PasswordEncoder.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/Rot13PasswordEncoder.java?rev=890150&r1=890149&r2=890150&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/Rot13PasswordEncoder.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/Rot13PasswordEncoder.java Mon Dec 14 00:27:08 2009
@@ -17,86 +17,79 @@
  *  under the License.
  ****************************************************************/
 
-
 package org.apache.cayenne.conf;
 
 /**
- * The ROT-13 password encoder passes the text of the database password
- * through a simple Caesar cipher to obscure the password text.  The ROT-13
- * cipher only processes letters -- numbers and symbols are left untouched.
- * ROT-13 is also a symmetrical cipher and therefore provides no real
- * encryption since applying the cipher to the encrypted text produces the
- * original source text.  See the Wikipedia entry on
- * <a href="http://en.wikipedia.org/wiki/Rot-13">ROT13</a>
- * for more information on this topic.
+ * The ROT-13 password encoder passes the text of the database password through a simple
+ * Caesar cipher to obscure the password text. The ROT-13 cipher only processes letters --
+ * numbers and symbols are left untouched. ROT-13 is also a symmetrical cipher and
+ * therefore provides no real encryption since applying the cipher to the encrypted text
+ * produces the original source text. See the Wikipedia entry on <a
+ * href="http://en.wikipedia.org/wiki/Rot-13">ROT13</a> for more information on this
+ * topic.
  * 
  * @since 3.0
  */
-public class Rot13PasswordEncoder implements PasswordEncoding
-{
-  /* (non-Javadoc)
-   * @see org.apache.cayenne.conf.PasswordEncoding#decodePassword(java.lang.String, java.lang.String)
-   */
-  public String decodePassword(String encodedPassword, String key)
-  {
-    return rotate(encodedPassword);
-  }
-
-  /* (non-Javadoc)
-   * @see org.apache.cayenne.conf.PasswordEncoding#encodePassword(java.lang.String, java.lang.String)
-   */
-  public String encodePassword(String normalPassword, String key)
-  {
-    return rotate(normalPassword);
-  }
-
-  /**
-   * Applies a ROT-13 Caesar cipher to the supplied value.  Each letter in
-   * the supplied value is substituted with a new value rotated by 13 places
-   * in the alphabet.  See <a href="http://en.wikipedia.org/wiki/ROT13">ROT13</a>
-   * for more information.
-   * <p>
-   * A Unix command to perform a ROT-13 cipher is:
-   *   <pre>tr "[a-m][n-z][A-M][N-Z]" "[n-z][a-m][N-Z][A-M]"</pre>
-   *   
-   * @param value The text to be rotated.
-   * @return The rotated text.
-   */
-  public String rotate(String value)
-  {
-    int length = value.length();
-    StringBuilder result = new StringBuilder();
-
-    for (int i = 0; i < length; i++)
-    {
-      char c = value.charAt(i);
-
-      // If c is a letter, rotate it by 13.  Numbers/symbols are untouched.
-      if ((c >= 'a' && c <= 'm') || (c >= 'A' && c <= 'M'))
-        c += 13; // The first half of the alphabet goes forward 13 letters
-      else if ((c >= 'n' && c <= 'z') || (c >= 'A' && c <= 'Z'))
-        c -= 13; // The last half of the alphabet goes backward 13 letters
+public class Rot13PasswordEncoder implements PasswordEncoding {
+
+    public String decodePassword(String encodedPassword, String key) {
+        return rotate(encodedPassword);
+    }
 
-      result.append(c);
+    public String encodePassword(String normalPassword, String key) {
+        return rotate(normalPassword);
     }
 
-    return result.toString();
-  }
+    /**
+     * Applies a ROT-13 Caesar cipher to the supplied value. Each letter in the supplied
+     * value is substituted with a new value rotated by 13 places in the alphabet. See <a
+     * href="http://en.wikipedia.org/wiki/ROT13">ROT13</a> for more information.
+     * <p>
+     * A Unix command to perform a ROT-13 cipher is:
+     * 
+     * <pre>
+     * tr "[a-m][n-z][A-M][N-Z]" "[n-z][a-m][N-Z][A-M]"
+     * </pre>
+     * 
+     * @param value The text to be rotated.
+     * @return The rotated text.
+     */
+    public String rotate(String value) {
+        if (value == null) {
+            return null;
+        }
+
+        int length = value.length();
+        StringBuilder result = new StringBuilder();
+
+        for (int i = 0; i < length; i++) {
+            char c = value.charAt(i);
+
+            // If c is a letter, rotate it by 13. Numbers/symbols are untouched.
+            if ((c >= 'a' && c <= 'm') || (c >= 'A' && c <= 'M'))
+                c += 13; // The first half of the alphabet goes forward 13 letters
+            else if ((c >= 'n' && c <= 'z') || (c >= 'A' && c <= 'Z'))
+                c -= 13; // The last half of the alphabet goes backward 13 letters
+
+            result.append(c);
+        }
 
-  /**
-   * Small test program to run text through the ROT-13 cipher.  This program
-   * can also be run by hand to encode/decode values manually.  The values
-   * passed on the command line are printed to standard out.
-   *   
-   * @param args The array of text values (on the command-line) to be run
-   *             through the ROT-13 cipher.
-   */
-  public static void main(String[] args) 
-  {
-    Rot13PasswordEncoder encoder = new Rot13PasswordEncoder();
-
-      for (String string : args) {
-          System.out.println(encoder.rotate(string));
-      }
-  }
+        return result.toString();
+    }
+
+    /**
+     * Small test program to run text through the ROT-13 cipher. This program can also be
+     * run by hand to encode/decode values manually. The values passed on the command line
+     * are printed to standard out.
+     * 
+     * @param args The array of text values (on the command-line) to be run through the
+     *            ROT-13 cipher.
+     */
+    public static void main(String[] args) {
+        Rot13PasswordEncoder encoder = new Rot13PasswordEncoder();
+
+        for (String string : args) {
+            System.out.println(encoder.rotate(string));
+        }
+    }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/Rot47PasswordEncoder.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/Rot47PasswordEncoder.java?rev=890150&r1=890149&r2=890150&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/Rot47PasswordEncoder.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/Rot47PasswordEncoder.java Mon Dec 14 00:27:08 2009
@@ -17,95 +17,88 @@
  *  under the License.
  ****************************************************************/
 
-
 package org.apache.cayenne.conf;
 
 /**
- * The ROT-47 password encoder passes the text of the database password
- * through a simple Caesar cipher to obscure the password text.  The ROT-47
- * cipher is similar to the ROT-13 cipher, but processes numbers and symbols
- * as well. See the Wikipedia entry on
- * <a href="http://en.wikipedia.org/wiki/Rot-13">ROT13</a>
- * for more information on this topic.
- *
+ * The ROT-47 password encoder passes the text of the database password through a simple
+ * Caesar cipher to obscure the password text. The ROT-47 cipher is similar to the ROT-13
+ * cipher, but processes numbers and symbols as well. See the Wikipedia entry on <a
+ * href="http://en.wikipedia.org/wiki/Rot-13">ROT13</a> for more information on this
+ * topic.
+ * 
  * @since 3.0
  */
-public class Rot47PasswordEncoder implements PasswordEncoding
-{
-  /* (non-Javadoc)
-   * @see org.apache.cayenne.conf.PasswordEncoding#decodePassword(java.lang.String, java.lang.String)
-   */
-  public String decodePassword(String encodedPassword, String key)
-  {
-    return rotate(encodedPassword);
-  }
-
-  /* (non-Javadoc)
-   * @see org.apache.cayenne.conf.PasswordEncoding#encodePassword(java.lang.String, java.lang.String)
-   */
-  public String encodePassword(String normalPassword, String key)
-  {
-    return rotate(normalPassword);
-  }
-
-  /**
-   * Applies a ROT-47 Caesar cipher to the supplied value.  Each letter in
-   * the supplied value is substituted with a new value rotated by 47 places.
-   * See <a href="http://en.wikipedia.org/wiki/ROT13">ROT13</a> for more
-   * information (there is a subsection for ROT-47).
-   * <p>
-   * A Unix command to perform a ROT-47 cipher is:
-   *   <pre>tr '!-~' 'P-~!-O'</pre>
-   *   
-   * @param value The text to be rotated.
-   * @return The rotated text.
-   */
-  public String rotate(String value)
-  {
-    int length = value.length();
-    StringBuilder result = new StringBuilder();
-
-    for (int i = 0; i < length; i++)
-    {
-      char c = value.charAt(i);
-
-      // Process letters, numbers, and symbols -- ignore spaces.
-      if (c != ' ')
-      {
-        // Add 47 (it is ROT-47, after all).
-        c += 47;
-
-        // If character is now above printable range, make it printable.
-        // Range of printable characters is ! (33) to ~ (126).  A value
-        // of 127 (just above ~) would therefore get rotated down to a
-        // 33 (the !).  The value 94 comes from 127 - 33 = 94, which is
-        // therefore the value that needs to be subtracted from the
-        // non-printable character to put it into the correct printable
-        // range.
-        if (c > '~')
-          c -= 94;
-      }
+public class Rot47PasswordEncoder implements PasswordEncoding {
+
+    public String decodePassword(String encodedPassword, String key) {
+        return rotate(encodedPassword);
+    }
 
-      result.append(c);
+    public String encodePassword(String normalPassword, String key) {
+        return rotate(normalPassword);
     }
 
-    return result.toString();
-  }
+    /**
+     * Applies a ROT-47 Caesar cipher to the supplied value. Each letter in the supplied
+     * value is substituted with a new value rotated by 47 places. See <a
+     * href="http://en.wikipedia.org/wiki/ROT13">ROT13</a> for more information (there is
+     * a subsection for ROT-47).
+     * <p>
+     * A Unix command to perform a ROT-47 cipher is:
+     * 
+     * <pre>
+     * tr '!-~' 'P-~!-O'
+     * </pre>
+     * 
+     * @param value The text to be rotated.
+     * @return The rotated text.
+     */
+    public String rotate(String value) {
+        if (value == null) {
+            return null;
+        }
+
+        int length = value.length();
+        StringBuilder result = new StringBuilder();
+
+        for (int i = 0; i < length; i++) {
+            char c = value.charAt(i);
+
+            // Process letters, numbers, and symbols -- ignore spaces.
+            if (c != ' ') {
+                // Add 47 (it is ROT-47, after all).
+                c += 47;
+
+                // If character is now above printable range, make it printable.
+                // Range of printable characters is ! (33) to ~ (126). A value
+                // of 127 (just above ~) would therefore get rotated down to a
+                // 33 (the !). The value 94 comes from 127 - 33 = 94, which is
+                // therefore the value that needs to be subtracted from the
+                // non-printable character to put it into the correct printable
+                // range.
+                if (c > '~')
+                    c -= 94;
+            }
+
+            result.append(c);
+        }
 
-  /**
-   * Small test program to run text through the ROT-47 cipher.  This program
-   * can also be run by hand to encode/decode values manually.  The values
-   * passed on the command line are printed to standard out.
-   *   
-   * @param args The array of text values (on the command-line) to be run
-   *             through the ROT-47 cipher.
-   */
-  public static void main(String[] args) 
-  {
-    Rot47PasswordEncoder encoder = new Rot47PasswordEncoder();
-
-      for (String string : args) {
-          System.out.println(encoder.rotate(string));
-      }
-  }
+        return result.toString();
+    }
+
+    /**
+     * Small test program to run text through the ROT-47 cipher. This program can also be
+     * run by hand to encode/decode values manually. The values passed on the command line
+     * are printed to standard out.
+     * 
+     * @param args The array of text values (on the command-line) to be run through the
+     *            ROT-47 cipher.
+     */
+    public static void main(String[] args) {
+        Rot47PasswordEncoder encoder = new Rot47PasswordEncoder();
+
+        for (String string : args) {
+            System.out.println(encoder.rotate(string));
+        }
+    }
 }

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=890150&r1=890149&r2=890150&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 Mon Dec 14 00:27:08 2009
@@ -56,12 +56,18 @@
             location = DBCP_PROPERTIES;
         }
 
-        DataChannelDescriptor parent = nodeDescriptor.getParent();
-        Resource dbcpConfiguration = parent.getConfigurationSource().getRelativeResource(
-                location);
+        Resource baseConfiguration = nodeDescriptor.getConfigurationSource();
+        if (baseConfiguration == null) {
+            throw new CayenneRuntimeException(
+                    "Null 'configurationSource' for nodeDescriptor '%s'",
+                    nodeDescriptor.getName());
+        }
+
+        Resource dbcpConfiguration = baseConfiguration.getRelativeResource(location);
         if (dbcpConfiguration == null) {
             throw new CayenneRuntimeException(
-                    "Null 'configurationResource' for nodeDescriptor '%s'",
+                    "Missing DBCP configuration '%s' for nodeDescriptor '%s'",
+                    location,
                     nodeDescriptor.getName());
         }
 

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=890150&r1=890149&r2=890150&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 Mon Dec 14 00:27:08 2009
@@ -22,6 +22,7 @@
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Map.Entry;
 
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.resource.Resource;
@@ -39,16 +40,63 @@
     protected String version;
     protected Map<String, String> properties;
     protected Collection<DataMap> dataMaps;
-    protected Collection<DataNodeDescriptor> dataNodeDescriptors;
+    protected Collection<DataNodeDescriptor> nodeDescriptors;
     protected Resource configurationSource;
 
     public DataChannelDescriptor() {
         properties = new HashMap<String, String>();
         dataMaps = new ArrayList<DataMap>(5);
-        dataNodeDescriptors = new ArrayList<DataNodeDescriptor>(3);
+        nodeDescriptors = new ArrayList<DataNodeDescriptor>(3);
     }
 
     public void encodeAsXML(XMLEncoder encoder) {
+
+        encoder.print("<domain");
+        encoder.printAttribute("name", name);
+        encoder.printAttribute("project-version", version);
+        encoder.println(">");
+
+        encoder.indent(1);
+        boolean breakNeeded = false;
+
+        if (!properties.isEmpty()) {
+            breakNeeded = true;
+
+            for (Entry<String, String> property : properties.entrySet()) {
+                encoder.printProperty(property.getKey(), property.getValue());
+            }
+
+        }
+
+        if (!dataMaps.isEmpty()) {
+            if (breakNeeded) {
+                encoder.println();
+            }
+            else {
+                breakNeeded = true;
+            }
+
+            for (DataMap dataMap : dataMaps) {
+
+                encoder.print("<map");
+                encoder.printAttribute("name", dataMap.getName().trim());
+                encoder.println("/>");
+            }
+        }
+
+        if (!nodeDescriptors.isEmpty()) {
+            if (breakNeeded) {
+                encoder.println();
+            }
+            else {
+                breakNeeded = true;
+            }
+
+            encoder.print(nodeDescriptors);
+        }
+
+        encoder.indent(-1);
+        encoder.println("</domain>");
     }
 
     public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor) {
@@ -79,8 +127,8 @@
         return dataMaps;
     }
 
-    public Collection<DataNodeDescriptor> getDataNodeDescriptors() {
-        return dataNodeDescriptors;
+    public Collection<DataNodeDescriptor> getNodeDescriptors() {
+        return nodeDescriptors;
     }
 
     public Resource getConfigurationSource() {

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=890150&r1=890149&r2=890150&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 Mon Dec 14 00:27:08 2009
@@ -23,17 +23,17 @@
 
 import org.apache.cayenne.access.DataNode;
 import org.apache.cayenne.conn.DataSourceInfo;
+import org.apache.cayenne.resource.Resource;
 import org.apache.cayenne.util.XMLEncoder;
 import org.apache.cayenne.util.XMLSerializable;
 
 /**
- * A descriptor of a {@link DataNode}.
+ * A descriptor of {@link DataNode} configuration.
  * 
  * @since 3.1
  */
 public class DataNodeDescriptor implements XMLSerializable {
 
-    protected DataChannelDescriptor parent;
     protected String name;
     protected Collection<String> dataMapNames;
 
@@ -41,19 +41,40 @@
     protected String adapterType;
     protected String dataSourceFactoryType;
     protected String schemaUpdateStrategyType;
+
+    // TODO: andrus, 12.13.2009: replace funky DataSourceInfo with a cleaner new class
+    // (DataSourceDescriptor?)
     protected DataSourceInfo dataSourceDescriptor;
 
-    public DataNodeDescriptor() {
-        this(null);
-    }
+    protected Resource configurationSource;
 
-    public DataNodeDescriptor(DataChannelDescriptor parent) {
-        this.parent = parent;
+    public DataNodeDescriptor() {
         this.dataMapNames = new ArrayList<String>();
     }
 
     public void encodeAsXML(XMLEncoder encoder) {
-        throw new UnsupportedOperationException("TODO");
+        encoder.print("<node");
+        encoder.printlnAttribute("name", name);
+        encoder.indent(1);
+
+        encoder.printlnAttribute("adapter", adapterType);
+        encoder.printlnAttribute("factory", dataSourceFactoryType);
+        encoder.printlnAttribute("parameters", parameters);
+        encoder.printlnAttribute("schema-update-strategy", schemaUpdateStrategyType);
+        encoder.println(">");
+
+        for (String mapName : dataMapNames) {
+            encoder.print("<map-ref");
+            encoder.printAttribute("name", mapName);
+            encoder.println("/>");
+        }
+
+        if (dataSourceDescriptor != null) {
+            dataSourceDescriptor.encodeAsXML(encoder);
+        }
+
+        encoder.indent(-1);
+        encoder.println("</node>");
     }
 
     public String getName() {
@@ -82,8 +103,8 @@
      * {@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 void setParameters(String parameters) {
+        this.parameters = parameters;
     }
 
     public String getAdapterType() {
@@ -118,11 +139,21 @@
         this.dataSourceDescriptor = dataSourceDescriptor;
     }
 
-    public DataChannelDescriptor getParent() {
-        return parent;
+    /**
+     * Returns configuration resource for this descriptor. Configuration is usually shared
+     * with the parent {@link DataChannelDescriptor}.
+     */
+    public Resource getConfigurationSource() {
+        return configurationSource;
     }
 
-    public void setParent(DataChannelDescriptor parent) {
-        this.parent = parent;
+    /**
+     * Sets configuration resource for this descriptor. Configuration is usually shared
+     * with the parent {@link DataChannelDescriptor} and has to be synchronized when it
+     * changes in the parent.
+     */
+    public void setConfigurationSource(Resource configurationResource) {
+        this.configurationSource = configurationResource;
     }
+
 }

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=890150&r1=890149&r2=890150&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 Mon Dec 14 00:27:08 2009
@@ -274,8 +274,10 @@
                     throw new ConfigurationException("Error: <node> without 'name'.");
                 }
 
-                DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor(descriptor);
-                descriptor.getDataNodeDescriptors().add(nodeDescriptor);
+                DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor();
+                nodeDescriptor
+                        .setConfigurationSource(descriptor.getConfigurationSource());
+                descriptor.getNodeDescriptors().add(nodeDescriptor);
 
                 nodeDescriptor.setName(nodeName);
                 nodeDescriptor.setAdapterType(attributes.getValue("", "adapter"));

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=890150&r1=890149&r2=890150&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 Mon Dec 14 00:27:08 2009
@@ -24,13 +24,15 @@
 import org.apache.cayenne.conf.PasswordEncoding;
 import org.apache.cayenne.conf.PlainTextPasswordEncoder;
 import org.apache.cayenne.util.Util;
+import org.apache.cayenne.util.XMLEncoder;
+import org.apache.cayenne.util.XMLSerializable;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 /**
  * Helper JavaBean class that holds DataSource login information.
  */
-public class DataSourceInfo implements Cloneable, Serializable {
+public class DataSourceInfo implements Cloneable, Serializable, XMLSerializable {
 
     private static Log logger = LogFactory.getLog(DataSourceInfo.class);
 
@@ -49,7 +51,7 @@
     public static final String PASSWORD_LOCATION_URL = "url";
 
     // Extended parameters
-    protected String passwordEncoderClass = PasswordEncoding.standardEncoders[0];
+    protected String passwordEncoderClass = PlainTextPasswordEncoder.class.getName();
     protected String passwordEncoderKey = "";
     protected String passwordLocation = PASSWORD_LOCATION_MODEL;
     protected String passwordSourceExecutable = "";
@@ -100,6 +102,64 @@
         return true;
     }
 
+    /**
+     * @since 3.1
+     */
+    public void encodeAsXML(XMLEncoder encoder) {
+        encoder.println("<data-source>");
+        encoder.indent(1);
+
+        encoder.print("<driver");
+        encoder.printAttribute("value", jdbcDriver);
+        encoder.println("/>");
+
+        encoder.print("<url");
+        encoder.printAttribute("value", dataSourceUrl);
+        encoder.println("/>");
+
+        encoder.print("<connectionPool");
+        encoder.printAttribute("min", String.valueOf(minConnections));
+        encoder.printAttribute("max", String.valueOf(maxConnections));
+        encoder.println("/>");
+
+        encoder.print("<login");
+        encoder.printAttribute("userName", userName);
+
+        if (DataSourceInfo.PASSWORD_LOCATION_MODEL.equals(passwordLocation)) {
+
+            PasswordEncoding passwordEncoder = getPasswordEncoder();
+
+            if (passwordEncoder != null) {
+                String passwordEncoded = passwordEncoder.encodePassword(
+                        password,
+                        passwordEncoderKey);
+                encoder.printAttribute("password", passwordEncoded);
+            }
+        }
+
+        if (!PlainTextPasswordEncoder.class.getName().equals(passwordEncoderClass)) {
+            encoder.printAttribute("encoderClass", passwordEncoderClass);
+        }
+
+        encoder.printAttribute("encoderKey", passwordEncoderKey);
+
+        if (!DataSourceInfo.PASSWORD_LOCATION_MODEL.equals(passwordLocation)) {
+            encoder.printAttribute("passwordLocation", passwordLocation);
+        }
+
+        // TODO: this is very not nice... we need to clean up the whole DataSourceInfo
+        // to avoid returning arbitrary labels...
+        String passwordSource = getPasswordSource();
+        if (!"Not Applicable".equals(passwordSource)) {
+            encoder.printAttribute("passwordSource", passwordSource);
+        }
+
+        encoder.println("/>");
+
+        encoder.indent(-1);
+        encoder.println("</data-source>");
+    }
+
     public DataSourceInfo cloneInfo() {
         try {
             return (DataSourceInfo) super.clone();
@@ -310,12 +370,12 @@
 
     @Override
     public String toString() {
-        StringBuilder buf = new StringBuilder();
-        buf.append("[").append(this.getClass().getName()).append(":").append(
+        StringBuilder buffer = new StringBuilder();
+        buffer.append("[").append(getClass().getName()).append(":").append(
                 "\n   user name: ").append(userName).append("\n   password: ");
 
-        buf.append("**********");
-        buf
+        buffer.append("**********");
+        buffer
                 .append("\n   driver: ")
                 .append(jdbcDriver)
                 .append("\n   db adapter class: ")
@@ -328,16 +388,16 @@
                 .append(maxConnections);
 
         if (!PlainTextPasswordEncoder.class.getName().equals(passwordEncoderClass)) {
-            buf.append("\n   encoder class: ").append(passwordEncoderClass).append(
+            buffer.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(
+            buffer.append("\n   password location: ").append(passwordLocation).append(
                     "\n   password source: ").append(getPasswordSource());
         }
 
-        buf.append("\n]");
-        return buf.toString();
+        buffer.append("\n]");
+        return buffer.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=890150&r1=890149&r2=890150&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 Mon Dec 14 00:27:08 2009
@@ -30,6 +30,7 @@
 import java.util.SortedMap;
 import java.util.TreeMap;
 
+import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.configuration.ConfigurationNode;
 import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
 import org.apache.cayenne.map.event.DbEntityListener;
@@ -345,7 +346,18 @@
         encoder.print(getObjEntityMap());
         encodeDBRelationshipsAsXML(getDbEntityMap(), encoder);
         encodeOBJRelationshipsAsXML(getObjEntityMap(), encoder);
-        encoder.print(getQueryMap());
+
+        // since Queries are not XMLSerializable by default, check for non-serilaizable
+        // queries and throws if they are not..
+        for (Query query : getQueries()) {
+            if (query instanceof XMLSerializable) {
+                ((XMLSerializable) query).encodeAsXML(encoder);
+            }
+            else {
+                throw new CayenneRuntimeException("Query is not XMLSerilaizable: "
+                        + query);
+            }
+        }
 
         // write entity listeners
         for (EntityListener entityListener : getDefaultEntityListeners()) {

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=890150&r1=890149&r2=890150&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 Mon Dec 14 00:27:08 2009
@@ -153,7 +153,7 @@
             dataDomain.addMap(dataMap);
         }
 
-        for (DataNodeDescriptor nodeDescriptor : descriptor.getDataNodeDescriptors()) {
+        for (DataNodeDescriptor nodeDescriptor : descriptor.getNodeDescriptors()) {
             DataNode dataNode = new DataNode(nodeDescriptor.getName());
 
             dataNode.setDataSourceLocation(nodeDescriptor.getParameters());

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/util/XMLEncoder.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/util/XMLEncoder.java?rev=890150&r1=890149&r2=890150&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/util/XMLEncoder.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/util/XMLEncoder.java Mon Dec 14 00:27:08 2009
@@ -21,7 +21,6 @@
 
 import java.io.PrintWriter;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.Map;
 
 /**
@@ -30,6 +29,7 @@
  * @since 1.1
  */
 public class XMLEncoder {
+
     protected String indent;
     protected PrintWriter out;
 
@@ -57,38 +57,75 @@
     }
 
     /**
-     * Utility method that prints all map values,
-     * assuming they are XMLSerializable objects.
+     * Utility method that prints all map values, assuming they are XMLSerializable
+     * objects.
      */
-    public void print(Map map) {
-        Iterator it = map.entrySet().iterator();
-        while (it.hasNext()) {
-            Map.Entry entry = (Map.Entry) it.next();
-            ((XMLSerializable) entry.getValue()).encodeAsXML(this);
+    public void print(Map<?, ? extends XMLSerializable> map) {
+        for (XMLSerializable value : map.values()) {
+            value.encodeAsXML(this);
         }
     }
 
     /**
-     * Utility method that prints all map values,
-     * assuming they are XMLSerializable objects.
+     * Utility method that prints all map values, assuming they are XMLSerializable
+     * objects.
      */
-    public void print(Collection c) {
-        Iterator it = c.iterator();
-        while (it.hasNext()) {
-            ((XMLSerializable) it.next()).encodeAsXML(this);
+    public void print(Collection<? extends XMLSerializable> c) {
+        for (XMLSerializable value : c) {
+            value.encodeAsXML(this);
         }
     }
 
     /**
-     * Prints a common XML element - property with name and value.
+     * Prints an XML attribute. The value is trimmed (so leading and following spaces are
+     * lost) and then encoded to be a proper XML attribute value. E.g. "&" becomes
+     * "&amp;", etc.
+     * 
+     * @since 3.1
      */
-    public void printProperty(String name, String value) {
+    public void printAttribute(String name, String value) {
+        printAttribute(name, value, false);
+    }
+
+    /**
+     * @since 3.1
+     */
+    public void printlnAttribute(String name, String value) {
+        printAttribute(name, value, true);
+    }
+
+    private void printAttribute(String name, String value, boolean lineBreak) {
+        if (value == null) {
+            return;
+        }
+
+        value = value.trim();
+        if (value.length() == 0) {
+            return;
+        }
+
+        value = Util.encodeXmlAttribute(value);
+
         printIndent();
-        out.print("<property name=\"");
+        out.print(' ');
         out.print(name);
-        out.print("\" value=\"");
+        out.print("=\"");
         out.print(value);
-        out.println("\"/>");
+        out.print("\"");
+        if (lineBreak) {
+            println();
+        }
+    }
+
+    /**
+     * Prints a common XML element - property with name and value.
+     */
+    public void printProperty(String name, String value) {
+        printIndent();
+        out.print("<property");
+        printAttribute("name", name);
+        printAttribute("value", value);
+        out.println("/>");
         indentLine = true;
     }
 
@@ -132,6 +169,14 @@
         indentLine = true;
     }
 
+    /**
+     * @since 3.1
+     */
+    public void println() {
+        out.println();
+        indentLine = true;
+    }
+
     public void println(char c) {
         printIndent();
         out.println(c);

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=890150&r1=890149&r2=890150&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 Mon Dec 14 00:27:08 2009
@@ -36,10 +36,8 @@
         URL url = getClass().getClassLoader().getResource(baseUrl + "/");
         assertNotNull(url);
 
-        DataChannelDescriptor channelDescriptor = new DataChannelDescriptor();
-        channelDescriptor.setConfigurationSource(new URLResource(url));
-
-        DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor(channelDescriptor);
+        DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor();
+        nodeDescriptor.setConfigurationSource(new URLResource(url));
         nodeDescriptor.setParameters("testDBCP.properties");
 
         DBCPDataSourceFactory factory = new DBCPDataSourceFactory();
@@ -65,10 +63,8 @@
         URL url = getClass().getClassLoader().getResource(baseUrl + "/");
         assertNotNull(url);
 
-        DataChannelDescriptor channelDescriptor = new DataChannelDescriptor();
-        channelDescriptor.setConfigurationSource(new URLResource(url));
-
-        DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor(channelDescriptor);
+        DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor();
+        nodeDescriptor.setConfigurationSource(new URLResource(url));
         nodeDescriptor.setParameters("testDBCP_legacy.properties");
 
         DBCPDataSourceFactory factory = new DBCPDataSourceFactory();
@@ -94,10 +90,8 @@
         URL url = getClass().getClassLoader().getResource(baseUrl + "/");
         assertNotNull(url);
 
-        DataChannelDescriptor channelDescriptor = new DataChannelDescriptor();
-        channelDescriptor.setConfigurationSource(new URLResource(url));
-
-        DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor(channelDescriptor);
+        DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor();
+        nodeDescriptor.setConfigurationSource(new URLResource(url));
         nodeDescriptor.setParameters("testDBCP.properties.nosuchfile");
 
         DBCPDataSourceFactory factory = new DBCPDataSourceFactory();

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=890150&r1=890149&r2=890150&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 Mon Dec 14 00:27:08 2009
@@ -168,7 +168,7 @@
         assertEquals("testConfigMap3_1", map1.getName());
         assertEquals("testConfigMap3_2", map2.getName());
 
-        Collection<DataNodeDescriptor> nodes = descriptor.getDataNodeDescriptors();
+        Collection<DataNodeDescriptor> nodes = descriptor.getNodeDescriptors();
         assertEquals(1, nodes.size());
 
         DataNodeDescriptor node1 = nodes.iterator().next();

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=890150&r1=890149&r2=890150&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 Mon Dec 14 00:27:08 2009
@@ -80,13 +80,13 @@
         nodeDescriptor1
                 .setSchemaUpdateStrategyType(ThrowOnPartialOrCreateSchemaStrategy.class
                         .getName());
-        testDescriptor.getDataNodeDescriptors().add(nodeDescriptor1);
+        testDescriptor.getNodeDescriptors().add(nodeDescriptor1);
 
         DataNodeDescriptor nodeDescriptor2 = new DataNodeDescriptor();
         nodeDescriptor2.setName("node2");
         nodeDescriptor2.getDataMapNames().add("map2");
         nodeDescriptor2.setParameters("testDataNode2.driver.xml");
-        testDescriptor.getDataNodeDescriptors().add(nodeDescriptor2);
+        testDescriptor.getNodeDescriptors().add(nodeDescriptor2);
 
         final ResourceLocator locator = new ResourceLocator() {
 

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/datanode/PasswordEncoderEditor.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/datanode/PasswordEncoderEditor.java?rev=890150&r1=890149&r2=890150&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/datanode/PasswordEncoderEditor.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/datanode/PasswordEncoderEditor.java Mon Dec 14 00:27:08 2009
@@ -36,20 +36,19 @@
 import org.apache.cayenne.swing.BindingDelegate;
 import org.apache.cayenne.swing.ObjectBinding;
 
+public class PasswordEncoderEditor extends CayenneController {
 
-public class PasswordEncoderEditor extends CayenneController  {
-    
     protected DataNode node;
     protected ObjectBinding[] bindings;
     protected PasswordEncoderView view;
     protected BindingDelegate nodeChangeProcessor;
-    
-    public PasswordEncoderEditor(CayenneController parent){
+
+    public PasswordEncoderEditor(CayenneController parent) {
 
         super(parent);
-        
+
         this.view = new PasswordEncoderView();
-        
+
         this.nodeChangeProcessor = new BindingDelegate() {
 
             public void modelUpdated(
@@ -61,51 +60,58 @@
                 ((ProjectController) getParent()).fireDataNodeEvent(e);
             }
         };
-                
+
         initController();
     }
-    
+
     protected void initController() {
         BindingBuilder builder = new BindingBuilder(
                 getApplication().getBindingFactory(),
                 this);
-        
+
         builder.setDelegate(nodeChangeProcessor);
-        
+
         bindings = new ObjectBinding[4];
-        
-        bindings[0] =
-              builder.bindToComboSelection(view.getPasswordEncoder(), "node.dataSource.dataSourceInfo.passwordEncoderClass");
-        bindings[1] =
-              builder.bindToTextField(view.getPasswordKey(), "node.dataSource.dataSourceInfo.passwordEncoderKey");
-        bindings[2] =
-              builder.bindToComboSelection(view.getPasswordLocation(), "node.dataSource.dataSourceInfo.passwordLocation");
-        bindings[3] =
-              builder.bindToTextField(view.getPasswordSource(), "node.dataSource.dataSourceInfo.passwordSource");
-
-          ((ProjectController) getParent())
-          .addDataNodeDisplayListener(new DataNodeDisplayListener() {
-        
-              public void currentDataNodeChanged(DataNodeDisplayEvent e) {
-                  refreshView(e.getDataNode());
-              }
-          });
-        
-          getView().addComponentListener(new ComponentAdapter() {
-        
-              public void componentShown(ComponentEvent e) {
-                  refreshView(node != null ? node : ((ProjectController) getParent())
-                          .getCurrentDataNode());
-              }
-          });
-          
-          
-      
-        builder.bindToAction(view.getPasswordEncoder(),  "validatePasswordEncoderAction()");
-        builder.bindToAction(view.getPasswordLocation(), "passwordLocationChangedAction()");
-      
+
+        bindings[0] = builder.bindToComboSelection(
+                view.getPasswordEncoder(),
+                "node.dataSource.dataSourceInfo.passwordEncoderClass");
+        bindings[1] = builder.bindToTextField(
+                view.getPasswordKey(),
+                "node.dataSource.dataSourceInfo.passwordEncoderKey");
+        bindings[2] = builder.bindToComboSelection(
+                view.getPasswordLocation(),
+                "node.dataSource.dataSourceInfo.passwordLocation");
+        bindings[3] = builder.bindToTextField(
+                view.getPasswordSource(),
+                "node.dataSource.dataSourceInfo.passwordSource");
+
+        ((ProjectController) getParent())
+                .addDataNodeDisplayListener(new DataNodeDisplayListener() {
+
+                    public void currentDataNodeChanged(DataNodeDisplayEvent e) {
+                        refreshView(e.getDataNode());
+                    }
+                });
+
+        getView().addComponentListener(new ComponentAdapter() {
+
+            public void componentShown(ComponentEvent e) {
+                refreshView(node != null ? node : ((ProjectController) getParent())
+                        .getCurrentDataNode());
+            }
+        });
+
+        builder
+                .bindToAction(
+                        view.getPasswordEncoder(),
+                        "validatePasswordEncoderAction()");
+        builder.bindToAction(
+                view.getPasswordLocation(),
+                "passwordLocationChangedAction()");
+
     }
-    
+
     protected void refreshView(DataNode node) {
         this.node = node;
 
@@ -118,73 +124,81 @@
             binding.updateView();
         }
     }
-    
-    public void validatePasswordEncoderAction()
-    {
-      if (node == null || node.getDataSource() == null)
-        return;
-
-      DataSourceInfo dsi = ((ProjectDataSource) node.getDataSource()).getDataSourceInfo();
-
-      if (view.getPasswordEncoder().getSelectedItem().equals(dsi.getPasswordEncoderClass()) == false)
-        return;
-
-      if (dsi.getPasswordEncoder() == null)
-      {
-        JOptionPane.showMessageDialog(getView(),
-                                      "A valid Password Encoder should be specified (check your CLASSPATH).",
-                                      "Invalid Password Encoder",
-                                      JOptionPane.ERROR_MESSAGE);
-      }
+
+    public void validatePasswordEncoderAction() {
+        if (node == null || node.getDataSource() == null)
+            return;
+
+        DataSourceInfo dsi = ((ProjectDataSource) node.getDataSource())
+                .getDataSourceInfo();
+
+        if (view.getPasswordEncoder().getSelectedItem().equals(
+                dsi.getPasswordEncoderClass()) == false)
+            return;
+
+        if (dsi.getPasswordEncoder() == null) {
+            JOptionPane
+                    .showMessageDialog(
+                            getView(),
+                            "A valid Password Encoder should be specified (check your CLASSPATH).",
+                            "Invalid Password Encoder",
+                            JOptionPane.ERROR_MESSAGE);
+        }
     }
-    
-    private void updatePasswordElements(boolean isPasswordFieldEnabled,
+
+    private void updatePasswordElements(
+            boolean isPasswordFieldEnabled,
             boolean isPasswordLocationEnabled,
-            String  passwordText,
-            String  passwordLocationLabel,
-            String  passwordLocationText)
-    {
+            String passwordText,
+            String passwordLocationLabel,
+            String passwordLocationText) {
         view.getPasswordSource().setEnabled(isPasswordLocationEnabled);
         view.getPasswordSourceLabel().setText(passwordLocationLabel);
         view.getPasswordSource().setText(passwordLocationText);
-        
 
     }
-    
-    public void passwordLocationChangedAction()
-    {
-      if (node == null || node.getDataSource() == null)
-        return;
-
-      DataSourceInfo dsi = ((ProjectDataSource) node.getDataSource()).getDataSourceInfo();
-
-      String selectedItem = (String) view.getPasswordLocation().getSelectedItem();
-
-      if (selectedItem.equals(DataSourceInfo.PASSWORD_LOCATION_CLASSPATH))
-        updatePasswordElements(true, true, dsi.getPassword(), "Password Filename:", dsi.getPasswordSourceFilename());
-      else if (selectedItem.equals(DataSourceInfo.PASSWORD_LOCATION_EXECUTABLE))
-        updatePasswordElements(false, true, null, "Password Executable:", dsi.getPasswordSourceExecutable());
-      else if (selectedItem.equals(DataSourceInfo.PASSWORD_LOCATION_MODEL))
-        updatePasswordElements(true, false, dsi.getPassword(), "Password Source:", dsi.getPasswordSourceModel());
-      else if (selectedItem.equals(DataSourceInfo.PASSWORD_LOCATION_URL))
-        updatePasswordElements(false, true, null, "Password URL:", dsi.getPasswordSourceUrl());
+
+    public void passwordLocationChangedAction() {
+        if (node == null || node.getDataSource() == null)
+            return;
+
+        DataSourceInfo dsi = ((ProjectDataSource) node.getDataSource())
+                .getDataSourceInfo();
+
+        String selectedItem = (String) view.getPasswordLocation().getSelectedItem();
+
+        if (selectedItem.equals(DataSourceInfo.PASSWORD_LOCATION_CLASSPATH))
+            updatePasswordElements(
+                    true,
+                    true,
+                    dsi.getPassword(),
+                    "Password Filename:",
+                    dsi.getPasswordSourceFilename());
+        else if (selectedItem.equals(DataSourceInfo.PASSWORD_LOCATION_EXECUTABLE))
+            updatePasswordElements(false, true, null, "Password Executable:", dsi
+                    .getPasswordSourceExecutable());
+        else if (selectedItem.equals(DataSourceInfo.PASSWORD_LOCATION_MODEL))
+            updatePasswordElements(
+                    true,
+                    false,
+                    dsi.getPassword(),
+                    "Password Source:",
+                    dsi.getPasswordSourceModel());
+        else if (selectedItem.equals(DataSourceInfo.PASSWORD_LOCATION_URL))
+            updatePasswordElements(false, true, null, "Password URL:", dsi
+                    .getPasswordSourceUrl());
     }
 
     public Component getView() {
         return view;
     }
 
-    
     public DataNode getNode() {
         return node;
     }
 
-    
     public void setNode(DataNode node) {
         this.node = node;
     }
 
-
-
-
 }

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=890150&r1=890149&r2=890150&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 Mon Dec 14 00:27:08 2009
@@ -38,15 +38,19 @@
 
     public Void visitDataChannelDescriptor(DataChannelDescriptor node) {
         XMLEncoder encoder = new XMLEncoder(printWriter, "\t");
-        encoder.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
+        printXMLHeader(encoder);
         node.encodeAsXML(encoder);
         return null;
     }
 
     public Void visitDataMap(DataMap node) {
         XMLEncoder encoder = new XMLEncoder(printWriter, "\t");
-        encoder.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
+        printXMLHeader(encoder);
         node.encodeAsXML(encoder);
         return null;
     }
+
+    private void printXMLHeader(XMLEncoder encoder) {
+        encoder.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
+    }
 }

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=890150&r1=890149&r2=890150&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 Mon Dec 14 00:27:08 2009
@@ -20,10 +20,13 @@
 
 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;
 
 /**
+ * Updates ConfigurationNode's configuration sources.
+ * 
  * @since 3.1
  */
 class ConfigurationSourceSetter implements ConfigurationNodeVisitor<Void> {
@@ -36,6 +39,11 @@
 
     public Void visitDataChannelDescriptor(DataChannelDescriptor node) {
         node.setConfigurationSource(configurationSource);
+
+        // update child configurations
+        for (DataNodeDescriptor childDescriptor : node.getNodeDescriptors()) {
+            childDescriptor.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=890150&r1=890149&r2=890150&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 Mon Dec 14 00:27:08 2009
@@ -40,7 +40,7 @@
 import org.apache.cayenne.util.Util;
 
 /**
- * A ProjectSaver saving project configuration to the filesystem.
+ * A ProjectSaver saving project configuration to the file system.
  * 
  * @since 3.1
  */
@@ -56,6 +56,8 @@
     public FileProjectSaver() {
         resourceGetter = new ConfigurationSourceGetter();
         nodesGetter = new ConfigurationNodesGetter();
+
+        // this is not configurable yet... probably doesn't have to be
         fileEncoding = "UTF-8";
     }
 

Modified: cayenne/main/trunk/framework/cayenne-project-unpublished/src/test/resources/org/apache/cayenne/project2/cayenne-PROJECT2.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-project-unpublished/src/test/resources/org/apache/cayenne/project2/cayenne-PROJECT2.xml?rev=890150&r1=890149&r2=890150&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-project-unpublished/src/test/resources/org/apache/cayenne/project2/cayenne-PROJECT2.xml (original)
+++ cayenne/main/trunk/framework/cayenne-project-unpublished/src/test/resources/org/apache/cayenne/project2/cayenne-PROJECT2.xml Mon Dec 14 00:27:08 2009
@@ -8,8 +8,10 @@
 		factory="org.apache.cayenne.configuration.XMLPoolingDataSourceFactory">
 		<map-ref name="testProjectMap2_1" />
 		<data-source>
+			<driver value="xyzDriver"/>
+			<url value="xyzUrl"/>
 			<connectionPool min="1" max="1" />
-			<login />
+			<login userName="xyzUser" password="xyzPassword"/>
 		</data-source>
 	</node>
 </domain>



Mime
View raw message