Changes between Version 2 and Version 3 of ExampleUsingXmlRpcBeans
- Timestamp:
- 10/09/06 14:43:03 (18 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ExampleUsingXmlRpcBeans
v2 v3 1 == Using XmlRpcBeans in you API ==1 == Using !XmlRpcBeans in you API == 2 2 3 What are XmlRpcBeans?? 4 3 What are !XmlRpcBeans?? 5 4 6 5 Sometimes parameter conversion is a straight-forward task which can be handed over to the XML-RPC runtime system. 7 6 When a java class fulfills certain conditions (roughly, being a java bean with complatible types) it can be turned into a XmlRpcBean 8 by annotating it with the @!XmlRpcBean annotation. It then can be used in every XML-RPC call without restriction. 7 by annotating it with the @!XmlRpcBean annotation. It then can be used in every XML-RPC call without restriction.[[BR]] 8 9 9 A XmlRpcBean must have 10 10 … … 13 13 - like a java bean: for each property which is supposed to be transported over XML-RPC there has to exist a public getter and setter method 14 14 15 - each peroperty type has to be XML-RPC compliant, that is it has to have one of the follwoing properties: 15 - each property type has to be a XML-RPC compliant type, that is it has to have one of the follwoing properties: 16 - it is a standard XML-RPC type 17 - it is annotated with a @!XmlRpc annotation and defines proper conversion methods 18 - a conversion mapping for that type is put at the XmlRpcBean (which then acts as an API itself) 19 - it is an XmlRpcBean (that is, XmlRpcBeans can be nested) 16 20 17 - it is a standard XML-RPC type 21 Technically, an !XmlRpcBean is converted into a XML-RPC STRUCT. The field names of the tranfered map are the property names derived from the bean class. 18 22 19 - it is annotated with a @!XmlRpc annotation and defines proper conversion methods20 23 21 - a conversion mapping for that type is put at the XmlRpcBean (which then acts as an API itself) 22 23 - it is an XmlRpcBean (that is, XmlRpcBeans can be nested) 24 Lets look at an example !XmlRpcBean (note that this bean also defines a converter mapping for type ''URL''): 25 {{{ 26 @XmlRpcBean 27 @ConverterMappings( @Mapping(type=URL.class,converter=URLConverter.class) ) 28 public class CoffeeBean 29 { 30 public URL getOrigin() 31 { 32 return mOrigin; 33 } 34 public void setOrigin( URL origin ) 35 { 36 mOrigin = origin; 37 } 38 public String getType() 39 { 40 return mType; 41 } 42 public void setType( String type ) 43 { 44 mType = type; 45 } 46 47 public String toString() 48 { 49 return( "CoffeeBean(" + getType() + ") comming from '" + getOrigin() + "'" ); 50 } 51 private String mType; 52 private URL mOrigin; 53 } 54 }}} 24 55 25 56 See also [http://delight.opendfki.de/wiki/ExampleUsingOwnConceteTypes#UsingowntypesinCollectionsandMaps How to use own types in Collections an Maps].