cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r811178 - in /cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type: AbstractTypeCreator.java TypeClassInfo.java XMLTypeCreator.java java5/Java5TypeCreator.java
Date Fri, 04 Sep 2009 00:02:53 GMT
Author: bimargulies
Date: Fri Sep  4 00:02:53 2009
New Revision: 811178

URL: http://svn.apache.org/viewvc?rev=811178&view=rev
Log:
Clarify slot in TypeClassInfo for explicit spec of the Aegis type.

Modified:
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/AbstractTypeCreator.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeClassInfo.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/XMLTypeCreator.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/Java5TypeCreator.java

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/AbstractTypeCreator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/AbstractTypeCreator.java?rev=811178&r1=811177&r2=811178&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/AbstractTypeCreator.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/AbstractTypeCreator.java
Fri Sep  4 00:02:53 2009
@@ -105,7 +105,7 @@
         AegisType result = null;
         boolean newType = true;
 
-        if (info.getType() != null) {
+        if (info.getAegisTypeClass() != null) {
             result = createUserType(info);
         } else if (isArray(javaType)) {
             result = createArrayType(info);
@@ -167,7 +167,7 @@
 
     protected AegisType createUserType(TypeClassInfo info) {
         try {
-            AegisType type = (AegisType)info.getType().newInstance();
+            AegisType type = info.getAegisTypeClass().newInstance();
 
             QName name = info.getTypeName();
             if (name == null) {
@@ -191,9 +191,11 @@
 
             return type;
         } catch (InstantiationException e) {
-            throw new DatabindingException("Couldn't instantiate type classs " + info.getType().getName(),
e);
+            throw new DatabindingException("Couldn't instantiate type classs " 
+                                           + info.getAegisTypeClass().getName(), e);
         } catch (IllegalAccessException e) {
-            throw new DatabindingException("Couldn't access type classs " + info.getType().getName(),
e);
+            throw new DatabindingException("Couldn't access type classs " 
+                                           + info.getAegisTypeClass().getName(), e);
         }
     }
 

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeClassInfo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeClassInfo.java?rev=811178&r1=811177&r2=811178&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeClassInfo.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeClassInfo.java
Fri Sep  4 00:02:53 2009
@@ -22,11 +22,11 @@
 import javax.xml.namespace.QName;
 
 /**
- * Object to carry information for a type, such as that from an XML mapping file.
+ * Object to carry information for a aegisTypeClass, such as that from an XML mapping file.
  * 
  * Note that this class has a misleading name. It is used both for 
- * type information that corresponds to a type, and also for parameters 
- * of methods and elements of beans. When describing a top-level type,
+ * aegisTypeClass information that corresponds to a aegisTypeClass, and also for parameters

+ * of methods and elements of beans. When describing a top-level aegisTypeClass,
  * minOccurs and maxOccurs are not meaningful. Nillable is only used for
  * parameters. It might be that the code could be deconfused by
  * using the nillable property in here for the non-parameters cases
@@ -49,7 +49,9 @@
     private Object valueType;
     private QName mappedName;
     private QName typeName;
-    private Class type;
+    // a Class reference to the aegis aegisTypeClass, if the app has specified it
+    // via XML or via an annotation.
+    private Class<? extends AegisType> aegisTypeClass;
     private String description;
     private long minOccurs = -1;
     private long maxOccurs = -1;
@@ -109,12 +111,12 @@
         this.typeName = name;
     }
 
-    public Class getType() {
-        return type;
+    public Class<? extends AegisType> getAegisTypeClass() {
+        return aegisTypeClass;
     }
 
-    public void setType(Class type) {
-        this.type = type;
+    public void setAegisTypeClass(Class<? extends AegisType> aegisTypeClass) {
+        this.aegisTypeClass = aegisTypeClass;
     }
 
     public QName getMappedName() {

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/XMLTypeCreator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/XMLTypeCreator.java?rev=811178&r1=811177&r2=811178&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/XMLTypeCreator.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/XMLTypeCreator.java
Fri Sep  4 00:02:53 2009
@@ -54,6 +54,7 @@
 import org.apache.cxf.aegis.DatabindingException;
 import org.apache.cxf.aegis.type.basic.BeanType;
 import org.apache.cxf.aegis.type.basic.XMLBeanTypeInfo;
+import org.apache.cxf.aegis.type.java5.Java5TypeCreator;
 import org.apache.cxf.aegis.util.NamespaceHelper;
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.logging.LogUtils;
@@ -575,7 +576,8 @@
         String type = DOMUtils.getAttributeValueEmptyNull(parameter, "type");
         if (type != null) {
             try {
-                info.setType(ClassLoaderUtils.loadClass(type, getClass()));
+                Class aegisTypeClass = ClassLoaderUtils.loadClass(type, getClass()); 
+                info.setAegisTypeClass(Java5TypeCreator.castToAegisTypeClass(aegisTypeClass));
             } catch (ClassNotFoundException e) {
                 throw new DatabindingException("Unable to load type class " + type, e);
             }

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/Java5TypeCreator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/Java5TypeCreator.java?rev=811178&r1=811177&r2=811178&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/Java5TypeCreator.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/Java5TypeCreator.java
Fri Sep  4 00:02:53 2009
@@ -27,6 +27,7 @@
 
 import javax.xml.namespace.QName;
 
+import org.apache.cxf.aegis.DatabindingException;
 import org.apache.cxf.aegis.type.AbstractTypeCreator;
 import org.apache.cxf.aegis.type.AegisType;
 import org.apache.cxf.aegis.type.TypeClassInfo;
@@ -44,6 +45,18 @@
     public Java5TypeCreator(AnnotationReader annotationReader) {
         this.annotationReader = annotationReader;
     }
+    
+    @SuppressWarnings("unchecked")
+    public static Class<? extends AegisType> castToAegisTypeClass(Class<?> c)
{
+        if (c == null) {
+            return null;
+        }
+        if (AegisType.class.isAssignableFrom(c)) {
+            return (Class<? extends AegisType>)c;
+        } else {
+            throw new DatabindingException("Invalid Aegis type annotation to non-type class"
+ c);
+        }
+    }
 
     @Override
     public TypeClassInfo createClassInfo(Method m, int index) {
@@ -59,7 +72,9 @@
             }
             info.setTypeClass(m.getParameterTypes()[index]);
 
-            info.setType(annotationReader.getParamType(m, index));
+            Class paramTypeClass = annotationReader.getParamType(m, index);
+
+            info.setAegisTypeClass(castToAegisTypeClass(paramTypeClass));
 
             String paramName = annotationReader.getParamName(m, index);
             if (paramName != null) {
@@ -86,7 +101,7 @@
                 info.setAnnotations(m.getAnnotations());
             }
 
-            info.setType(annotationReader.getReturnType(m));
+            info.setAegisTypeClass(castToAegisTypeClass(annotationReader.getReturnType(m)));
 
             String returnName = annotationReader.getReturnName(m);
             if (returnName != null) {
@@ -104,7 +119,7 @@
         TypeClassInfo info = createBasicClassInfo(pd.getPropertyType());
         info.setGenericType(pd.getReadMethod().getGenericReturnType());
         info.setAnnotations(pd.getReadMethod().getAnnotations());
-        info.setType(annotationReader.getType(pd.getReadMethod()));
+        info.setAegisTypeClass(castToAegisTypeClass(annotationReader.getType(pd.getReadMethod())));
 
         return info;
     }



Mime
View raw message