1 10 11 package org.mule.providers.gs.transformers; 12 13 import java.util.HashMap ; 14 import java.util.Iterator ; 15 import java.util.Map ; 16 17 import net.jini.core.entry.Entry; 18 19 import org.mule.providers.gs.JiniMessage; 20 import org.mule.transformers.AbstractEventAwareTransformer; 21 import org.mule.umo.UMOEventContext; 22 import org.mule.umo.UMOMessage; 23 import org.mule.umo.transformer.TransformerException; 24 25 30 public class UMOMessageToJavaSpaceEntry extends AbstractEventAwareTransformer 31 { 32 35 private static final long serialVersionUID = -6852740125237850362L; 36 37 public UMOMessageToJavaSpaceEntry() 38 { 39 setReturnClass(Entry.class); 40 } 41 42 public Object transform(Object src, String encoding, UMOEventContext context) throws TransformerException 43 { 44 if (src instanceof Entry) 45 { 46 return src; 47 } 48 else 49 { 50 String destination = context.getEndpointURI().toString(); 51 UMOMessage muleMessage = context.getMessage(); 52 53 JiniMessage msg = new JiniMessage(destination, src); 54 msg.setMessageId(muleMessage.getUniqueId()); 55 msg.setCorrelationId(muleMessage.getCorrelationId()); 56 msg.setCorrelationGroupSize(new Integer (muleMessage.getCorrelationGroupSize())); 57 msg.setCorrelationSequence(new Integer (muleMessage.getCorrelationSequence())); 58 msg.setReplyTo(muleMessage.getReplyTo()); 59 msg.setEncoding(muleMessage.getEncoding()); 60 msg.setExceptionPayload(muleMessage.getExceptionPayload()); 61 62 Map props = new HashMap (); 63 for (Iterator iterator = muleMessage.getPropertyNames().iterator(); iterator.hasNext();) 64 { 65 String key = (String )iterator.next(); 66 props.put(key, muleMessage.getProperty(key)); 67 } 68 69 msg.setProperties(props); 70 return msg; 71 } 72 } 73 74 } 75 | Popular Tags |