Groovy Documentation

src.java.org.grails.xfire.aegis.type
Class XMLTypeCreator

java.lang.Object
  src.java.org.grails.xfire.aegis.type.AbstractTypeCreator
      src.java.org.grails.xfire.aegis.type.XMLTypeCreator

class XMLTypeCreator
extends AbstractTypeCreator

Deduce mapping information from an xml file. The xml file should be in the same packages as the class, with the name className.aegis.xml. For example, given the following service interface:

 public Collection getResultsForValues(String id, Collection values); //method 1
 public Collection getResultsForValues(int id, Collection values); //method 2
 public String getResultForValue(String value); //method 3
 
An example of the type xml is:
 <mappings>
  <mapping>
    <method name="getResultsForValues">
      <return-type componentType="com.acme.ResultBean" />
      <!-- no need to specify index 0, since it's a String -->
      <parameter index="1" componentType="java.lang.String" />
    </method>
  </mapping>
 </mappings>
 

Note that for values which can be easily deduced (such as the String parameter, or the second service method) no mapping need be specified in the xml descriptor, which is why no mapping is specified for method 3.

However, if you have overloaded methods with different semantics, then you will need to specify enough parameters to disambiguate the method and uniquely identify it. So in the example above, the mapping specifies will apply to both method 1 and method 2, since the parameter at index 0 is not specified.

author:
Hani Suleiman Date: Jun 14, 2005 Time: 7:47:56 PM
author:
Mika G?ckel
author:
?yvind Matheson Wergeland
author:
Tomasz Sztelak


Field Summary
private static Log log

XMLClassMetaInfoManager manager

private static List stopClasses

 
Fields inherited from class AbstractTypeCreator
nextCreator, tm
 
Constructor Summary
XMLTypeCreator()

 
Method Summary
TypeClassInfo createClassInfo(PropertyDescriptor pd)

TypeClassInfo createClassInfo(Method m, int index)

Type createCollectionType(TypeClassInfo info)

Type createDefaultType(TypeClassInfo info)

Type createEnumType(TypeClassInfo info)

protected QName createQName(Element e, java.lang.String value)

Creates a QName from a string, such as "ns:Element".

private Type createTypeFromGeneric(java.lang.Object cType)

protected Element findMapping(java.lang.Class clazz)

protected List findMappings(java.lang.Class clazz)

private Element getBestMatch(Element mapping, Method method, List availableNodes)

protected Document getDocument(java.lang.Class clazz)

private List getMatches(java.lang.Object doc, java.lang.String xpath)

protected Type getOrCreateGenericType(TypeClassInfo info)

protected Type getOrCreateMapKeyType(TypeClassInfo info)

protected Type getOrCreateMapValueType(TypeClassInfo info)

protected boolean isEnum(java.lang.Class javaType)

private java.lang.Class loadComponentClass(java.lang.String componentType)

private java.lang.Object loadGeneric(TypeClassInfo info, Element mapping, java.lang.String componentType)

protected void readMetadata(TypeClassInfo info, Element mapping, Element parameter)

protected void setComponentType(TypeClassInfo info, Element mapping, Element parameter)

protected void setKeyType(TypeClassInfo info, Element mapping, Element parameter)

protected void setType(TypeClassInfo info, Element parameter)

 
Methods inherited from class AbstractTypeCreator
createArrayType, createBasicClassInfo, createClassInfo, createClassInfo, createClassInfo, createCollectionQName, createCollectionType, createCollectionTypeFromGeneric, createDefaultType, createEnumType, createHolderType, createMapQName, createMapType, createMapType, createQName, createType, createType, createType, createType, createTypeForClass, createUserType, getConfiguration, getElementName, getOrCreateGenericType, getOrCreateMapKeyType, getOrCreateMapValueType, getParent, getTopCreator, getTypeMapping, isArray, isCollection, isEnum, isHolder, isMap, setConfiguration, setNextCreator, setParent, setTypeMapping
 

Field Detail

log

private static final Log log


manager

XMLClassMetaInfoManager manager


stopClasses

private static List stopClasses


 
Constructor Detail

XMLTypeCreator

XMLTypeCreator()


 
Method Detail

createClassInfo

public TypeClassInfo createClassInfo(PropertyDescriptor pd)


createClassInfo

public TypeClassInfo createClassInfo(Method m, int index)


createCollectionType

public Type createCollectionType(TypeClassInfo info)


createDefaultType

public Type createDefaultType(TypeClassInfo info)


createEnumType

public Type createEnumType(TypeClassInfo info)


createQName

protected QName createQName(Element e, java.lang.String value)
Creates a QName from a string, such as "ns:Element".


createTypeFromGeneric

private Type createTypeFromGeneric(java.lang.Object cType)


findMapping

protected Element findMapping(java.lang.Class clazz)


findMappings

protected List findMappings(java.lang.Class clazz)


getBestMatch

private Element getBestMatch(Element mapping, Method method, List availableNodes)


getDocument

protected Document getDocument(java.lang.Class clazz)


getMatches

private List getMatches(java.lang.Object doc, java.lang.String xpath)


getOrCreateGenericType

protected Type getOrCreateGenericType(TypeClassInfo info)


getOrCreateMapKeyType

protected Type getOrCreateMapKeyType(TypeClassInfo info)


getOrCreateMapValueType

protected Type getOrCreateMapValueType(TypeClassInfo info)


isEnum

protected boolean isEnum(java.lang.Class javaType)


loadComponentClass

private java.lang.Class loadComponentClass(java.lang.String componentType)


loadGeneric

private java.lang.Object loadGeneric(TypeClassInfo info, Element mapping, java.lang.String componentType)


readMetadata

protected void readMetadata(TypeClassInfo info, Element mapping, Element parameter)


setComponentType

protected void setComponentType(TypeClassInfo info, Element mapping, Element parameter)


setKeyType

protected void setKeyType(TypeClassInfo info, Element mapping, Element parameter)


setType

protected void setType(TypeClassInfo info, Element parameter)


 

Groovy Documentation