cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r503690 - in /cayenne/main/trunk/framework/cayenne-jpa-unpublished/src: main/java/org/apache/cayenne/jpa/ main/java/org/apache/cayenne/jpa/conf/ test/java/org/apache/cayenne/jpa/conf/
Date Mon, 05 Feb 2007 14:07:52 GMT
Author: aadamchik
Date: Mon Feb  5 06:07:51 2007
New Revision: 503690

URL: http://svn.apache.org/viewvc?view=rev&rev=503690
Log:
Renaming custom Provider JPA keys to comply with the spec rules, namely, the property name
prefix must be org.apache.cayenne

Removed:
    cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/test/java/org/apache/cayenne/jpa/conf/DefaultDataSourceFactoryTest.java
Modified:
    cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/JpaUnit.java
    cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/Provider.java
    cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/conf/DefaultDataSourceFactory.java

Modified: cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/JpaUnit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/JpaUnit.java?view=diff&rev=503690&r1=503689&r2=503690
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/JpaUnit.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/JpaUnit.java
Mon Feb  5 06:07:51 2007
@@ -32,7 +32,6 @@
 import javax.persistence.spi.PersistenceUnitTransactionType;
 import javax.sql.DataSource;
 
-import org.apache.cayenne.jpa.conf.DefaultDataSourceFactory;
 import org.apache.cayenne.jpa.conf.JpaDataSourceFactory;
 import org.apache.cayenne.jpa.conf.JpaUnitFactory;
 
@@ -55,16 +54,6 @@
 
     // properties not exposed directly
     protected ClassLoader classLoader;
-
-    /**
-     * Builds a DataSource-specific property name for a generic property name.
-     */
-    public static String getDataSourcePropertyName(String dataSourceName, String suffix)
{
-        return DefaultDataSourceFactory.DATA_SOURCE_PREFIX
-                + dataSourceName
-                + "."
-                + suffix;
-    }
 
     public JpaUnit() {
 

Modified: cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/Provider.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/Provider.java?view=diff&rev=503690&r1=503689&r2=503690
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/Provider.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/Provider.java
Mon Feb  5 06:07:51 2007
@@ -79,11 +79,25 @@
     public static final String NON_JTA_DATA_SOURCE_PROPERTY = "javax.persistence.nonJtaDataSource";
 
     // provider-specific properties. Must use provider namespace per ch. 7.1.3.1.
+    public static final String CREATE_SCHEMA_PROPERTY = "org.apache.cayenne.schema.create";
     public static final String DATA_SOURCE_FACTORY_PROPERTY = "org.apache.cayenne.jpa.jpaDataSourceFactory";
     public static final String UNIT_FACTORY_PROPERTY = "org.apache.cayenne.jpa.jpaUnitFactory";
-    public static final String CREATE_SCHEMA_PROPERTY = "cayenne.schema.create";
 
-    public static final String INSTRUMENTING_FACTORY_CLASS = InstrumentingUnitFactory.class
+    // ... DataSource
+    public static final String ADAPTER_PROPERTY = "org.apache.cayenne."
+            + ConnectionProperties.ADAPTER_KEY;
+    public static final String DATA_SOURCE_DRIVER_PROPERTY = "org.apache.cayenne.datasource."
+            + ConnectionProperties.DRIVER_KEY;
+    public static final String DATA_SOURCE_URL_PROPERTY = "org.apache.cayenne.datasource."
+            + ConnectionProperties.URL_KEY;
+    public static final String DATA_SOURCE_USER_NAME_PROPERTY = "org.apache.cayenne.datasource."
+            + ConnectionProperties.USER_NAME_KEY;
+    public static final String DATA_SOURCE_PASSWORD_PROPERTY = "org.apache.cayenne.datasource."
+            + ConnectionProperties.PASSWORD_KEY;
+    public static final String DATA_SOURCE_MIN_CONNECTIONS_PROPERTY = "org.apache.cayenne.datasource.jdbc.minConnections";
+    public static final String DATA_SOURCE_MAX_CONNECTIONS_PROPERTY = "org.apache.cayenne.datasource.jdbc.maxConnections";
+
+    static final String INSTRUMENTING_FACTORY_CLASS = InstrumentingUnitFactory.class
             .getName();
 
     protected boolean validateDescriptors;
@@ -375,9 +389,7 @@
             EntityMapLoaderContext context,
             PersistenceUnitInfo info) {
 
-        String adapterKey = JpaUnit.getDataSourcePropertyName(info
-                .getPersistenceUnitName(), ConnectionProperties.ADAPTER_KEY);
-        String adapterClass = info.getProperties().getProperty(adapterKey);
+        String adapterClass = info.getProperties().getProperty(ADAPTER_PROPERTY);
 
         if (Util.isEmptyString(adapterClass)) {
             return null;

Modified: cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/conf/DefaultDataSourceFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/conf/DefaultDataSourceFactory.java?view=diff&rev=503690&r1=503689&r2=503690
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/conf/DefaultDataSourceFactory.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/conf/DefaultDataSourceFactory.java
Mon Feb  5 06:07:51 2007
@@ -29,10 +29,9 @@
 
 import org.apache.cayenne.access.ConnectionLogger;
 import org.apache.cayenne.access.QueryLogger;
-import org.apache.cayenne.conf.ConnectionProperties;
 import org.apache.cayenne.conn.PoolManager;
 import org.apache.cayenne.jpa.JpaProviderException;
-import org.apache.cayenne.jpa.JpaUnit;
+import org.apache.cayenne.jpa.Provider;
 import org.apache.cayenne.util.Util;
 
 /**
@@ -41,32 +40,21 @@
  * obtained via JNDI.
  * <p>
  * Properties are specified in the corresponding section of the <em>persistence.xml</em>
- * file. All property names related to a given named DataSource must be prefixed with
- * <em>"CayenneDataSource.[datasource name]."</em>. The following properties
are
- * supported:
+ * file. The following properties are supported:
  * </p>
  * <ul>
- * <li>cayenne.ds.[datasource name].jdbc.driver - (required) JDBC driver class</li>
- * <li>cayenne.ds.[datasource name].jdbc.url - (required) Database URL</li>
- * <li>cayenne.ds.[datasource name].jdbc.username - Database login id</li>
- * <li>cayenne.ds.[datasource name].jdbc.password - Database password</li>
- * <li>cayenne.ds.[datasource name].jdbc.minConnections - (optional) Minimal pool size</li>
- * <li>cayenne.ds.[datasource name].jdbc.maxConnections - (optional) Maximum pool size</li>
+ * <li>org.apache.cayenne.datasource.jdbc.driver - (required) JDBC driver class</li>
+ * <li>org.apache.cayenne.datasource.jdbc.url - (required) Database URL</li>
+ * <li>org.apache.cayenne.datasource.jdbc.username - Database login id</li>
+ * <li>org.apache.cayenne.datasource.jdbc.password - Database password</li>
+ * <li>org.apache.cayenne.datasource.jdbc.minConnections - (optional) Minimal pool
size</li>
+ * <li>org.apache.cayenne.datasource..jdbc.maxConnections - (optional) Maximum pool
size</li>
  * </ul>
- * <p>
- * Another optional property is <em>cayenne.ds.[datasource name].cayenne.adapter</em>.
- * It is not strictly related to the DataSource configuration, but Cayenne provider will
- * use to configure the same {@link org.apache.cayenne.access.DataNode} that will use the
- * DataSource. If not set, an AutoAdapter is used.
  * 
  * @author Andrus Adamchik
  */
 public class DefaultDataSourceFactory implements JpaDataSourceFactory {
 
-    public static final String DATA_SOURCE_PREFIX = "cayenne.ds.";
-    public static final String MIN_CONNECTIONS_SUFFIX = "jdbc.minConnections";
-    public static final String MAX_CONNECTIONS_SUFFIX = "jdbc.maxConnections";
-
     public DataSource getJtaDataSource(String name, PersistenceUnitInfo info) {
         return getDataSource(name, info);
     }
@@ -99,12 +87,12 @@
 
     protected DataSource getCayenneDataSource(String name, Properties properties) {
 
-        String driverName = properties.getProperty(getDriverKey(name));
+        String driverName = properties.getProperty(Provider.DATA_SOURCE_DRIVER_PROPERTY);
         if (Util.isEmptyString(driverName)) {
             return null;
         }
 
-        String url = properties.getProperty(getUrlKey(name));
+        String url = properties.getProperty(Provider.DATA_SOURCE_URL_PROPERTY);
         if (Util.isEmptyString(url)) {
             return null;
         }
@@ -112,7 +100,7 @@
         int minConnection;
         try {
             minConnection = Integer.parseInt(properties
-                    .getProperty(getMinConnectionsKey(name)));
+                    .getProperty(Provider.DATA_SOURCE_MIN_CONNECTIONS_PROPERTY));
         }
         catch (Exception e) {
             minConnection = 1;
@@ -121,7 +109,7 @@
         int maxConnection;
         try {
             maxConnection = Integer.parseInt(properties
-                    .getProperty(getMaxConnectionsKey(name)));
+                    .getProperty(Provider.DATA_SOURCE_MAX_CONNECTIONS_PROPERTY));
         }
         catch (Exception e) {
             maxConnection = 1;
@@ -134,37 +122,13 @@
                     url,
                     minConnection,
                     maxConnection,
-                    properties.getProperty(getUserKey(name)),
-                    properties.getProperty(getPasswordKey(name)),
+                    properties.getProperty(Provider.DATA_SOURCE_USER_NAME_PROPERTY),
+                    properties.getProperty(Provider.DATA_SOURCE_PASSWORD_PROPERTY),
                     new ConnectionLogger());
         }
         catch (SQLException e) {
             QueryLogger.logConnectFailure(e);
             throw new JpaProviderException("Error creating connection pool", e);
         }
-    }
-
-    protected String getDriverKey(String dataSourceName) {
-        return JpaUnit.getDataSourcePropertyName(dataSourceName, ConnectionProperties.DRIVER_KEY);
-    }
-
-    protected String getUrlKey(String dataSourceName) {
-        return JpaUnit.getDataSourcePropertyName(dataSourceName, ConnectionProperties.URL_KEY);
-    }
-
-    protected String getUserKey(String dataSourceName) {
-        return JpaUnit.getDataSourcePropertyName(dataSourceName, ConnectionProperties.USER_NAME_KEY);
-    }
-
-    protected String getPasswordKey(String dataSourceName) {
-        return JpaUnit.getDataSourcePropertyName(dataSourceName, ConnectionProperties.PASSWORD_KEY);
-    }
-
-    protected String getMinConnectionsKey(String dataSourceName) {
-        return JpaUnit.getDataSourcePropertyName(dataSourceName, MIN_CONNECTIONS_SUFFIX);
-    }
-
-    protected String getMaxConnectionsKey(String dataSourceName) {
-        return JpaUnit.getDataSourcePropertyName(dataSourceName, MAX_CONNECTIONS_SUFFIX);
     }
 }



Mime
View raw message