org.codehaus.xfire.aegis.type
Class XMLTypeCreator

java.lang.Object
  extended byorg.codehaus.xfire.aegis.type.AbstractTypeCreator
      extended byorg.codehaus.xfire.aegis.type.XMLTypeCreator
All Implemented Interfaces:
TypeCreator

public 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, Mika G?ckel, ?yvind Matheson Wergeland

Nested Class Summary
 
Nested classes inherited from class org.codehaus.xfire.aegis.type.AbstractTypeCreator
AbstractTypeCreator.TypeClassInfo
 
Field Summary
 
Fields inherited from class org.codehaus.xfire.aegis.type.AbstractTypeCreator
nextCreator, tm
 
Constructor Summary
XMLTypeCreator()
           
 
Method Summary
 AbstractTypeCreator.TypeClassInfo createClassInfo(java.lang.reflect.Method m, int index)
           
 AbstractTypeCreator.TypeClassInfo createClassInfo(java.beans.PropertyDescriptor pd)
           
 Type createCollectionType(AbstractTypeCreator.TypeClassInfo info)
           
 Type createDefaultType(AbstractTypeCreator.TypeClassInfo info)
           
 Type createEnumType(AbstractTypeCreator.TypeClassInfo info)
           
protected  Type createMapType(AbstractTypeCreator.TypeClassInfo info)
           
protected  javax.xml.namespace.QName createQName(org.jdom.Element e, java.lang.String value)
          Creates a QName from a string, such as "ns:Element".
protected  org.jdom.Element findMapping(java.lang.Class clazz)
           
protected  java.util.List findMappings(java.lang.Class clazz)
           
protected  org.jdom.Document getDocument(java.lang.Class clazz)
           
protected  boolean isEnum(java.lang.Class javaType)
           
protected  void readMetadata(AbstractTypeCreator.TypeClassInfo info, org.jdom.Element parameter)
           
protected  void setComponentType(AbstractTypeCreator.TypeClassInfo info, org.jdom.Element parameter)
           
protected  void setKeyType(AbstractTypeCreator.TypeClassInfo info, org.jdom.Element parameter)
           
protected  void setType(AbstractTypeCreator.TypeClassInfo info, org.jdom.Element parameter)
           
 
Methods inherited from class org.codehaus.xfire.aegis.type.AbstractTypeCreator
createArrayQName, createArrayType, createBasicClassInfo, createClassInfo, createCollectionQName, createCollectionType, createHolderType, createMapQName, createMapType, createQName, createType, createType, createType, createType, createTypeForClass, createUserType, getTypeMapping, isArray, isCollection, isHolder, isMap, setNextCreator, setTypeMapping
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLTypeCreator

public XMLTypeCreator()
Method Detail

getDocument

protected org.jdom.Document getDocument(java.lang.Class clazz)

isEnum

protected boolean isEnum(java.lang.Class javaType)
Overrides:
isEnum in class AbstractTypeCreator

createEnumType

public Type createEnumType(AbstractTypeCreator.TypeClassInfo info)
Overrides:
createEnumType in class AbstractTypeCreator

createMapType

protected Type createMapType(AbstractTypeCreator.TypeClassInfo info)
Overrides:
createMapType in class AbstractTypeCreator

createCollectionType

public Type createCollectionType(AbstractTypeCreator.TypeClassInfo info)
Specified by:
createCollectionType in class AbstractTypeCreator

createClassInfo

public AbstractTypeCreator.TypeClassInfo createClassInfo(java.beans.PropertyDescriptor pd)
Specified by:
createClassInfo in class AbstractTypeCreator

findMapping

protected org.jdom.Element findMapping(java.lang.Class clazz)

findMappings

protected java.util.List findMappings(java.lang.Class clazz)

createDefaultType

public Type createDefaultType(AbstractTypeCreator.TypeClassInfo info)
Specified by:
createDefaultType in class AbstractTypeCreator

createClassInfo

public AbstractTypeCreator.TypeClassInfo createClassInfo(java.lang.reflect.Method m,
                                                         int index)
Specified by:
createClassInfo in class AbstractTypeCreator

readMetadata

protected void readMetadata(AbstractTypeCreator.TypeClassInfo info,
                            org.jdom.Element parameter)

setComponentType

protected void setComponentType(AbstractTypeCreator.TypeClassInfo info,
                                org.jdom.Element parameter)

setType

protected void setType(AbstractTypeCreator.TypeClassInfo info,
                       org.jdom.Element parameter)

setKeyType

protected void setKeyType(AbstractTypeCreator.TypeClassInfo info,
                          org.jdom.Element parameter)

createQName

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



Copyright © 2004-2006 null. All Rights Reserved.