[jboss-svn-commits] JBoss Common SVN: r2456 - jbossxb-builder/trunk/src/main/java/org/jboss/xb/builder.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Jul 25 07:34:03 EDT 2007
Author: alex.loubyansky at jboss.com
Date: 2007-07-25 07:34:03 -0400 (Wed, 25 Jul 2007)
New Revision: 2456
Modified:
jbossxb-builder/trunk/src/main/java/org/jboss/xb/builder/JBossXBNoSchemaBuilder.java
Log:
some fixes and hacks to make the ejb metadata tests run w/o errors
Modified: jbossxb-builder/trunk/src/main/java/org/jboss/xb/builder/JBossXBNoSchemaBuilder.java
===================================================================
--- jbossxb-builder/trunk/src/main/java/org/jboss/xb/builder/JBossXBNoSchemaBuilder.java 2007-07-25 11:27:37 UTC (rev 2455)
+++ jbossxb-builder/trunk/src/main/java/org/jboss/xb/builder/JBossXBNoSchemaBuilder.java 2007-07-25 11:34:03 UTC (rev 2456)
@@ -37,6 +37,7 @@
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlNsForm;
@@ -1046,6 +1047,8 @@
else if (!property.getType().isPrimitive())
{
ClassInfo propClassInfo = (ClassInfo) property.getType();
+
+ // TODO XmlElement on this property?..
XmlElement propXmlElement = property.getUnderlyingAnnotation(XmlElement.class);
if(propXmlElement != null)
{
@@ -1053,7 +1056,7 @@
}
JBossXmlModelGroup xmlModelGroup = propClassInfo.getUnderlyingAnnotation(JBossXmlModelGroup.class);
- if (xmlModelGroup != null)
+ if (xmlModelGroup != null && xmlModelGroup.particles().length == 0)
{
if(trace)
log.trace("Property " + property.getName() + " is bound to " + xmlModelGroup.kind());
@@ -1127,7 +1130,10 @@
XmlElement memberXmlElement = memberProp.getUnderlyingAnnotation(XmlElement.class);
if(memberXmlElement != null)
{
- memberTypeInfo = memberTypeInfo.getTypeInfoFactory().getTypeInfo(memberXmlElement.type());
+ if(!XmlElement.DEFAULT.class.equals(memberXmlElement.type()))
+ {
+ memberTypeInfo = memberTypeInfo.getTypeInfoFactory().getTypeInfo(memberXmlElement.type());
+ }
memberNamespace = memberXmlElement.namespace();
memberName = memberXmlElement.name();
}
@@ -1202,8 +1208,9 @@
for (int i = 0; i < elements.length; ++i)
{
+ XmlElement element = elements[i];
if (trace)
- log.trace("Processing " + xmlElement + " for type=" + beanInfo.getName() + " property=" + property.getName());
+ log.trace("Processing " + element + " for type=" + beanInfo.getName() + " property=" + property.getName());
// Determine the parameters
overrideNamespace = null;
@@ -1213,7 +1220,6 @@
TypeInfo localPropertyType = propertyType;
- XmlElement element = elements[i];
if (element != null)
{
overrideNamespace = element.namespace();
@@ -1230,7 +1236,7 @@
// Create the element
JBossXmlGroup jbossXmlGroup = null;
- if (propertyType instanceof ClassInfo)
+ if (!propertyType.isPrimitive())
jbossXmlGroup = ((ClassInfo) propertyType).getUnderlyingAnnotation(JBossXmlGroup.class);
if (element == null && jbossXmlGroup != null)
{
@@ -1283,7 +1289,7 @@
childBinding.setNillable(nillable);
// Bind it to the model
- particle = new ParticleBinding(childBinding, 1, 1, false);
+ particle = new ParticleBinding(childBinding, child.minOccurs(), child.maxOccurs(), child.unbounded());
particle.setMinOccurs(0);
childModel.addParticle(particle);
@@ -1325,27 +1331,79 @@
}
else
{
+ ModelGroupBinding targetGroup = localModel;
+ boolean isCol = false;
+ AbstractPropertyHandler propertyHandler = null;
+ // handled by wildcard
+ if (wildcardProperty == property)
+ {
+ propertyHandler = wildcardHandler;
+ }
+ // a collection may be bound as a value of a complex type
+ // and this is checked with the XmlType annotation
+ else if (propertyType.isCollection() && ((ClassInfo) propertyType).getUnderlyingAnnotation(XmlType.class) == null)
+ {
+ isCol = true;
+ propertyHandler = new CollectionPropertyHandler(property, propertyType);
+
+ ClassInfo typeArg = null;
+ // parametrized collection
+ if(propertyType instanceof ParameterizedClassInfo)
+ {
+ ParameterizedClassInfo pti = (ParameterizedClassInfo) propertyType;
+ typeArg = (ClassInfo) pti.getActualTypeArguments()[0];
+ }
+ else if(((ClassInfo) propertyType).getGenericSuperclass() instanceof ParameterizedClassInfo)
+ {
+ ParameterizedClassInfo pti = (ParameterizedClassInfo) ((ClassInfo) propertyType).getGenericSuperclass();
+ typeArg = (ClassInfo) pti.getActualTypeArguments()[0];
+ }
+
+ //if (((ClassInfo) typeArg).getUnderlyingAnnotation(XmlType.class) != null)
+ if (typeArg != null && typeArg.getUnderlyingAnnotation(JBossXmlModelGroup.class) == null)
+ {// it may be a model group in which case we don't want to change the type
+
+ // TODO yes, this is another hack with collections
+ JBossXmlChild xmlChild = ((ClassInfo) propertyType).getUnderlyingAnnotation(JBossXmlChild.class);
+ if (xmlChild == null)
+ {
+ localPropertyType = typeArg;
+ }
+ }
+ }
+ // TODO this shouldn't be here (because localPropertyType should specify an item?)
+ // this is to support the Descriptions.class -> DescriptionsImpl.class
+ else if (localPropertyType.isCollection() && ((ClassInfo)localPropertyType).getUnderlyingAnnotation(XmlType.class) == null)
+ {
+ propertyHandler = new CollectionPropertyHandler(property, localPropertyType);
+ isCol = true;
+ TypeInfo gs = ((ClassInfo) localPropertyType).getGenericSuperclass();
+ if (gs instanceof ParameterizedClassInfo)
+ {
+ ParameterizedClassInfo pti = (ParameterizedClassInfo) gs;
+ ClassInfo typeArg = (ClassInfo) pti.getActualTypeArguments()[0];
+ //if (((ClassInfo) typeArg).getUnderlyingAnnotation(XmlType.class) != null)
+ if (typeArg.getUnderlyingAnnotation(JBossXmlModelGroup.class) == null)
+ {// it may be a model group in which case we don't want to change the type
+ localPropertyType = typeArg;
+ }
+ }
+ }
+ else
+ {
+ propertyHandler = new PropertyHandler(property, localPropertyType);
+ }
+
TypeBinding elementTypeBinding = resolveTypeBinding(localPropertyType);
ElementBinding elementBinding = createElementBinding(localPropertyType, elementTypeBinding, qName, false);
elementBinding.setNillable(nillable);
// Bind it to the model
- ParticleBinding particle = new ParticleBinding(elementBinding, 1, 1, false);
+ ParticleBinding particle = new ParticleBinding(elementBinding, 1, 1, isCol);
if (required == false)
particle.setMinOccurs(0);
- localModel.addParticle(particle);
+ targetGroup.addParticle(particle);
- // Create the handler
- AbstractPropertyHandler propertyHandler;
- // handled by wildcard
- if (wildcardProperty == property)
- {
- propertyHandler = wildcardHandler;
- }
- else if (propertyType.isCollection())
- propertyHandler = new CollectionPropertyHandler(property, propertyType);
- else
- propertyHandler = new PropertyHandler(property, localPropertyType);
beanAdapterFactory.addProperty(qName, propertyHandler);
if (trace)
log.trace("Added property " + qName + " for type=" + beanInfo.getName() + " property=" + property.getName() + " handler=" + propertyHandler);
@@ -1377,7 +1435,7 @@
ElementBinding elementBinding = createElementBinding(childType, elementTypeBinding, qName, false);
// Bind it to the model
- ParticleBinding particle = new ParticleBinding(elementBinding, 0, 1, false);
+ ParticleBinding particle = new ParticleBinding(elementBinding, child.minOccurs(), child.maxOccurs(), child.unbounded());
model.addParticle(particle);
DefaultElementInterceptor interceptor = null;
More information about the jboss-svn-commits
mailing list