cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r439596 - in /incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src: main/java/org/apache/cayenne/access/types/ test/java/org/apache/cayenne/access/types/
Date Sat, 02 Sep 2006 13:39:26 GMT
Author: aadamchik
Date: Sat Sep  2 06:39:26 2006
New Revision: 439596

URL: http://svn.apache.org/viewvc?rev=439596&view=rev
Log:
CAY-648

Modified:
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/types/ExtendedTypeMap.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/types/SerializableTypeFactory.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/types/ExtendedTypeMapTst.java

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/types/ExtendedTypeMap.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/types/ExtendedTypeMap.java?rev=439596&r1=439595&r2=439596&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/types/ExtendedTypeMap.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/types/ExtendedTypeMap.java
Sat Sep  2 06:39:26 2006
@@ -168,7 +168,7 @@
      * <i>Note that for array types class name must be in the form 'MyClass[]'</i>.
      */
     public ExtendedType getRegisteredType(String javaClassName) {
-        ExtendedType type = (ExtendedType) typeMap.get(javaClassName);
+        ExtendedType type = getExplictlyRegisteredType(javaClassName);
 
         if (type != null) {
             return type;
@@ -183,6 +183,10 @@
         }
 
         return getDefaultType();
+    }
+    
+    ExtendedType getExplictlyRegisteredType(String className) {
+        return (ExtendedType) typeMap.get(className);
     }
 
     /**

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/types/SerializableTypeFactory.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/types/SerializableTypeFactory.java?rev=439596&r1=439595&r2=439596&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/types/SerializableTypeFactory.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/types/SerializableTypeFactory.java
Sat Sep  2 06:39:26 2006
@@ -48,7 +48,23 @@
     public ExtendedType getType(Class objectClass) {
 
         if (Serializable.class.isAssignableFrom(objectClass)) {
-            return new SerializableType(objectClass);
+
+            // using a binary stream delegate instead of byte[] may actually speed up
+            // things in some dbs, but at least byte[] type works consistently across
+            // adapters...
+
+            // note - can't use "getRegisteredType" as it causes infinite recursion
+            ExtendedType bytesType = map.getExplictlyRegisteredType("byte[]");
+
+            // not sure if this type of recursion can occur, still worth checking
+            if (bytesType instanceof SerializableType) {
+                throw new IllegalStateException(
+                        "Can't create Serializable ExtendedType for "
+                                + objectClass.getName()
+                                + ": no ExtendedType exists for byte[]");
+            }
+
+            return new SerializableType(objectClass, bytesType);
         }
 
         return null;
@@ -62,19 +78,9 @@
         private Class javaClass;
         private ExtendedType bytesType;
 
-        SerializableType(Class javaClass) {
+        SerializableType(Class javaClass, ExtendedType bytesType) {
             this.javaClass = javaClass;
-
-            // using a binary stream delegate instead of byte[] may actually speed up
-            // things in some dbs, but at least byte[] type works consistently across
-            // adapters...
-
-            this.bytesType = map.getRegisteredType(byte[].class);
-
-            // not sure if this condition ever occurs, but still worth checking...
-            if (bytesType instanceof SerializableType) {
-                throw new IllegalStateException("No ExtendedType exists for byte[]");
-            }
+            this.bytesType = bytesType;
         }
 
         public String getClassName() {

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/types/ExtendedTypeMapTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/types/ExtendedTypeMapTst.java?rev=439596&r1=439595&r2=439596&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/types/ExtendedTypeMapTst.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/types/ExtendedTypeMapTst.java
Sat Sep  2 06:39:26 2006
@@ -45,7 +45,13 @@
         assertSame(tstType, map.getRegisteredType(byte[].class));
 
         map.unregisterType(tstType.getClassName());
-        assertSame(map.getDefaultType(), map.getRegisteredType(tstType.getClassName()));
+
+        // will return serializable ExtendedType inner class
+        assertTrue(map
+                .getRegisteredType(tstType.getClassName())
+                .getClass()
+                .getName()
+                .indexOf("SerializableTypeFactory") > 0);
     }
 
     public void testRegisteredTypeName() throws Exception {



Mime
View raw message