1 16 17 package org.apache.log4j.or.jms; 18 19 import org.apache.log4j.helpers.LogLog; 20 import org.apache.log4j.or.ObjectRenderer; 21 22 import javax.jms.Message ; 23 import javax.jms.JMSException ; 24 import javax.jms.DeliveryMode ; 25 26 31 public class MessageRenderer implements ObjectRenderer { 32 33 public 34 MessageRenderer() { 35 } 36 37 38 41 public 42 String doRender(Object o) { 43 if(o instanceof Message ) { 44 StringBuffer sbuf = new StringBuffer (); 45 Message m = (Message ) o; 46 try { 47 sbuf.append("DeliveryMode="); 48 switch(m.getJMSDeliveryMode()) { 49 case DeliveryMode.NON_PERSISTENT : 50 sbuf.append("NON_PERSISTENT"); 51 break; 52 case DeliveryMode.PERSISTENT : 53 sbuf.append("PERSISTENT"); 54 break; 55 default: sbuf.append("UNKNOWN"); 56 } 57 sbuf.append(", CorrelationID="); 58 sbuf.append(m.getJMSCorrelationID()); 59 60 sbuf.append(", Destination="); 61 sbuf.append(m.getJMSDestination()); 62 63 sbuf.append(", Expiration="); 64 sbuf.append(m.getJMSExpiration()); 65 66 sbuf.append(", MessageID="); 67 sbuf.append(m.getJMSMessageID()); 68 69 sbuf.append(", Priority="); 70 sbuf.append(m.getJMSPriority()); 71 72 sbuf.append(", Redelivered="); 73 sbuf.append(m.getJMSRedelivered()); 74 75 sbuf.append(", ReplyTo="); 76 sbuf.append(m.getJMSReplyTo()); 77 78 sbuf.append(", Timestamp="); 79 sbuf.append(m.getJMSTimestamp()); 80 81 sbuf.append(", Type="); 82 sbuf.append(m.getJMSType()); 83 84 91 } catch(JMSException e) { 92 LogLog.error("Could not parse Message.", e); 93 } 94 return sbuf.toString(); 95 } else { 96 return o.toString(); 97 } 98 } 99 } 100 | Popular Tags |