Using Custom Type Marshallers in BlazeDS

In my previous post I pointed to the BlazeDS classes that need to be replaced in order to prevent ActionScript Number.NaN from turning into Long or Integer zeroes on the MessageBroker side. The recommendation boiled down to re-jaring flex-messaging-core.jar or placing the modified classes somewhere earlier in the application server’s classpath. If neither option is allowed, you may configure your endpoint with the custom type marshaller, like the one below:

        <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
           <endpoint url="http://{}:{server.port}/{context.root}/messagebroker/amf" 

In BlazeDS 4 you will base your type marshaller on
public class NullkeepingASTranslator extends
    private static final NumberDecoder numberDecoder = new NumberDecoder();  
    public Object convert(Object source, Class desiredClass)
      if ( DecoderFactory.isNumber(desiredClass)){
        return numberDecoder.decodeObject(source, desiredClass);
        return super.convert(source, desiredClass);

This route does not require neither server-level deployment nor modification of the flex-messaging-core.jar.

I’d like to use this opportunity and invite Flex developers living in Europe to attend our Advanced Flex Master Class in Brussels, Belgium on March 1 and 2, 2010.

Victor Rasputnis