cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1180407 - /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/JdbcAdapter.java
Date Sat, 08 Oct 2011 16:39:21 GMT
Author: aadamchik
Date: Sat Oct  8 16:39:20 2011
New Revision: 1180407

URL: http://svn.apache.org/viewvc?rev=1180407&view=rev
Log:
CAY-1603 Improve custom ExtendedType registration API

refactoring of the patch

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/JdbcAdapter.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/JdbcAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/JdbcAdapter.java?rev=1180407&r1=1180406&r2=1180407&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/JdbcAdapter.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/JdbcAdapter.java
Sat Oct  8 16:39:20 2011
@@ -81,10 +81,6 @@ public class JdbcAdapter implements DbAd
     protected String identifiersStartQuote;
     protected String identifiersEndQuote;
     
-    protected List<ExtendedType> defaultExtendedTypes;
-    protected List<ExtendedType> userExtendedTypes;
-    protected List<ExtendedTypeFactory> extendedTypeFactories;
-
     protected ResourceLocator resourceLocator;
     protected RuntimeProperties runtimeProperties;
 
@@ -118,11 +114,7 @@ public class JdbcAdapter implements DbAd
             @Inject(DEFAULT_EXTENDED_TYPE_LIST) List<ExtendedType> defaultExtendedTypes,
             @Inject(USER_EXTENDED_TYPE_LIST) List<ExtendedType> userExtendedTypes,
             @Inject(EXTENDED_TYPE_FACTORY_LIST) List<ExtendedTypeFactory> extendedTypeFactories)
{
-        
-        this.defaultExtendedTypes = defaultExtendedTypes;
-        this.userExtendedTypes = userExtendedTypes;
-        this.extendedTypeFactories = extendedTypeFactories;
-        
+
         // init defaults
         this.setSupportsBatchUpdates(false);
         this.setSupportsUniqueConstraints(true);
@@ -130,12 +122,12 @@ public class JdbcAdapter implements DbAd
 
         // TODO: andrus 05.02.2010 - ideally this should be injected
         this.resourceLocator = new ClassLoaderResourceLocator();
-        
+
         this.pkGenerator = createPkGenerator();
         this.ejbqlTranslatorFactory = createEJBQLTranslatorFactory();
         this.typesHandler = TypesHandler.getHandler(findResource("/types.xml"));
         this.extendedTypes = new ExtendedTypeMap();
-        this.initExtendedTypes();
+        initExtendedTypes(defaultExtendedTypes, userExtendedTypes, extendedTypeFactories);
         initIdentifiersQuotes();
     }
 
@@ -185,22 +177,30 @@ public class JdbcAdapter implements DbAd
     }
 
     /**
-     * Installs appropriate ExtendedTypes as converters for passing values between JDBC
-     * and Java layers. Called from default constructor.
+     * Called from {@link #initExtendedTypes(List, List, List)} to load adapter-specific
+     * types into the ExtendedTypeMap right after the default types are loaded, but before
+     * the DI overrides are. This method has specific implementations in JdbcAdapter
+     * subclasses.
      */
     protected void configureExtendedTypes(ExtendedTypeMap map) {
         // noop... subclasses may override to install custom types
     }
     
-    protected void initExtendedTypes() {
+    /**
+     * @since 3.1
+     */
+    protected void initExtendedTypes(
+            List<ExtendedType> defaultExtendedTypes,
+            List<ExtendedType> userExtendedTypes,
+            List<ExtendedTypeFactory> extendedTypeFactories) {
         for (ExtendedType type : defaultExtendedTypes) {
             extendedTypes.registerType(type);
         }
-        
+
         // loading adapter specific extended types
         configureExtendedTypes(extendedTypes);
-        
-        for (ExtendedType type: userExtendedTypes) {
+
+        for (ExtendedType type : userExtendedTypes) {
             extendedTypes.registerType(type);
         }
         for (ExtendedTypeFactory typeFactory : extendedTypeFactories) {



Mime
View raw message