org.apache.muse.core.proxy
Class ReflectionProxyHandler

java.lang.Object
  extended by org.apache.muse.core.proxy.AbstractProxyHandler
      extended by org.apache.muse.core.proxy.ReflectionProxyHandler
All Implemented Interfaces:
ProxyHandler

public class ReflectionProxyHandler
extends AbstractProxyHandler

ReflectionProxyHandler is a generic implementation of ProxyHandler that can be applied to any web service operation. It uses reflection to determine what types are being sent to/from the operation and then invokes the Serializers that have been registered with Muse to do the XML/POJO transformations. If a type is used that is not included in Muse's set of built-in Serializers, you must register a Serializer for that type in order to take advantage of this class.

Author:
Dan Jemiolo (danj)
See Also:
Serializer

Constructor Summary
ReflectionProxyHandler()
           
 
Method Summary
protected  Object deserialize(Element xml, Class theClass)
          Deserializes the given DOM Element using the Serializer registered for the given type.
 Object fromXML(Element xml)
          Deserializes the given DOM Element into a POJO that can be returned to the invoker of the web service operation.
protected  Element serialize(Object obj, QName qname)
          Serializes the given object using the Serializer registered for the object's type.
 Element toXML(Object[] parameters)
          Serializes the given objects into a DOM Element that can used in a request SOAP Body.
 
Methods inherited from class org.apache.muse.core.proxy.AbstractProxyHandler
getAction, getRequestName, getRequestParameterNames, getRequestParameterSchemaTypes, getRequestParameterTypes, getResponseName, getReturnSchemaType, getReturnType, setAction, setRequestName, setRequestParameterNames, setRequestParameterSchemaTypes, setRequestParameterTypes, setResponseName, setReturnSchemaType, setReturnType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReflectionProxyHandler

public ReflectionProxyHandler()
Method Detail

deserialize

protected Object deserialize(Element xml,
                             Class theClass)
                      throws SoapFault
Deserializes the given DOM Element using the Serializer registered for the given type.

Parameters:
xml -
theClass -
Returns:
An instance of the given type, created from the given XML. If the type is null (or void), the method returns null.
Throws:
SoapFault -
  • If the XML cannot be deserialized to the given type.

fromXML

public Object fromXML(Element xml)
               throws SoapFault
Description copied from interface: ProxyHandler
Deserializes the given DOM Element into a POJO that can be returned to the invoker of the web service operation. Implementations should use Muse's registered Serializers in order to deserialize the XML into objects of the proper types.

Parameters:
xml - The contents of the response SOAP Body, where the root element contains either a simple value or a single child element that defines a complex type. Multiple return values will not be parsed - they must be part of a single data structure.
Returns:
The return value from the operation. This object will have the same type as getReturnType().
Throws:
SoapFault -
  • If the name of the element does not match the value of getResponseName().
  • If no serialization mechanism exists for the return value type.
  • If the XML could not be deserialized into an object.
See Also:
ProxyHandler.getReturnType(), Serializer.fromXML(Element)

serialize

protected Element serialize(Object obj,
                            QName qname)
                     throws SoapFault
Serializes the given object using the Serializer registered for the object's type. The XML is wrapped in an element whose name is the one given.

Parameters:
obj - The object to transform into XML.
qname - The name of the root Element returned by this method.
Returns:
The XML version of the object, wrapped in an element that has the given name.
Throws:
SoapFault -
  • If the object could not be serialized to XML.

toXML

public Element toXML(Object[] parameters)
              throws SoapFault
Description copied from interface: ProxyHandler
Serializes the given objects into a DOM Element that can used in a request SOAP Body. Implementations should use Muse's registered Serializers in order to serialize the objects into the proper formats.

Parameters:
parameters - The parameters for the operation, which must be serialized into XML.
Returns:
The XML equivalent of the given objects, wrapped in an element whose QName is the value of getRequestName(). Each object's XML fragment will be wrapped in the equivalent QName from the array returned by getRequestParameterNames().
Throws:
SoapFault -
  • If no serialization mechanism exists for an object's type.
  • If an object could not be serialized into XML.
See Also:
ProxyHandler.getRequestName(), ProxyHandler.getRequestParameterNames(), Serializer.toXML(Object, QName)


Copyright © 2005-2011 Apache Web Services - Muse. All Rights Reserved.