Announcement Announcement Module
Collapse
No announcement yet.
Examples on MessageInterceptor? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Examples on MessageInterceptor?

    Hi,

    are there any examples on MessageInterceptor? I have some Intertype declarations from AspectJ in my domain model. I would like to remove those fields when sending them to the client so they don't have any warnings about it. Can this be done with a MessageInterceptor? How?

    regards,

    Wim

  • #2
    I'm not familiar enough with ITD's to know exactly how you would go about removing them from an object instance at runtime, but it sounds like mainly you'll want to focus on using the postProcess method to manipulate the body of the outgoing Message. The body will be the actual Java object that is intended to be serialized to AMF (so the result of a remoting-destination invocation, for example).

    So something like this:
    Code:
    public class MyMessageInterceptor implements MessageInterceptor {
    
        public Message postProcess(MessageProcessingContext context, Message inputMessage, Message outputMessage) {
            Object result =  outputMessage.getBody();
            
            //...Do some sort of processing on result...
            
            outputMessage.setBody(result);
            
            return outputMessage;
        }
    
        public Message preProcess(MessageProcessingContext context, Message inputMessage) {
            //Don't need to process the incoming message, so just return it
            return inputMessage;
        }
    
    }

    Comment


    • #3
      Due to the ITD, we have to do something like this in ActionScript:

      public class MyClass
      {
      private var myProperty:Integer;
      private var ajc$interField$com_mycomp_MyAspect$myAspectPropert y:*;
      }

      The field is really added to the object, so I don't think I can remove it if the object is already created like in the postProcess method.

      I think I need to influence the conversion from the java object to the flex representation. Would that be possible?

      regards,

      Wim

      Comment


      • #4
        Yes, it is possible...see the following section from the BlazeDS docs on "Using custom serialization between ActionScript and Java":
        http://livedocs.adobe.com/blazeds/1/..._3.html#303410

        Comment

        Working...
        X