cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r887949 - in /cayenne/main/trunk: docs/doc/src/main/resources/UPGRADE.txt framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/XMLDataChannelDescriptorLoaderAction.java
Date Mon, 07 Dec 2009 15:19:01 GMT
Author: aadamchik
Date: Mon Dec  7 15:19:01 2009
New Revision: 887949

URL: http://svn.apache.org/viewvc?rev=887949&view=rev
Log:
CAY-1319 Switch Cayenne configuration loading to cayenne-di container

* Adding a converter of the legacy DataSourceFactory names
* Upgrade instrcutions for custom factories

Modified:
    cayenne/main/trunk/docs/doc/src/main/resources/UPGRADE.txt
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/XMLDataChannelDescriptorLoaderAction.java

Modified: cayenne/main/trunk/docs/doc/src/main/resources/UPGRADE.txt
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/doc/src/main/resources/UPGRADE.txt?rev=887949&r1=887948&r2=887949&view=diff
==============================================================================
--- cayenne/main/trunk/docs/doc/src/main/resources/UPGRADE.txt (original)
+++ cayenne/main/trunk/docs/doc/src/main/resources/UPGRADE.txt Mon Dec  7 15:19:01 2009
@@ -8,6 +8,23 @@
   using removed EntityUtil methods (those were replaced by variables placed directly into
   Velocity context)
 
+* Custom DataSourceFactory: The interface used by Cayenne to load custom DataSource factories
has changed
+  from org.apache.cayenne.conf.DataSourceFactory to org.apache.cayenne.configuration.DataSourceFactory.

+  This new interface must be implemented by the custom factories. Note that now custom
+  implementations can rely on Cayenne to inject dependencies into them using @Inject annotation.
+
+* Custom DbAdapter / DbAdapterFactory: The interface used by Cayenne to allow custom DbAdapters
to be auto-detected 
+  with AutoAdapter has changed from org.apache.cayenne.dba.DbAdapterFactory to org.apache.cayenne.configuration.DbAdapterDetector.

+  Note that now custom implementations can rely on Cayenne to inject dependencies into them
using @Inject annotation.
+  To register a custom implementation with Cayenne DI container, one might do this in the
custom DI module:
+
+  ... 
+  public void configure(Binder binder) {
+  ...
+     binder.bindList(DbAdapterFactory.class).add(new MyDbAdapterDetector());
+  }
+
+
 UPGRADING FROM 3.0M6
 
 * Per CAY-1281 pre-persist callback was renamed to post-add (while pre-persist now has a
different meaning).

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/XMLDataChannelDescriptorLoaderAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/XMLDataChannelDescriptorLoaderAction.java?rev=887949&r1=887948&r2=887949&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/XMLDataChannelDescriptorLoaderAction.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/XMLDataChannelDescriptorLoaderAction.java
Mon Dec  7 15:19:01 2009
@@ -21,6 +21,8 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
 
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.map.DataMap;
@@ -46,6 +48,21 @@
     static final String PROPERTY_TAG = "property";
     static final String MAP_REF_TAG = "map-ref";
 
+    private static final Map<String, String> dataSourceFactoryNameMapping;
+
+    static {
+        dataSourceFactoryNameMapping = new HashMap<String, String>();
+        dataSourceFactoryNameMapping.put(
+                "org.apache.cayenne.conf.DriverDataSourceFactory",
+                XMLPoolingDataSourceFactory.class.getName());
+        dataSourceFactoryNameMapping.put(
+                "org.apache.cayenne.conf.JNDIDataSourceFactory",
+                JNDIDataSourceFactory.class.getName());
+        dataSourceFactoryNameMapping.put(
+                "org.apache.cayenne.conf.DBCPDataSourceFactory",
+                DBCPDataSourceFactory.class.getName());
+    }
+
     private DataMapLoader mapLoader;
     private Log logger;
 
@@ -96,6 +113,20 @@
         return descriptor;
     }
 
+    /**
+     * Converts the names of standard Cayenne-supplied DataSourceFactories from the legacy
+     * names to the current names.
+     */
+    private String convertDataSourceFactory(String dataSourceFactory) {
+
+        if (dataSourceFactory == null) {
+            return null;
+        }
+
+        String converted = dataSourceFactoryNameMapping.get(dataSourceFactory);
+        return converted != null ? converted : dataSourceFactory;
+    }
+
     final class DataChannelHandler extends SAXNestedTagHandler {
 
         private DataChannelDescriptor descriptor;
@@ -167,12 +198,12 @@
                 nodeDescriptor.setName(nodeName);
                 nodeDescriptor.setAdapterType(attributes.getValue("", "adapter"));
 
-                // TODO: andrus, 11.29.2009 : should we rename that to "location"??
                 String location = attributes.getValue("", "datasource");
                 nodeDescriptor.setLocation(location);
 
-                nodeDescriptor.setDataSourceFactoryType(attributes
-                        .getValue("", "factory"));
+                String dataSourceFactory = attributes.getValue("", "factory");
+                nodeDescriptor
+                        .setDataSourceFactoryType(convertDataSourceFactory(dataSourceFactory));
                 nodeDescriptor.setSchemaUpdateStrategyType(attributes.getValue(
                         "",
                         "schema-update-strategy"));



Mime
View raw message