org.apache.muse.core.serializer
Interface Serializer

All Known Implementing Classes:
ArraySerializer, BooleanSerializer, DateSerializer, DoubleSerializer, ElementSerializer, FilterSerializer, FloatSerializer, IntegerSerializer, LongSerializer, MembershipContentRuleSerializer, NotificationMessageSerializer, QNameSerializer, ShortSerializer, StringSerializer, UriSerializer, UrlSerializer, XmlSerializableSerializer

public interface Serializer

Serializer is a simple interface for serializing and deserializing individual objects to and from XML. It is different from the MessageHandler class because it is unaware of SOAP messages - it can only deal with one object at a time. This interface should be used to provide serialization for user-defined types that are exposed in web service parameter lists or return types.

New Serializers can be introduced to Muse by adding the following XML to the Muse deployment descriptor (muse.xml):

<custom-serializer>
   <java-serializable-type>the new type</java-concrete-class>
   <java-serializer-class>the type's serializer</java-serializer-class>
</custom-serializer>

This package contains many Serializers for built-in types, including primitives and simple types. These built-in types have their Serializers loaded at startup by Muse.

Author:
Dan Jemiolo (danj)

Method Summary
 Object fromXML(Element xml)
          Deserializes the DOM Element into a POJO whose type this Serializer is responsible for.
 Class getSerializableType()
           
 Element toXML(Object obj, QName qname)
          Serializes the given object into a DOM Element, the value wrapped inside a root element with the given name.
 

Method Detail

fromXML

Object fromXML(Element xml)
               throws SoapFault
Deserializes the DOM Element into a POJO whose type this Serializer is responsible for.

Parameters:
xml - The XML representation of a Java object. If the type is primitive or simple (not a primitive, but serialized to a string), the value should be a DOM Text node inside the given Element.
Returns:
A POJO constructed from the given XML. If the Element is empty and the Serializer's type is a non-primitive, the method will return null.
Throws:
SoapFault -
  • If the XML is not a valid representation of the Serializer's type.

getSerializableType

Class getSerializableType()

toXML

Element toXML(Object obj,
              QName qname)
              throws SoapFault
Serializes the given object into a DOM Element, the value wrapped inside a root element with the given name.

Parameters:
obj - The object to serialize into XML, or null.
qname - The name of the element which the XML representation will be wrapped in.
Returns:
An Element whose name is the one given, and whose child Nodes represent the object. If the object was null, an empty Element is returned.
Throws:
SoapFault -
  • If the object could not be serialized to XML.


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