1 10 11 package org.mule.interceptors; 12 13 import org.mule.config.MuleProperties; 14 import org.mule.impl.RequestContext; 15 import org.mule.umo.Invocation; 16 import org.mule.umo.UMOException; 17 import org.mule.umo.UMOInterceptor; 18 import org.mule.umo.UMOMessage; 19 20 35 public abstract class MessageNormalizerInterceptor implements UMOInterceptor 36 { 37 private Object originalPayload = null; 38 39 44 public abstract UMOMessage before(Invocation invocation) throws UMOException; 45 46 51 public abstract UMOMessage after(Invocation invocation) throws UMOException; 52 53 public final UMOMessage intercept(Invocation invocation) throws UMOException 54 { 55 originalPayload = invocation.getEvent().getTransformedMessage(); 57 58 UMOMessage bMessage = before(invocation); 60 if (bMessage != null) 61 { 62 RequestContext.rewriteEvent(bMessage); 64 invocation.setMessage(bMessage); 66 invocation.getMessage().removeProperty(MuleProperties.MULE_METHOD_PROPERTY); 69 } 70 UMOMessage message = invocation.execute(); 72 invocation.setMessage(message); 74 UMOMessage aMessage = after(invocation); 75 if (aMessage == null) 76 { 77 return message; 78 } 79 else 80 { 81 return aMessage; 82 } 83 } 84 85 protected Object getOriginalPayload() 86 { 87 return originalPayload; 88 } 89 90 protected void setOriginalPayload(Object originalPayload) 91 { 92 this.originalPayload = originalPayload; 93 } 94 } 95 | Popular Tags |