2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 package org.apache.log4j.or.jms;
20 import org.apache.log4j.helpers.LogLog;
21 import org.apache.log4j.or.ObjectRenderer;
23 import javax.jms.Message;
24 import javax.jms.JMSException;
25 import javax.jms.DeliveryMode;
28 Render <code>javax.jms.Message</code> objects.
30 @author Ceki Gülcü
32 public class MessageRenderer implements ObjectRenderer {
40 Render a {@link javax.jms.Message}.
43 String doRender(Object o) {
44 if(o instanceof Message) {
45 StringBuffer sbuf = new StringBuffer();
46 Message m = (Message) o;
48 sbuf.append("DeliveryMode=");
49 switch(m.getJMSDeliveryMode()) {
50 case DeliveryMode.NON_PERSISTENT :
51 sbuf.append("NON_PERSISTENT");
53 case DeliveryMode.PERSISTENT :
54 sbuf.append("PERSISTENT");
56 default: sbuf.append("UNKNOWN");
58 sbuf.append(", CorrelationID=");
59 sbuf.append(m.getJMSCorrelationID());
61 sbuf.append(", Destination=");
62 sbuf.append(m.getJMSDestination());
64 sbuf.append(", Expiration=");
65 sbuf.append(m.getJMSExpiration());
67 sbuf.append(", MessageID=");
68 sbuf.append(m.getJMSMessageID());
70 sbuf.append(", Priority=");
71 sbuf.append(m.getJMSPriority());
73 sbuf.append(", Redelivered=");
74 sbuf.append(m.getJMSRedelivered());
76 sbuf.append(", ReplyTo=");
77 sbuf.append(m.getJMSReplyTo());
79 sbuf.append(", Timestamp=");
80 sbuf.append(m.getJMSTimestamp());
82 sbuf.append(", Type=");
83 sbuf.append(m.getJMSType());
85 //Enumeration enum = m.getPropertyNames();
86 //while(enum.hasMoreElements()) {
87 // String key = (String) enum.nextElement();
88 // sbuf.append("; "+key+"=");
89 // sbuf.append(m.getStringProperty(key));
92 } catch(JMSException e) {
93 LogLog.error("Could not parse Message.", e);
95 return sbuf.toString();