@Override public TypeClassInfo createClassInfo(Method m, int index) { TypeClassInfo info = new TypeClassInfo(); info.setDescription("method " + m.getName() + " parameter " + index); if (index >= 0) { info.setType(m.getParameterTypes()[index]); } else { info.setType(m.getReturnType()); } return info; }
@Override public AegisType createCollectionType(TypeClassInfo info) { if (!(info.getType() instanceof ParameterizedType)) { throw new DatabindingException("Cannot create mapping for " + info.getType() + ", unspecified component type for " + info.getDescription()); } return createCollectionTypeFromGeneric(info); }
@Override protected AegisType getOrCreateMapKeyType(TypeClassInfo info) { AegisType type = null; if (info.getKeyType() != null) { type = createTypeFromGeneric(info.getKeyType()); } if (type == null) { type = super.getOrCreateMapKeyType(info); } return type; }
protected void readMetadata(TypeClassInfo info, Element mapping, Element parameter) { info.setTypeName(createQName(parameter, DOMUtils.getAttributeValueEmptyNull(parameter, "typeName"))); info.setMappedName(createQName(parameter, DOMUtils.getAttributeValueEmptyNull(parameter, "mappedName"))); Class<?> relatedClass = TypeUtil.getTypeRelatedClass(info.getType()); Type fullType = ParameterizedTypeFactory.createParameterizedType(relatedClass, new Type[] {componentType}); info.setType(fullType); info.setKeyType(keyType); info.setValueType(valueType); if (keyType == null || valueType == null) { if (keyType == null) { keyType = TypeUtil.getSingleTypeParameter(info.getType(), 0); valueType = TypeUtil.getSingleTypeParameter(info.getType(), 1); = ParameterizedTypeFactory.createParameterizedType(relatedClass, new Type[] {keyType, valueType}); info.setType(fullType); info.setMinOccurs(Long.parseLong(min)); info.setMaxOccurs(Long.parseLong(max)); info.setFlat(Boolean.valueOf(flat.toLowerCase()).booleanValue());
protected AegisType createCollectionTypeFromGeneric(TypeClassInfo info) { AegisType component = getOrCreateGenericType(info); CollectionType type = new CollectionType(component); type.setTypeMapping(getTypeMapping()); QName name = info.getTypeName(); if (name == null) { name = createCollectionQName(info, component); } type.setSchemaType(name); type.setTypeClass(info.getType()); if (info.getMinOccurs() != -1) { type.setMinOccurs(info.getMinOccurs()); } if (info.getMaxOccurs() != -1) { type.setMaxOccurs(info.getMaxOccurs()); } type.setFlat(info.isFlat()); return type; }
info = nextCreator.createClassInfo(m, index); } else { info = new TypeClassInfo(); info.setDescription("method " + m.getName() + " parameter " + index); info.setType(genericType); info.setAegisTypeClass(castToAegisTypeClass(paramTypeClass)); String paramName = annotationReader.getParamTypeName(m, index); if (paramName != null) { info.setTypeName(createQName(m.getParameterTypes()[index], genericType, paramName, info = nextCreator.createClassInfo(m, index); } else { info = new TypeClassInfo(); info.setDescription("method " + m.getName() + " parameter " + index); info.setType(genericReturnType); info.setAnnotations(m.getAnnotations()); info.setAegisTypeClass(castToAegisTypeClass(annotationReader.getReturnType(m))); String returnName = annotationReader.getReturnTypeName(m); if (returnName != null) { info.setTypeName(createQName(m.getReturnType(), genericReturnType, returnName,
info = typeCreator.createBasicClassInfo(param.getTypeClass()); Boolean nillable = info.getNillable(); if (info.getMinOccurs() != -1) { param.setProperty("minOccurs", Long.toString(info.getMinOccurs())); if (info.getMaxOccurs() != -1) { param.setProperty("maxOccurs", Long.toString(info.getMaxOccurs())); if (info.getMappedName() != null) { param.setConcreteName(info.getMappedName()); param.setName(info.getMappedName()); if (info.nonDefaultAttributes()) { tm.register(type);
protected AegisType createUserType(TypeClassInfo info) { try { AegisType type = info.getAegisTypeClass().newInstance(); QName name = info.getTypeName(); if (name == null) { Class<?> typeClass = TypeUtil.getTypeRelatedClass(info.getType()); if (typeClass.getPackage().getName().startsWith("java")) { name = tm.getTypeQName(typeClass); type.setTypeClass(info.getType()); type.setTypeMapping(getTypeMapping()); } catch (InstantiationException 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.getAegisTypeClass().getName(), e);
protected QName createCollectionQName(TypeClassInfo info, AegisType type) { String ns; if (type.isComplex()) { ns = type.getSchemaType().getNamespaceURI(); } else { ns = tm.getMappingIdentifierURI(); } if (WSDLConstants.NS_SCHEMA_XSD.equals(ns)) { ns = HTTP_CXF_APACHE_ORG_ARRAYS; } String first = type.getSchemaType().getLocalPart().substring(0, 1); String last = type.getSchemaType().getLocalPart().substring(1); String localName = "ArrayOf" + first.toUpperCase() + last; if (info.nonDefaultAttributes()) { localName += "-"; if (info.getMinOccurs() >= 0) { localName += info.getMinOccurs(); } localName += "-"; if (info.getMaxOccurs() >= 0) { localName += info.getMaxOccurs(); } if (info.isFlat()) { localName += "Flat"; } } return new QName(ns, localName); }
protected AegisType getOrCreateParameterizedType(TypeClassInfo generic, int index, boolean map) { Type paramType; Map<String, Type> pm = generic.getTypeVars(); if (map) { if (pm == null) { pm = new HashMap<>(pm); paramType = getComponentTypeForMap(generic.getType(), pm, index == 0); } else { paramType = getComponentType(generic.getType(), index); "Could not map TypeVariable named {0} from {1} with initial mapping {2} to " + "a known class. Using Object.", new Object[] {v.getName(), generic.getType().toString(), generic.getTypeVars()}); info.setDescription(clazz.toString()); info.setType(paramType, paramType instanceof ParameterizedType ? pm : null);
@Override protected AegisType getOrCreateMapValueType(TypeClassInfo info) { AegisType type = null; if (info.getType() instanceof ParameterizedType) { // well, let's hope that someone has filled in the value type. type = createTypeFromGeneric(info.getValueType()); } if (type == null) { type = super.getOrCreateMapValueType(info); } return type; }
@Override public AegisType createDefaultType(TypeClassInfo info) { QName typeName = info.getTypeName(); Class<?> relatedClass = TypeUtil.getTypeRelatedClass(info.getType()); if (typeName == null) { typeName = createQName(relatedClass); } AnnotatedTypeInfo typeInfo = new AnnotatedTypeInfo( getTypeMapping(), relatedClass, typeName.getNamespaceURI(), getConfiguration()); typeInfo.setExtensibleElements(annotationReader.isExtensibleElements( relatedClass, getConfiguration().isDefaultExtensibleElements())); typeInfo.setExtensibleAttributes(annotationReader.isExtensibleAttributes( relatedClass, getConfiguration().isDefaultExtensibleAttributes())); typeInfo.setDefaultMinOccurs(getConfiguration().getDefaultMinOccurs()); typeInfo.setDefaultNillable(getConfiguration().isDefaultNillable()); BeanType type = new BeanType(typeInfo); type.setTypeMapping(getTypeMapping()); type.setSchemaType(typeName); return type; }
@Override public String toString() { return "TypeClassInfo " + getDescription(); }
public QName getElementName(Method m, int index) { TypeClassInfo info = createClassInfo(m, index); return info.getMappedName(); }
protected void readMetadata(TypeClassInfo info, Element mapping, Element parameter) { info.setTypeName(createQName(parameter, DOMUtils.getAttributeValueEmptyNull(parameter, "typeName"))); info.setMappedName(createQName(parameter, DOMUtils.getAttributeValueEmptyNull(parameter, "mappedName"))); Class<?> relatedClass = TypeUtil.getTypeRelatedClass(info.getType()); Type fullType = ParameterizedTypeFactory.createParameterizedType(relatedClass, new Type[] {componentType}); info.setType(fullType); info.setKeyType(keyType); info.setValueType(valueType); if (keyType == null || valueType == null) { if (keyType == null) { keyType = TypeUtil.getSingleTypeParameter(info.getType(), 0); valueType = TypeUtil.getSingleTypeParameter(info.getType(), 1); = ParameterizedTypeFactory.createParameterizedType(relatedClass, new Type[] {keyType, valueType}); info.setType(fullType); info.setMinOccurs(Long.parseLong(min)); info.setMaxOccurs(Long.parseLong(max)); info.setFlat(Boolean.valueOf(flat.toLowerCase()).booleanValue());
protected AegisType createCollectionTypeFromGeneric(TypeClassInfo info) { AegisType component = getOrCreateGenericType(info); CollectionType type = new CollectionType(component); type.setTypeMapping(getTypeMapping()); QName name = info.getTypeName(); if (name == null) { name = createCollectionQName(info, component); } type.setSchemaType(name); type.setTypeClass(info.getType()); if (info.getMinOccurs() != -1) { type.setMinOccurs(info.getMinOccurs()); } if (info.getMaxOccurs() != -1) { type.setMaxOccurs(info.getMaxOccurs()); } type.setFlat(info.isFlat()); return type; }
info = nextCreator.createClassInfo(m, index); } else { info = new TypeClassInfo(); info.setDescription("method " + m.getName() + " parameter " + index); info.setType(genericType); info.setAegisTypeClass(castToAegisTypeClass(paramTypeClass)); String paramName = annotationReader.getParamTypeName(m, index); if (paramName != null) { info.setTypeName(createQName(m.getParameterTypes()[index], genericType, paramName, info = nextCreator.createClassInfo(m, index); } else { info = new TypeClassInfo(); info.setDescription("method " + m.getName() + " parameter " + index); info.setType(genericReturnType); info.setAnnotations(m.getAnnotations()); info.setAegisTypeClass(castToAegisTypeClass(annotationReader.getReturnType(m))); String returnName = annotationReader.getReturnTypeName(m); if (returnName != null) { info.setTypeName(createQName(m.getReturnType(), genericReturnType, returnName,
info = typeCreator.createBasicClassInfo(param.getTypeClass()); Boolean nillable = info.getNillable(); if (info.getMinOccurs() != -1) { param.setProperty("minOccurs", Long.toString(info.getMinOccurs())); if (info.getMaxOccurs() != -1) { param.setProperty("maxOccurs", Long.toString(info.getMaxOccurs())); if (info.getMappedName() != null) { param.setConcreteName(info.getMappedName()); param.setName(info.getMappedName()); if (info.nonDefaultAttributes()) { tm.register(type);