1 16 17 package org.apache.taglibs.jms; 18 19 import java.util.Iterator ; 20 import java.util.Map ; 21 22 import javax.jms.JMSException ; 23 import javax.jms.Message ; 24 import javax.jms.MapMessage ; 25 import javax.servlet.jsp.JspException ; 26 27 32 public class MapMessageTag extends MessageTag { 33 34 public MapMessageTag() { 35 } 36 37 public void addEntry(String name, Object value) throws JspException , JMSException { 38 MapMessage message = (MapMessage ) getMessage(); 39 message.setObject(name, value); 40 } 41 42 public void setMap(Map map) throws JspException , JMSException { 45 MapMessage message = (MapMessage ) getMessage(); 46 for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) { 47 Map.Entry entry = (Map.Entry ) iter.next(); 48 String name = entry.getKey().toString(); 49 Object value = entry.getValue(); 50 message.setObject(name, value); 51 } 52 } 53 54 protected Message createMessage() throws JspException , JMSException { 57 return getConnection().createMapMessage(); 58 } 59 } 60 | Popular Tags |