Package de.dfki.util.xmlrpc.conversion

Examples of de.dfki.util.xmlrpc.conversion.XmlRpcBeanConverter


        if (xmlRpcBeanAnno != null)
        {
            try
            {
                xmlRpcType = Type.STRUCT;
                ParameterConverter<?,?> c = new XmlRpcBeanConverter( apiParameterClass );
           
                //register a converter for especially for this bean type
                ParameterConverterRegistry.setParameterConverterForClass( apiParameterClass, c );
               
                ParameterConverterRegistry.readParameterConverterMappingsFromApiClass( apiParameterClass );
            }
            catch( Exception e )
            {
                throw( new TypeConversionException( "Error creating bean converter:", e ) );
            }
        }
       
        //second: annotations for used types
        XmlRpc xmlRpcAnno = AnnotationUtils.getAnnotationForClass( apiParameterClass, XmlRpc.class );
        if( xmlRpcAnno != null )
        {
            xmlRpcType = xmlRpcAnno.type();
            convertableCls = xmlRpcAnno.concrete();
            separateConverterCls = xmlRpcAnno.converter();
           
            //usesConvertable = a concete class != parameter class does conversion
            boolean usesConvertable = !convertableCls.equals( NoParameterBoundConverter.class );
           
            //usesConverter = a seperate converter does conversion
            boolean usesConverter = !separateConverterCls.equals( NoSeparateParameterConverter.class );
           
            //isConvertable = the parameter does the work itself
            boolean isConvertable = !usesConvertable && !usesConverter;
           
            if (usesConvertable && usesConverter)
            {
                throw( new AnnotationException( "Parameter can only be either a convertable or use a parameter converter, not both at a time!" ) );
            }
           
            if (isConvertable)
            {
                convertableCls = validateConvertableClass( apiParameterClass, xmlRpcType );
            }
            else if (usesConvertable)
            {
                validateConvertableClass( convertableCls, xmlRpcType );
            }
            else if (usesConverter)
            {
                checkParameterConverter( separateConverterCls, xmlRpcType );
            }
        }
       
        ParameterConverter<?,?> converter = ParameterConverterRegistry.getParameterConverterByClass( separateConverterCls );
        if (converter == null)
        {
            //maybe a mapping
            converter = ParameterConverterRegistry.getParameterConverterForClass( apiParameterClass );
        }
     
        if( converter != null )
        {
            xmlRpcType = converter.getXmlRpcRepresentationType();
        }

        if( xmlRpcType == null && !isXmlRpcCompatible
                        && de.dfki.util.xmlrpc.XmlRpc.treatUnknownTypesAsBeans() )
        {
            //the last chance: treat this type as a bean
            log().info( "Found XML-RPC unaware type '" + apiParameterClass.getName() + "' treating it as XmlRpcBean!" );
            converter = new XmlRpcBeanConverter( apiParameterClass );
            xmlRpcType = converter.getXmlRpcRepresentationType();
           
            ParameterConverterRegistry.setParameterConverterForClass( apiParameterClass, converter );
            log().info( "XmlRpcBeanConverter registered for " + apiParameterClass );
        }
View Full Code Here

TOP

Related Classes of de.dfki.util.xmlrpc.conversion.XmlRpcBeanConverter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.