org.spicefactory.cinnamon.io.mapping
Class ExternalizableClassMapping

java.lang.Object
  extended by org.spicefactory.cinnamon.io.mapping.AbstractClassMapping
      extended by org.spicefactory.cinnamon.io.mapping.ExternalizableClassMapping
All Implemented Interfaces:
ClassMapping

public class ExternalizableClassMapping
extends AbstractClassMapping

ClassMapping implementation responsible for mapping ActionScript classes that implement flash.utils.IExternalizable. Additionally these classes must have an alias registered in ActionScript with flash.net.registerClassAlias or the [RemoteClass] metadata tag (which only works in Flex applications).

This implementation basically just delegates the task of encoding/decoding the object to/from AMF3 binary data to the classes that implement Externalizable or Externalizer

Author:
Jens Halm

Constructor Summary
ExternalizableClassMapping(String alias, String actionScriptClass, Class<?> javaClass, Class<?> javaFactory, Class<?> externalizerClass)
           
 
Method Summary
 void init(CinnamonConfig config)
          Initialization method that will be called once for each ClassMapping instance at application startup.
 Object newJavaInstance()
          Creates a new instance of the mapped Java class.
 void readObject(Object instance, AMFInput input, ObjectEncoding encoding, String[] propertyNames)
          Restores the content of the given object from the AMFInput instance.
 String toString()
           
 void writeObject(Object instance, AMFOutput output)
          Writes the content of the specified object to the given AMFOutput.
 
Methods inherited from class org.spicefactory.cinnamon.io.mapping.AbstractClassMapping
getActionScriptClass, getAlias, getEncoding, getJavaClass, getJavaFactory, getPropertyNames, setPropertyNames, writeClassDescriptor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExternalizableClassMapping

public ExternalizableClassMapping(String alias,
                                  String actionScriptClass,
                                  Class<?> javaClass,
                                  Class<?> javaFactory,
                                  Class<?> externalizerClass)
Method Detail

init

public void init(CinnamonConfig config)
Description copied from interface: ClassMapping
Initialization method that will be called once for each ClassMapping instance at application startup.

Parameters:
config - the Cinnamon configuration instance

newJavaInstance

public Object newJavaInstance()
Description copied from interface: ClassMapping
Creates a new instance of the mapped Java class.

Returns:
a new instance of the mapped Java class

readObject

public void readObject(Object instance,
                       AMFInput input,
                       ObjectEncoding encoding,
                       String[] propertyNames)
Description copied from interface: ClassMapping
Restores the content of the given object from the AMFInput instance.

Parameters:
instance - the object to be restored
input - the AMF3 data to read from
encoding - the type of object encoding to use
propertyNames - the names of the properties of the object (may be empty for some kinds of mappings)

writeObject

public void writeObject(Object instance,
                        AMFOutput output)
Description copied from interface: ClassMapping
Writes the content of the specified object to the given AMFOutput.

Parameters:
instance - the object to be serialized
output - the output to write to

toString

public String toString()
Overrides:
toString in class AbstractClassMapping