db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r289458 - in /db/ddlutils/trunk/src/java/org/apache/ddlutils: ./ platform/ task/
Date Fri, 16 Sep 2005 09:44:48 GMT
Author: tomdz
Date: Fri Sep 16 02:44:34 2005
New Revision: 289458

URL: http://svn.apache.org/viewcvs?rev=289458&view=rev
Log:
Added ability to specify for which platforms a parameter for the database creation sub task
is applicable
Changed initialization of the platform factory to a lazy scheme

Added:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/task/Parameter.java
      - copied, changed from r289427, db/ddlutils/trunk/src/java/org/apache/ddlutils/task/NamedValue.java
Removed:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/task/NamedValue.java
Modified:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/Platform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformFactory.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/AxionPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/CloudscapePlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/Db2Platform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/DerbyPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/FirebirdPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/HsqlDbPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/InterbasePlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/MSSqlPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/MaxDbPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/MckoiPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/MySqlPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/Oracle8Platform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PostgreSqlPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SapDbPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SybasePlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/task/CreateDatabaseCommand.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DropDatabaseCommand.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteDataToSpecifiedDatabaseCommand.java

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/Platform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/Platform.java?rev=289458&r1=289457&r2=289458&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/Platform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/Platform.java Fri Sep 16 02:44:34 2005
@@ -40,9 +40,9 @@
     /**
      * Returns the name of the database that this platform is for.
      * 
-     * @return The database name
+     * @return The name
      */
-    public String getDatabaseName();
+    public String getName();
 
     /**
      * Returns the info object for this platform.

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformFactory.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformFactory.java?rev=289458&r1=289457&r2=289458&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformFactory.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformFactory.java Fri Sep 16 02:44:34
2005
@@ -16,13 +16,9 @@
  * limitations under the License.
  */
 
-import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
-
 import javax.sql.DataSource;
-
 import org.apache.ddlutils.platform.AxionPlatform;
 import org.apache.ddlutils.platform.CloudscapePlatform;
 import org.apache.ddlutils.platform.Db2Platform;
@@ -52,13 +48,24 @@
 public class PlatformFactory
 {
     /** The database name -> platform map */
-    private static Map _platforms = new HashMap();
+    private static Map _platforms = null;
 
-    static
+    /**
+     * Returns the platform map.
+     * 
+     * @return The platform list
+     */
+    private static synchronized Map getPlatforms()
     {
-        registerDatabases();
+        if (_platforms == null)
+        {
+            // lazy initialization
+            _platforms = new HashMap();
+            registerPlatforms();
+        }
+        return _platforms;
     }
-
+    
     /**
      * Creates a new platform for the given (case insensitive) database name
      * or returns null if the database is not recognized.
@@ -68,7 +75,7 @@
      */
     public static synchronized Platform createNewPlatformInstance(String databaseName) throws
DdlUtilsException
     {
-        Class platformClass = (Class)_platforms.get(databaseName.toLowerCase());
+        Class platformClass = (Class)getPlatforms().get(databaseName.toLowerCase());
 
         try
         {
@@ -108,55 +115,73 @@
     }
 
     /**
-     * Returns a list of all supported databases.
+     * Returns a list of all supported platforms.
      * 
-     * @return The currently registered database types
+     * @return The names of the currently registered platforms
      */
-    public static synchronized List getDatabaseTypes()
+    public static synchronized String[] getSupportedPlatforms()
     {
-        // return a copy to prevent modification
-        List answer = new ArrayList();
-
-        answer.addAll(_platforms.keySet());
-        return answer;
+        return (String[])getPlatforms().keySet().toArray(new String[0]);
     }
 
+    /**
+     * Determines whether the indicated platform is supported.
+     * 
+     * @param platformName The name of the platform
+     * @return <code>true</code> if the platform is supported
+     */
+    public static boolean isPlatformSupported(String platformName)
+    {
+        return getPlatforms().containsKey(platformName.toLowerCase());
+    }
 
     /**
      * Registers a new platform.
      * 
-     * @param databaseName  The database name
+     * @param platformName  The platform name
      * @param platformClass The platform class which must implement the {@link Platform}
interface
      */
-    public static synchronized void registerDatabase(String databaseName, Class platformClass)
+    public static synchronized void registerPlatform(String platformName, Class platformClass)
     {
-        if (!Platform.class.isAssignableFrom(platformClass))
-        {
-            throw new IllegalArgumentException("Cannot register class "+platformClass.getName()+"
because it does not implement the "+Platform.class.getName()+" interface");
-        }
-        _platforms.put(databaseName.toLowerCase(), platformClass);        
+        addPlatform(getPlatforms(), platformName, platformClass);
+    }
+
+    /**
+     * Registers the known platforms.
+     */
+    private static void registerPlatforms()
+    {
+        addPlatform(_platforms, AxionPlatform.DATABASENAME,      AxionPlatform.class);
+        addPlatform(_platforms, CloudscapePlatform.DATABASENAME, CloudscapePlatform.class);
+        addPlatform(_platforms, Db2Platform.DATABASENAME,        Db2Platform.class);
+        addPlatform(_platforms, DerbyPlatform.DATABASENAME,      DerbyPlatform.class);
+        addPlatform(_platforms, FirebirdPlatform.DATABASENAME,   FirebirdPlatform.class);
+        addPlatform(_platforms, HsqlDbPlatform.DATABASENAME,     HsqlDbPlatform.class);
+        addPlatform(_platforms, InterbasePlatform.DATABASENAME,  InterbasePlatform.class);
+        addPlatform(_platforms, MaxDbPlatform.DATABASENAME,      MaxDbPlatform.class);
+        addPlatform(_platforms, MckoiPlatform.DATABASENAME,      MckoiPlatform.class);
+        addPlatform(_platforms, MSSqlPlatform.DATABASENAME,      MSSqlPlatform.class);
+        addPlatform(_platforms, MySqlPlatform.DATABASENAME,      MySqlPlatform.class);
+        addPlatform(_platforms, Oracle8Platform.DATABASENAME,    Oracle8Platform.class);
+        addPlatform(_platforms, Oracle9Platform.DATABASENAME,    Oracle9Platform.class);
+        addPlatform(_platforms, PostgreSqlPlatform.DATABASENAME, PostgreSqlPlatform.class);
+        addPlatform(_platforms, SapDbPlatform.DATABASENAME,      SapDbPlatform.class);
+        addPlatform(_platforms, SybasePlatform.DATABASENAME,     SybasePlatform.class);
     }
 
     /**
-     * Registers the predefined builders.
+     * Registers a new platform.
+     * 
+     * @param platformMap   The map to add the platform info to 
+     * @param platformName  The platform name
+     * @param platformClass The platform class which must implement the {@link Platform}
interface
      */
-    protected static void registerDatabases()
+    private static synchronized void addPlatform(Map platformMap, String platformName, Class
platformClass)
     {
-        registerDatabase(AxionPlatform.DATABASENAME,      AxionPlatform.class);
-        registerDatabase(CloudscapePlatform.DATABASENAME, CloudscapePlatform.class);
-        registerDatabase(Db2Platform.DATABASENAME,        Db2Platform.class);
-        registerDatabase(DerbyPlatform.DATABASENAME,      DerbyPlatform.class);
-        registerDatabase(FirebirdPlatform.DATABASENAME,   FirebirdPlatform.class);
-        registerDatabase(HsqlDbPlatform.DATABASENAME,     HsqlDbPlatform.class);
-        registerDatabase(InterbasePlatform.DATABASENAME,  InterbasePlatform.class);
-        registerDatabase(MaxDbPlatform.DATABASENAME,      MaxDbPlatform.class);
-        registerDatabase(MckoiPlatform.DATABASENAME,      MckoiPlatform.class);
-        registerDatabase(MSSqlPlatform.DATABASENAME,      MSSqlPlatform.class);
-        registerDatabase(MySqlPlatform.DATABASENAME,      MySqlPlatform.class);
-        registerDatabase(Oracle8Platform.DATABASENAME,    Oracle8Platform.class);
-        registerDatabase(Oracle9Platform.DATABASENAME,    Oracle9Platform.class);
-        registerDatabase(PostgreSqlPlatform.DATABASENAME, PostgreSqlPlatform.class);
-        registerDatabase(SapDbPlatform.DATABASENAME,      SapDbPlatform.class);
-        registerDatabase(SybasePlatform.DATABASENAME,     SybasePlatform.class);
+        if (!Platform.class.isAssignableFrom(platformClass))
+        {
+            throw new IllegalArgumentException("Cannot register class "+platformClass.getName()+"
because it does not implement the "+Platform.class.getName()+" interface");
+        }
+        platformMap.put(platformName.toLowerCase(), platformClass);        
     }
 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/AxionPlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/AxionPlatform.java?rev=289458&r1=289457&r2=289458&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/AxionPlatform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/AxionPlatform.java Fri Sep 16
02:44:34 2005
@@ -69,9 +69,9 @@
     }
 
     /* (non-Javadoc)
-     * @see org.apache.ddlutils.Platform#getDatabaseName()
+     * @see org.apache.ddlutils.Platform#getName()
      */
-    public String getDatabaseName()
+    public String getName()
     {
         return DATABASENAME;
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/CloudscapePlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/CloudscapePlatform.java?rev=289458&r1=289457&r2=289458&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/CloudscapePlatform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/CloudscapePlatform.java Fri Sep
16 02:44:34 2005
@@ -71,9 +71,9 @@
     }
 
     /* (non-Javadoc)
-     * @see org.apache.ddlutils.builder.Platform#getDatabaseName()
+     * @see org.apache.ddlutils.builder.Platform#getName()
      */
-    public String getDatabaseName()
+    public String getName()
     {
         return DATABASENAME;
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/Db2Platform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/Db2Platform.java?rev=289458&r1=289457&r2=289458&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/Db2Platform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/Db2Platform.java Fri Sep 16 02:44:34
2005
@@ -74,9 +74,9 @@
     }
 
     /* (non-Javadoc)
-     * @see org.apache.ddlutils.builder.Platform#getDatabaseName()
+     * @see org.apache.ddlutils.builder.Platform#getName()
      */
-    public String getDatabaseName()
+    public String getName()
     {
         return DATABASENAME;
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/DerbyPlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/DerbyPlatform.java?rev=289458&r1=289457&r2=289458&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/DerbyPlatform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/DerbyPlatform.java Fri Sep 16
02:44:34 2005
@@ -42,9 +42,9 @@
     public static final String JDBC_SUBPROTOCOL     = "derby";
 
     /* (non-Javadoc)
-     * @see org.apache.ddlutils.builder.Platform#getDatabaseName()
+     * @see org.apache.ddlutils.builder.Platform#getName()
      */
-    public String getDatabaseName()
+    public String getName()
     {
         return DATABASENAME;
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/FirebirdPlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/FirebirdPlatform.java?rev=289458&r1=289457&r2=289458&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/FirebirdPlatform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/FirebirdPlatform.java Fri Sep
16 02:44:34 2005
@@ -32,9 +32,9 @@
     public static final String JDBC_SUBPROTOCOL = "firebirdsql";
 
     /* (non-Javadoc)
-     * @see org.apache.ddlutils.builder.Platform#getDatabaseName()
+     * @see org.apache.ddlutils.builder.Platform#getName()
      */
-    public String getDatabaseName()
+    public String getName()
     {
         return DATABASENAME;
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/HsqlDbPlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/HsqlDbPlatform.java?rev=289458&r1=289457&r2=289458&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/HsqlDbPlatform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/HsqlDbPlatform.java Fri Sep 16
02:44:34 2005
@@ -64,9 +64,9 @@
     }
 
     /* (non-Javadoc)
-     * @see org.apache.ddlutils.builder.Platform#getDatabaseName()
+     * @see org.apache.ddlutils.builder.Platform#getName()
      */
-    public String getDatabaseName()
+    public String getName()
     {
         return DATABASENAME;
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/InterbasePlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/InterbasePlatform.java?rev=289458&r1=289457&r2=289458&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/InterbasePlatform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/InterbasePlatform.java Fri Sep
16 02:44:34 2005
@@ -77,9 +77,9 @@
     }
 
     /* (non-Javadoc)
-     * @see org.apache.ddlutils.builder.Platform#getDatabaseName()
+     * @see org.apache.ddlutils.builder.Platform#getName()
      */
-    public String getDatabaseName()
+    public String getName()
     {
         return DATABASENAME;
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/MSSqlPlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/MSSqlPlatform.java?rev=289458&r1=289457&r2=289458&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/MSSqlPlatform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/MSSqlPlatform.java Fri Sep 16
02:44:34 2005
@@ -75,9 +75,9 @@
     }
 
     /* (non-Javadoc)
-     * @see org.apache.ddlutils.builder.Platform#getDatabaseName()
+     * @see org.apache.ddlutils.builder.Platform#getName()
      */
-    public String getDatabaseName()
+    public String getName()
     {
         return DATABASENAME;
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/MaxDbPlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/MaxDbPlatform.java?rev=289458&r1=289457&r2=289458&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/MaxDbPlatform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/MaxDbPlatform.java Fri Sep 16
02:44:34 2005
@@ -32,9 +32,9 @@
     public static final String DATABASENAME = "MaxDB";
 
     /* (non-Javadoc)
-     * @see org.apache.ddlutils.builder.Platform#getDatabaseName()
+     * @see org.apache.ddlutils.builder.Platform#getName()
      */
-    public String getDatabaseName()
+    public String getName()
     {
         return DATABASENAME;
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/MckoiPlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/MckoiPlatform.java?rev=289458&r1=289457&r2=289458&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/MckoiPlatform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/MckoiPlatform.java Fri Sep 16
02:44:34 2005
@@ -62,9 +62,9 @@
     }
 
     /* (non-Javadoc)
-     * @see org.apache.ddlutils.builder.Platform#getDatabaseName()
+     * @see org.apache.ddlutils.builder.Platform#getName()
      */
-    public String getDatabaseName()
+    public String getName()
     {
         return DATABASENAME;
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/MySqlPlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/MySqlPlatform.java?rev=289458&r1=289457&r2=289458&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/MySqlPlatform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/MySqlPlatform.java Fri Sep 16
02:44:34 2005
@@ -80,9 +80,9 @@
     }
 
     /* (non-Javadoc)
-     * @see org.apache.ddlutils.builder.Platform#getDatabaseName()
+     * @see org.apache.ddlutils.builder.Platform#getName()
      */
-    public String getDatabaseName()
+    public String getName()
     {
         return DATABASENAME;
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/Oracle8Platform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/Oracle8Platform.java?rev=289458&r1=289457&r2=289458&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/Oracle8Platform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/Oracle8Platform.java Fri Sep 16
02:44:34 2005
@@ -87,9 +87,9 @@
     }
 
     /* (non-Javadoc)
-     * @see org.apache.ddlutils.builder.Platform#getDatabaseName()
+     * @see org.apache.ddlutils.builder.Platform#getName()
      */
-    public String getDatabaseName()
+    public String getName()
     {
         return DATABASENAME;
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java?rev=289458&r1=289457&r2=289458&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java Fri Sep
16 02:44:34 2005
@@ -235,7 +235,7 @@
      */
     public void createDatabase(String jdbcDriverClassName, String connectionUrl, String username,
String password, Map parameters) throws DynaSqlException, UnsupportedOperationException
     {
-        throw new UnsupportedOperationException("Database creation is not supported for the
database platform "+getDatabaseName());
+        throw new UnsupportedOperationException("Database creation is not supported for the
database platform "+getName());
     }
 
     /* (non-Javadoc)
@@ -243,7 +243,7 @@
      */
     public void dropDatabase(String jdbcDriverClassName, String connectionUrl, String username,
String password) throws DynaSqlException, UnsupportedOperationException
     {
-        throw new UnsupportedOperationException("Database deletion is not supported for the
database platform "+getDatabaseName());
+        throw new UnsupportedOperationException("Database deletion is not supported for the
database platform "+getName());
     }
 
     /* (non-Javadoc)

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PostgreSqlPlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PostgreSqlPlatform.java?rev=289458&r1=289457&r2=289458&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PostgreSqlPlatform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PostgreSqlPlatform.java Fri Sep
16 02:44:34 2005
@@ -85,9 +85,9 @@
     }
 
     /* (non-Javadoc)
-     * @see org.apache.ddlutils.builder.Platform#getDatabaseName()
+     * @see org.apache.ddlutils.builder.Platform#getName()
      */
-    public String getDatabaseName()
+    public String getName()
     {
         return DATABASENAME;
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SapDbPlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SapDbPlatform.java?rev=289458&r1=289457&r2=289458&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SapDbPlatform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SapDbPlatform.java Fri Sep 16
02:44:34 2005
@@ -80,9 +80,9 @@
     }
 
     /* (non-Javadoc)
-     * @see org.apache.ddlutils.builder.Platform#getDatabaseName()
+     * @see org.apache.ddlutils.builder.Platform#getName()
      */
-    public String getDatabaseName()
+    public String getName()
     {
         return DATABASENAME;
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SybasePlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SybasePlatform.java?rev=289458&r1=289457&r2=289458&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SybasePlatform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SybasePlatform.java Fri Sep 16
02:44:34 2005
@@ -79,9 +79,9 @@
     }
 
     /* (non-Javadoc)
-     * @see org.apache.ddlutils.builder.Platform#getDatabaseName()
+     * @see org.apache.ddlutils.builder.Platform#getName()
      */
-    public String getDatabaseName()
+    public String getName()
     {
         return DATABASENAME;
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/task/CreateDatabaseCommand.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/task/CreateDatabaseCommand.java?rev=289458&r1=289457&r2=289458&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/task/CreateDatabaseCommand.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/task/CreateDatabaseCommand.java Fri Sep
16 02:44:34 2005
@@ -16,7 +16,10 @@
  * limitations under the License.
  */
 
-import org.apache.commons.collections.map.ListOrderedMap;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
 import org.apache.commons.dbcp.BasicDataSource;
 import org.apache.ddlutils.Platform;
 import org.apache.ddlutils.model.Database;
@@ -33,16 +36,16 @@
 public class CreateDatabaseCommand extends DatabaseCommand
 {
     /** The additional creation parameters */
-    private ListOrderedMap _parameters = new ListOrderedMap();
+    private ArrayList _parameters = new ArrayList();
 
     /**
      * Adds a parameter which is a name-value pair.
      * 
      * @param param The parameter
      */
-    public void addConfiguredParameter(NamedValue param)
+    public void addConfiguredParameter(Parameter param)
     {
-        _parameters.put(param.getName(), param.getValue());
+        _parameters.add(param);
     }
 
     /* (non-Javadoc)
@@ -58,20 +61,20 @@
         }
 
         Platform platform = getPlatform();
-
+        
         try
         {
             platform.createDatabase(dataSource.getDriverClassName(),
                                     dataSource.getUrl(),
                                     dataSource.getUsername(),
                                     dataSource.getPassword(),
-                                    _parameters);
+                                    getFilteredParameters(platform.getName()));
 
             task.log("Created database", Project.MSG_INFO);
         }
         catch (UnsupportedOperationException ex)
         {
-            task.log("Database platform "+getPlatform().getDatabaseName()+" does not support
database creation via JDBC", Project.MSG_ERR);
+            task.log("Database platform "+getPlatform().getName()+" does not support database
creation via JDBC", Project.MSG_ERR);
         }
         catch (Exception ex)
         {
@@ -84,5 +87,27 @@
                 task.log(ex.getLocalizedMessage(), Project.MSG_ERR);
             }
         }
+    }
+
+    /**
+     * Filters the parameters for the indicated platform.
+     * 
+     * @param platformName The name of the platform
+     * @return The filtered parameters
+     */
+    private Map getFilteredParameters(String platformName)
+    {
+        LinkedHashMap parameters = new LinkedHashMap();
+
+        for (Iterator it = _parameters.iterator(); it.hasNext();)
+        {
+            Parameter param = (Parameter)it.next();
+
+            if (param.isForPlatform(platformName))
+            {
+                parameters.put(param.getName(), param.getValue());
+            }
+        }
+        return parameters;
     }
 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DropDatabaseCommand.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DropDatabaseCommand.java?rev=289458&r1=289457&r2=289458&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DropDatabaseCommand.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DropDatabaseCommand.java Fri Sep 16
02:44:34 2005
@@ -53,7 +53,7 @@
         }
         catch (UnsupportedOperationException ex)
         {
-            task.log("Database platform "+getPlatform().getDatabaseName()+" does not support
database dropping via JDBC", Project.MSG_ERR);
+            task.log("Database platform "+getPlatform().getName()+" does not support database
dropping via JDBC", Project.MSG_ERR);
         }
         catch (Exception ex)
         {

Copied: db/ddlutils/trunk/src/java/org/apache/ddlutils/task/Parameter.java (from r289427,
db/ddlutils/trunk/src/java/org/apache/ddlutils/task/NamedValue.java)
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/task/Parameter.java?p2=db/ddlutils/trunk/src/java/org/apache/ddlutils/task/Parameter.java&p1=db/ddlutils/trunk/src/java/org/apache/ddlutils/task/NamedValue.java&r1=289427&r2=289458&rev=289458&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/task/NamedValue.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/task/Parameter.java Fri Sep 16 02:44:34
2005
@@ -1,17 +1,25 @@
 package org.apache.ddlutils.task;
 
+import java.util.HashSet;
+import java.util.Set;
+import java.util.StringTokenizer;
+import org.apache.ddlutils.PlatformFactory;
+
 /**
- * A name-value pair.
+ * A parameter which consists of a name-value pair and an optional list of platforms
+ * for which the parameter is applicable.
  * 
  * @author <a href="mailto:tomdz@apache.org">Thomas Dudziak</a>
  * @version $Revision: 231306 $
  */
-public class NamedValue
+public class Parameter
 {
     /** The name */
     private String _name;
     /** The value */
     private String _value;
+    /** The platforms for which this parameter is applicable */
+    private Set _platforms = new HashSet();
 
     /**
      * Returns the name.
@@ -51,5 +59,44 @@
     public void setValue(String value)
     {
         _value = value;
+    }
+
+    /**
+     * Sets the platforms - a comma-separated list of platform names - for which this parameter
shall be used.
+     * 
+     * @param platforms The platforms
+     */
+    public void setPlatforms(String platforms)
+    {
+        _platforms.clear();
+        if (platforms != null)
+        {
+            StringTokenizer tokenizer = new StringTokenizer(platforms, ",");
+
+            while (tokenizer.hasMoreTokens())
+            {
+                String platform = tokenizer.nextToken().trim();
+
+                if (PlatformFactory.isPlatformSupported(platform))
+                {
+                    _platforms.add(platform.toLowerCase());
+                }
+                else
+                {
+                    throw new IllegalArgumentException("Platform "+platform+" is not supported");
+                }
+            }
+        }
+    }
+
+    /**
+     * Determines whether this parameter is applicable for the indicated platform.
+     * 
+     * @param platformName The platform name
+     * @return <code>true</code> if this parameter is defined for the platform
+     */
+    public boolean isForPlatform(String platformName)
+    {
+        return _platforms.isEmpty() || _platforms.contains(platformName.toLowerCase());
     }
 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteDataToSpecifiedDatabaseCommand.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteDataToSpecifiedDatabaseCommand.java?rev=289458&r1=289457&r2=289458&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteDataToSpecifiedDatabaseCommand.java
(original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteDataToSpecifiedDatabaseCommand.java
Fri Sep 16 02:44:34 2005
@@ -138,7 +138,7 @@
             }
             catch (Exception ex)
             {
-                throw new BuildException("Could not read data file "+schemaFile.getAbsolutePath(),
ex);
+                throw new BuildException("Could not read data file "+schemaFile.getAbsolutePath()+":
"+ex.getLocalizedMessage(), ex);
             }
         }
     }



Mime
View raw message