Index: F:/work/xfire/xfire-java5/src/main/org/codehaus/xfire/aegis/type/java5/AnnotatedTypeInfo.java =================================================================== --- F:/work/xfire/xfire-java5/src/main/org/codehaus/xfire/aegis/type/java5/AnnotatedTypeInfo.java (revision 1316) +++ F:/work/xfire/xfire-java5/src/main/org/codehaus/xfire/aegis/type/java5/AnnotatedTypeInfo.java (working copy) @@ -15,8 +15,7 @@ public AnnotatedTypeInfo(TypeMapping tm, Class typeClass, String ns) { super(typeClass, ns); - setTypeMapping(tm); - + setTypeMapping(tm); initialize(); } @@ -124,4 +123,19 @@ return super.isNillable(name); } } + + public int getMinOccurs ( QName name ) + { + PropertyDescriptor desc = getPropertyDescriptorFromMappedName(name); + if (isAnnotatedElement(desc)) + { + XmlElement att = desc.getReadMethod().getAnnotation(XmlElement.class); + String minOccurs = att.minOccurs(); + if ( minOccurs != null && minOccurs.length() > 0 ) + { + return Integer.parseInt( minOccurs ); + } + } + return super.getMinOccurs(name); + } } Index: F:/work/xfire/xfire-java5/src/main/org/codehaus/xfire/aegis/type/java5/Java5TypeCreator.java =================================================================== --- F:/work/xfire/xfire-java5/src/main/org/codehaus/xfire/aegis/type/java5/Java5TypeCreator.java (revision 1316) +++ F:/work/xfire/xfire-java5/src/main/org/codehaus/xfire/aegis/type/java5/Java5TypeCreator.java (working copy) @@ -5,7 +5,6 @@ import java.lang.reflect.Method; import java.lang.reflect.ParameterizedType; import java.lang.reflect.WildcardType; -import java.util.Arrays; import javax.xml.namespace.QName; @@ -26,7 +25,7 @@ { TypeClassInfo info; java.lang.reflect.Type genericType = m.getGenericParameterTypes()[index]; - if(genericType instanceof Class) + if (genericType instanceof Class) { info = nextCreator.createClassInfo(m, index); } @@ -42,19 +41,19 @@ { if (xmlParam.type() != Type.class) info.setType(xmlParam.type()); - + info.setTypeName(createQName(m.getParameterTypes()[index], xmlParam.name(), xmlParam.namespace())); } - + return info; } else { java.lang.reflect.Type genericReturnType = m.getGenericReturnType(); TypeClassInfo info; - if(genericReturnType instanceof Class) + if (genericReturnType instanceof Class) { info = nextCreator.createClassInfo(m, index); } @@ -64,33 +63,31 @@ info.setGenericType(genericReturnType); } info.setTypeClass(m.getReturnType()); - if(m.getParameterAnnotations() != null && m.getAnnotations().length > 0) + if (m.getParameterAnnotations() != null && m.getAnnotations().length > 0) info.setAnnotations(m.getAnnotations()); - + XmlReturnType xmlParam = m.getAnnotation(XmlReturnType.class); if (xmlParam != null) { if (xmlParam.type() != Type.class) info.setType(xmlParam.type()); - - info.setTypeName(createQName(m.getReturnType(), - xmlParam.name(), - xmlParam.namespace())); + + info.setTypeName(createQName(m.getReturnType(), xmlParam.name(), xmlParam + .namespace())); } - + return info; } } - + public XmlParamType getXmlParamAnnotation(Method m, int index) { - if (m.getParameterAnnotations() == null || - m.getParameterAnnotations().length < index || - m.getParameterAnnotations()[index] == null) + if (m.getParameterAnnotations() == null || m.getParameterAnnotations().length < index + || m.getParameterAnnotations()[index] == null) return null; - + Annotation[] annotations = m.getParameterAnnotations()[index]; - + for (int i = 0; i < annotations.length; i++) { Annotation annotation = annotations[i]; @@ -99,29 +96,29 @@ return (XmlParamType) annotations[i]; } } - + return null; } - + @Override public TypeClassInfo createClassInfo(PropertyDescriptor pd) { TypeClassInfo info = createBasicClassInfo(pd.getPropertyType()); info.setGenericType(pd.getReadMethod().getGenericReturnType()); info.setAnnotations(pd.getReadMethod().getAnnotations()); - + XmlElement el = pd.getReadMethod().getAnnotation(XmlElement.class); if (el != null && !el.type().equals(Type.class)) { - info.setType(el.type()); + info.setType(el.type()); } - + XmlAttribute att = pd.getReadMethod().getAnnotation(XmlAttribute.class); if (att != null && !att.type().equals(Type.class)) { - info.setType(att.type()); + info.setType(att.type()); } - + return info; } @@ -136,11 +133,11 @@ ParameterizedType type = (ParameterizedType) genericType; if (type.getActualTypeArguments()[0] instanceof Class) { - keyClass = (Class) type.getActualTypeArguments()[0]; + keyClass = (Class) type.getActualTypeArguments()[0]; } if (type.getActualTypeArguments()[1] instanceof Class) { - valueClass = (Class) type.getActualTypeArguments()[1]; + valueClass = (Class) type.getActualTypeArguments()[1]; } } @@ -152,11 +149,14 @@ { Object genericType = info.getGenericType(); Class paramClass = getComponentType(genericType); - if(paramClass != null){ + if (paramClass != null) + { return super.createCollectionType(info, paramClass); - } else { - return nextCreator.createCollectionType(info); } + else + { + return nextCreator.createCollectionType(info); + } } protected Class getComponentType(Object genericType) @@ -171,13 +171,13 @@ { paramClass = (Class) type.getActualTypeArguments()[0]; } - else if (type.getActualTypeArguments()[0] instanceof WildcardType ) + else if (type.getActualTypeArguments()[0] instanceof WildcardType) { WildcardType wildcardType = (WildcardType) type.getActualTypeArguments()[0]; - if( wildcardType.getUpperBounds()[0] instanceof Class ) + if (wildcardType.getUpperBounds()[0] instanceof Class) { - paramClass = (Class) wildcardType.getUpperBounds()[0]; + paramClass = (Class) wildcardType.getUpperBounds()[0]; } } } @@ -188,12 +188,27 @@ public Type createDefaultType(TypeClassInfo info) { QName typeName = info.getTypeName(); - if (typeName == null) typeName = createQName(info.getTypeClass()); - - BeanType type = new BeanType(new AnnotatedTypeInfo(getTypeMapping(), info.getTypeClass(), typeName.getNamespaceURI())); + if (typeName == null) + typeName = createQName(info.getTypeClass()); + + AnnotatedTypeInfo typeInfo = new AnnotatedTypeInfo(getTypeMapping(), info.getTypeClass(), + typeName.getNamespaceURI()); + XmlType xtype = (XmlType) info.getTypeClass().getAnnotation(XmlType.class); + if (xtype != null) + { + typeInfo.setExtensibleElements(xtype.extensibleElements()); + typeInfo.setExtensibleAttributes(xtype.extensibleAttributes()); + } + else + { + typeInfo.setExtensibleElements(isDefaultExtensibleElements()); + typeInfo.setExtensibleAttributes(isDefaultExtensibleAttributes()); + } + + BeanType type = new BeanType(typeInfo); type.setTypeMapping(getTypeMapping()); type.setSchemaType(typeName); - + setDefaults( type ); return type; } @@ -205,7 +220,7 @@ type.setSchemaType(createQName(info.getTypeClass())); type.setTypeClass(info.getTypeClass()); type.setTypeMapping(getTypeMapping()); - + return type; } @@ -214,14 +229,14 @@ { String name = null; String ns = null; - + XmlType xtype = (XmlType) typeClass.getAnnotation(XmlType.class); if (xtype != null) { name = xtype.name(); ns = xtype.namespace(); } - + return createQName(typeClass, name, ns); } @@ -230,13 +245,13 @@ String clsName = typeClass.getName(); if (name == null || name.length() == 0) name = ServiceUtils.makeServiceNameFromClassName(typeClass); - + if (ns == null || ns.length() == 0) ns = NamespaceHelper.makeNamespaceFromClassName(clsName, "http"); - + return new QName(ns, name); } - + @Override protected boolean isEnum(Class javaType) { Index: F:/work/xfire/xfire-java5/src/main/org/codehaus/xfire/aegis/type/java5/XmlElement.java =================================================================== --- F:/work/xfire/xfire-java5/src/main/org/codehaus/xfire/aegis/type/java5/XmlElement.java (revision 1316) +++ F:/work/xfire/xfire-java5/src/main/org/codehaus/xfire/aegis/type/java5/XmlElement.java (working copy) @@ -15,4 +15,9 @@ String name() default ""; String namespace() default ""; boolean nillable() default true; + + /** + * ajc - set to "0" to make the property optional, "1" for required + */ + String minOccurs() default ""; } Index: F:/work/xfire/xfire-java5/src/main/org/codehaus/xfire/aegis/type/java5/XmlType.java =================================================================== --- F:/work/xfire/xfire-java5/src/main/org/codehaus/xfire/aegis/type/java5/XmlType.java (revision 1316) +++ F:/work/xfire/xfire-java5/src/main/org/codehaus/xfire/aegis/type/java5/XmlType.java (working copy) @@ -14,4 +14,6 @@ Class type() default Type.class; String name() default ""; String namespace() default ""; + boolean extensibleElements() default true; + boolean extensibleAttributes() default true; }