1 10 11 package org.mule.transformers; 12 13 import org.mule.config.i18n.Message; 14 import org.mule.config.i18n.Messages; 15 import org.mule.impl.RequestContext; 16 import org.mule.umo.UMOEventContext; 17 import org.mule.umo.transformer.TransformerException; 18 19 31 32 public abstract class AbstractEventAwareTransformer extends AbstractTransformer 33 { 34 public final Object doTransform(Object src, String encoding) throws TransformerException 35 { 36 UMOEventContext event = RequestContext.getEventContext(); 37 if (event == null && requiresCurrentEvent()) 38 { 39 throw new TransformerException(new Message(Messages.NO_CURRENT_EVENT_FOR_TRANSFORMER), this); 40 } 41 return transform(src, encoding, event); 42 } 43 44 public abstract Object transform(Object src, String encoding, UMOEventContext context) 45 throws TransformerException; 46 47 protected boolean requiresCurrentEvent() 48 { 49 return true; 50 } 51 } 52 | Popular Tags |