springapache-flexserializationdeserializationblazeds

Flex: BlazeDs deserialization


I'm working on a webapp built using Spring + Flex. Communication between front and back uses BlazeDS and I have a custom marshaller in order to serialize data from flex to backend as:

<channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
        <endpoint url="http://localhost:8080/${context.root.cpanel}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
        <properties>    
            <serialization>
                <type-marshaller>es.onebox.flex.messaging.io.CustomTypeMarshaller</type-marshaller>
            </serialization>
        </properties>
    </channel-definition>

Is there a way to configure how use a custom de-serializer from back to flex ? I need an interceptor to modify some fields of data sent from back to flex so I think this approach could work.


Solution

  • I've used an interceptor for Flex using:

    <flex:message-interceptor ref="myMessageInterceptor"/>
    

    And on my application.xml I've defined myMessageInterceptor as:

    <bean id="myMessageInterceptor" class="es.onebox.flex.messaging.io.FlexInterceptor"/>
    

    And this is de content of the interceptor:

    public class FlexInterceptor implements ResourceHandlingMessageInterceptor
    {
    private static Logger logger = Logger.getLogger(FlexInterceptor.class);
    
    public void afterCompletion(MessageProcessingContext context, Message inputMessage, Message outputMessage, Exception ex)
    {
        logger.info(inputMessage.getMessageId());
    }
    
    public Message postProcess(MessageProcessingContext context, Message inputMessage, Message outputMessage)
    {
        return outputMessage;
    }
    
    public Message preProcess(MessageProcessingContext context, Message inputMessage) {
        return inputMessage;
    }
    

    }