You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by bi...@apache.org on 2009/02/21 20:49:06 UTC
svn commit: r746572 -
/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
Author: bimargulies
Date: Sat Feb 21 19:49:05 2009
New Revision: 746572
URL: http://svn.apache.org/viewvc?rev=746572&view=rev
Log:
Cleanup inspired by CXF-2044.
Modified:
cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java?rev=746572&r1=746571&r2=746572&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java Sat Feb 21 19:49:05 2009
@@ -56,8 +56,12 @@
/**
* Serializes JavaBeans.
*
- * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
- * @author <a href="mailto:jack.xu.hong@gmail.com">Jack Hong</a>
+ * There's a really dangerous coding convention in this class, maintainers beware.
+ * There are two constructor. The no-args constructor defers, until later,
+ * the construction of a BeanTypeInfo. The one-arg constructor gets the BeanTypeInfo passed as a parameter.
+ * Aegis doesn't have any uniform discipline of 'construct, set properties, initialize'. Instead,
+ * each piece of code that uses the type info needs to call getTypeInfo() instead of referencing the
+ * 'info' field.
*/
public class BeanType extends Type {
private BeanTypeInfo info;
@@ -66,9 +70,17 @@
private boolean isException;
+ /**
+ * Construct a type info. Caller must pass in the type class via
+ * setTypeClass later.
+ */
public BeanType() {
}
+ /**
+ * Construct a type info given a full BeanTypeInfo.
+ * @param info
+ */
public BeanType(BeanTypeInfo info) {
this.info = info;
this.typeClass = info.getTypeClass();
@@ -80,10 +92,8 @@
isException = Exception.class.isAssignableFrom(typeClass);
}
- /*
- * (non-Javadoc)
- * @see org.codehaus.xfire.aegis.type.Type#readObject(org.codehaus.xfire.aegis.MessageReader,
- * org.codehaus.xfire.MessageContext)
+ /**
+ * {@inheritDoc}
*/
@Override
public Object readObject(MessageReader reader, Context context) throws DatabindingException {
@@ -447,6 +457,9 @@
}
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void setTypeClass(Class typeClass) {
super.setTypeClass(typeClass);
@@ -464,6 +477,9 @@
return true;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Set<Type> getDependencies() {
Set<Type> deps = new HashSet<Type>();
@@ -526,6 +542,10 @@
return elementTypeInfo;
}
+ /**
+ * Return the Type for the superclass if this type's class, if any.
+ * @return
+ */
public Type getSuperType() {
BeanTypeInfo inf = getTypeInfo();
Class c = inf.getTypeClass().getSuperclass();
@@ -550,6 +570,10 @@
}
}
+ /**
+ * Return the type info.
+ * @return
+ */
public BeanTypeInfo getTypeInfo() {
if (info == null) {
info = createTypeInfo();
@@ -560,6 +584,10 @@
return info;
}
+ /**
+ * Create type info based in the type class.
+ * @return
+ */
public BeanTypeInfo createTypeInfo() {
BeanTypeInfo inf = new BeanTypeInfo(getTypeClass(), getSchemaType().getNamespaceURI());
@@ -568,6 +596,9 @@
return inf;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public String toString() {
StringBuffer sb = new StringBuffer();
@@ -588,6 +619,9 @@
XmlSchemaUtils.addImportIfNeeded(root, AbstractXOPType.XML_MIME_NS);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public long getMinOccurs() {
return getTypeInfo().getMinOccurs();
@@ -602,6 +636,7 @@
public void setTypeMapping(TypeMapping typeMapping) {
super.setTypeMapping(typeMapping);
if (info != null) {
+ // this seems dangerous .. what if the type info is later created, it won't be passed the mapping.
info.setTypeMapping(typeMapping);
}
}