KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > mq > SpyMessage


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.mq;
23
24 import java.io.Externalizable JavaDoc;
25 import java.io.IOException JavaDoc;
26 import java.io.ObjectInput JavaDoc;
27 import java.io.ObjectOutput JavaDoc;
28 import java.io.Serializable JavaDoc;
29 import java.util.Collections JavaDoc;
30 import java.util.Enumeration JavaDoc;
31 import java.util.HashMap JavaDoc;
32 import java.util.HashSet JavaDoc;
33 import java.util.Map JavaDoc;
34
35 import javax.jms.Destination JavaDoc;
36 import javax.jms.JMSException JavaDoc;
37 import javax.jms.Message JavaDoc;
38 import javax.jms.MessageFormatException JavaDoc;
39 import javax.jms.MessageNotWriteableException JavaDoc;
40 import javax.jms.Session JavaDoc;
41
42 import org.jboss.util.Primitives;
43 import org.jboss.util.Strings;
44
45 /**
46  * This class implements javax.jms.Message
47  *
48  * @author Norbert Lataille (Norbert.Lataille@m4x.org)
49  * @author Hiram Chirino (Cojonudo14@hotmail.com)
50  * @author David Maplesden (David.Maplesden@orion.co.nz)
51  * @author <a HREF="mailto:adrian@jboss.org">Adrian Brock</a>
52  * @version $Revision: 38291 $
53  */

54 public class SpyMessage implements Serializable JavaDoc, Message JavaDoc, Comparable JavaDoc, Cloneable JavaDoc, Externalizable JavaDoc
55 {
56    // Constants -----------------------------------------------------
57

58    /** The serialVersionUID */
59    private final static long serialVersionUID = 467206190892964404L;
60
61    /**
62     * Standard property for delivery count
63     */

64    public static final String JavaDoc PROPERTY_DELIVERY_COUNT = "JMSXDeliveryCount";
65
66    /**
67      * JBoss-vendor specific property for scheduling a JMS message. In
68      * milliseconds since January 1, 1970.
69      */

70    public static final String JavaDoc PROPERTY_SCHEDULED_DELIVERY = "JMS_JBOSS_SCHEDULED_DELIVERY";
71
72    /**
73      * JBoss-vendor specific property specifying redelivery delay of a message.
74      * The message will be rescheduled for delivery from the time at which it
75      * was unacknowledged, plus the given period.
76      */

77    public static final String JavaDoc PROPERTY_REDELIVERY_DELAY = "JMS_JBOSS_REDELIVERY_DELAY";
78
79    /**
80      * JBoss-vendor specific property for getting the count of redelivery
81      * attempts of a message.
82      */

83    public static final String JavaDoc PROPERTY_REDELIVERY_COUNT = "JMS_JBOSS_REDELIVERY_COUNT";
84
85    /**
86      * JBoss-vendor specific property specifying the limit of redelivery
87      * attempts of a message. The message will be redelivered a given number of
88      * times. If not set, the container default is used.
89      */

90    public static final String JavaDoc PROPERTY_REDELIVERY_LIMIT = "JMS_JBOSS_REDELIVERY_LIMIT";
91
92    /**
93    * JBoss-vendor property name holding original destination.
94    */

95    public static final String JavaDoc PROPERTY_ORIG_DESTINATION = "JBOSS_ORIG_DESTINATION";
96
97    /**
98    * JBoss-vendor property name holding original expiration value.
99    */

100    public static final String JavaDoc PROPERTY_ORIG_EXPIRATION = "JBOSS_ORIG_EXPIRATION";
101
102    /**
103    * JBoss-vendor property name holding original message ID value.
104    */

105    public static final String JavaDoc PROPERTY_ORIG_MESSAGEID = "JBOSS_ORIG_MESSAGEID";
106
107    /** An object message */
108    protected static final byte OBJECT_MESS = 1;
109    /** An bytes message */
110    protected static final byte BYTES_MESS = 2;
111    /** A map message */
112    protected static final byte MAP_MESS = 3;
113    /** A text message */
114    protected static final byte TEXT_MESS = 4;
115    /** A stream message */
116    protected static final byte STREAM_MESS = 5;
117    /** An encapsulated message */
118    protected static final byte ENCAP_MESS = 6;
119    /** A plain message */
120    protected static final byte SPY_MESS = 7;
121
122    /** A byte property */
123    protected static final int BYTE = 0;
124    /** A short property */
125    protected static final int SHORT = 1;
126    /** An integer property */
127    protected static final int INT = 2;
128    /** A long property */
129    protected static final int LONG = 3;
130    /** A float property */
131    protected static final int FLOAT = 4;
132    /** A double property */
133    protected static final int DOUBLE = 5;
134    /** A boolean property */
135    protected static final int BOOLEAN = 6;
136    /** A string property */
137    protected static final int STRING = 7;
138    /** An object property */
139    protected static final int OBJECT = 8;
140    /** A null property */
141    protected static final int NULL = 9;
142
143    /** Reserved identifiers */
144    private static final HashSet JavaDoc reservedIdentifiers = new HashSet JavaDoc();
145
146    // Attributes ----------------------------------------------------
147

148    /** The message header */
149    public Header header = new Header();
150
151    /** The acknowledgement request for this message */
152    public transient AcknowledgementRequest ack;
153
154    /** The session for this message */
155    public transient SpySession session;
156
157    // Static --------------------------------------------------------
158

159    static
160    {
161       reservedIdentifiers.add("NULL");
162       reservedIdentifiers.add("TRUE");
163       reservedIdentifiers.add("FALSE");
164       reservedIdentifiers.add("NOT");
165       reservedIdentifiers.add("AND");
166       reservedIdentifiers.add("OR");
167       reservedIdentifiers.add("BETWEEN");
168       reservedIdentifiers.add("LIKE");
169       reservedIdentifiers.add("IN");
170       reservedIdentifiers.add("IS");
171       reservedIdentifiers.add("ESCAPE");
172    }
173
174    /**
175      * Write a message
176      *
177      * @param message the message
178      * @param out the output
179      * @throws IOException for any error
180      */

181    public static void writeMessage(SpyMessage message, ObjectOutput JavaDoc out) throws IOException JavaDoc
182    {
183       if (message instanceof SpyEncapsulatedMessage)
184          out.writeByte(ENCAP_MESS);
185       else if (message instanceof SpyObjectMessage)
186          out.writeByte(OBJECT_MESS);
187       else if (message instanceof SpyBytesMessage)
188          out.writeByte(BYTES_MESS);
189       else if (message instanceof SpyMapMessage)
190          out.writeByte(MAP_MESS);
191       else if (message instanceof SpyTextMessage)
192          out.writeByte(TEXT_MESS);
193       else if (message instanceof SpyStreamMessage)
194          out.writeByte(STREAM_MESS);
195       else
196          out.writeByte(SPY_MESS);
197       message.writeExternal(out);
198    }
199
200    /**
201      * Read a message
202      *
203      * @param in the input
204      * @return the message
205      * @throws IOException for any error
206      */

207    public static SpyMessage readMessage(ObjectInput JavaDoc in) throws IOException JavaDoc
208    {
209       SpyMessage message = null;
210       byte type = in.readByte();
211       switch (type)
212       {
213          case OBJECT_MESS :
214             message = MessagePool.getObjectMessage();
215             break;
216          case BYTES_MESS :
217             message = MessagePool.getBytesMessage();
218             break;
219          case MAP_MESS :
220             message = MessagePool.getMapMessage();
221             break;
222          case STREAM_MESS :
223             message = MessagePool.getStreamMessage();
224             break;
225          case TEXT_MESS :
226             message = MessagePool.getTextMessage();
227             break;
228          case ENCAP_MESS :
229             message = MessagePool.getEncapsulatedMessage();
230             break;
231          default :
232             message = MessagePool.getMessage();
233       }
234       try
235       {
236          message.readExternal(in);
237       }
238       catch (ClassNotFoundException JavaDoc cnf)
239       {
240          throw new IOException JavaDoc("Class not found when reading in spy message.");
241       }
242       return message;
243    }
244
245    // Constructors --------------------------------------------------
246

247    // Public --------------------------------------------------------
248

249    /**
250     * Clear the message body
251     *
252     * @throws JMSException for any error
253     */

254    public void clearBody() throws JMSException JavaDoc
255    {
256       //Inherited classes clear their content here
257
header.msgReadOnly = false;
258    }
259
260    /**
261     * Acknowledge a message
262     *
263     * @throws JMSException for any error
264     */

265    public void acknowledge() throws JMSException JavaDoc
266    {
267       if (session == null)
268          throw new JMSException JavaDoc("This message was not recieved from the provider");
269
270       if (session.acknowledgeMode == Session.CLIENT_ACKNOWLEDGE)
271          doAcknowledge();
272    }
273
274    /**
275     * Set the message to read only
276     */

277    public void setReadOnlyMode()
278    {
279       header.jmsPropertiesReadWrite = false;
280       header.msgReadOnly = true;
281    }
282
283    /**
284     * Clone the message
285     *
286     * @return the cloned message
287     * @throws JMSException for any error
288     */

289    public SpyMessage myClone() throws JMSException JavaDoc
290    {
291       SpyMessage result = MessagePool.getMessage();
292       result.copyProps(this);
293       return result;
294    }
295
296    /**
297     * Copy the properties
298     *
299     * @param original the message with original properties
300     * @throws JMSException for any error
301     */

302    public void copyProps(SpyMessage original) throws JMSException JavaDoc
303    {
304       try
305       {
306          this.setJMSCorrelationID(original.getJMSCorrelationID());
307       }
308       catch (JMSException JavaDoc e)
309       {
310          //must be as bytes
311
this.setJMSCorrelationIDAsBytes(original.getJMSCorrelationIDAsBytes());
312       }
313       this.setJMSDeliveryMode(original.getJMSDeliveryMode());
314       this.setJMSDestination(original.getJMSDestination());
315       this.setJMSExpiration(original.getJMSExpiration());
316       this.setJMSMessageID(original.getJMSMessageID());
317       this.setJMSPriority(original.getJMSPriority());
318       this.setJMSRedelivered(original.getJMSRedelivered());
319       this.setJMSReplyTo(original.getJMSReplyTo());
320       this.setJMSTimestamp(original.getJMSTimestamp());
321       this.setJMSType(original.getJMSType());
322       this.header.jmsProperties.putAll(original.header.jmsProperties);
323
324       //Spy Message special header.jmsPropertiess
325
this.header.jmsPropertiesReadWrite = original.header.jmsPropertiesReadWrite;
326       this.header.msgReadOnly = original.header.msgReadOnly;
327       this.header.producerClientId = original.header.producerClientId;
328       if (original.header.durableSubscriberID != null)
329          this.header.durableSubscriberID = new DurableSubscriptionID(original.header.durableSubscriberID.clientID,
330                original.header.durableSubscriberID.subscriptionName, original.header.durableSubscriberID.selector);
331    }
332
333    /**
334      * Test whether a message has expired
335      *
336      * @return true when expired false otherwise
337      */

338    public boolean isOutdated()
339    {
340       if (header.jmsExpiration == 0)
341          return false;
342       long ts = System.currentTimeMillis();
343       return header.jmsExpiration < ts;
344    }
345
346    /**
347     * Actually acknowledge a message
348     *
349     * @throws JMSException for any error
350     */

351    public void doAcknowledge() throws JMSException JavaDoc
352    {
353       session.doAcknowledge(this, getAcknowledgementRequest(true));
354    }
355
356    /**
357     * Create an acknowledgement request for the message
358     */

359    public void createAcknowledgementRequest(int subscriptionId)
360    {
361       ack = new AcknowledgementRequest();
362       ack.destination = header.jmsDestination;
363       ack.messageID = header.jmsMessageID;
364       ack.subscriberId = subscriptionId;
365    }
366
367    /**
368     * Get an acknowledgement request for the message
369     *
370     * @param isAck true for an ack, false for a nack
371     * @throws JMSException for any error
372     */

373    public AcknowledgementRequest getAcknowledgementRequest(boolean isAck) throws JMSException JavaDoc
374    {
375       //don't know if we have to copy but to be on safe side...
376
AcknowledgementRequest item = new AcknowledgementRequest(isAck);
377       item.destination = ack.destination;
378       item.messageID = ack.messageID;
379       item.subscriberId = ack.subscriberId;
380       return item;
381    }
382
383    // Comparable implementation -------------------------------------
384

385    public int compareTo(Object JavaDoc o)
386    {
387       SpyMessage sm = (SpyMessage) o;
388
389       if (header.jmsPriority > sm.header.jmsPriority)
390       {
391          return -1;
392       }
393       if (header.jmsPriority < sm.header.jmsPriority)
394       {
395          return 1;
396       }
397       return (int) (header.messageId - sm.header.messageId);
398    }
399
400    // Message implementation ----------------------------------------
401

402    public String JavaDoc getJMSMessageID()
403    {
404       return header.jmsMessageID;
405    }
406
407    public void setJMSMessageID(String JavaDoc id) throws JMSException JavaDoc
408    {
409       header.jmsMessageID = id;
410    }
411
412    public long getJMSTimestamp()
413    {
414       return header.jmsTimeStamp;
415    }
416
417    public void setJMSTimestamp(long timestamp) throws JMSException JavaDoc
418    {
419       header.jmsTimeStamp = timestamp;
420    }
421
422    public byte[] getJMSCorrelationIDAsBytes() throws JMSException JavaDoc
423    {
424       if (header.jmsCorrelationID)
425          throw new JMSException JavaDoc("JMSCorrelationID is a string");
426       return header.jmsCorrelationIDbyte;
427    }
428
429    public void setJMSCorrelationIDAsBytes(byte[] correlationID) throws JMSException JavaDoc
430    {
431       header.jmsCorrelationID = false;
432       header.jmsCorrelationIDbyte = (byte[]) correlationID.clone();
433       header.jmsCorrelationIDString = null;
434    }
435
436    public void setJMSCorrelationID(String JavaDoc correlationID) throws JMSException JavaDoc
437    {
438       header.jmsCorrelationID = true;
439       header.jmsCorrelationIDString = correlationID;
440       header.jmsCorrelationIDbyte = null;
441    }
442
443    public String JavaDoc getJMSCorrelationID() throws JMSException JavaDoc
444    {
445       if (!header.jmsCorrelationID)
446          throw new JMSException JavaDoc("JMSCorrelationID is an array");
447       return header.jmsCorrelationIDString;
448    }
449
450    public Destination JavaDoc getJMSReplyTo()
451    {
452       return header.jmsReplyTo;
453    }
454
455    public void setJMSReplyTo(Destination JavaDoc replyTo) throws JMSException JavaDoc
456    {
457       header.jmsReplyTo = replyTo;
458    }
459
460    public Destination JavaDoc getJMSDestination()
461    {
462       return header.jmsDestination;
463    }
464
465    public void setJMSDestination(Destination JavaDoc destination) throws JMSException JavaDoc
466    {
467       header.jmsDestination = destination;
468    }
469
470    public int getJMSDeliveryMode()
471    {
472       return header.jmsDeliveryMode;
473    }
474
475    public void setJMSDeliveryMode(int deliveryMode) throws JMSException JavaDoc
476    {
477       header.jmsDeliveryMode = deliveryMode;
478    }
479
480    public boolean getJMSRedelivered()
481    {
482       return header.jmsRedelivered;
483    }
484
485    public void setJMSRedelivered(boolean redelivered) throws JMSException JavaDoc
486    {
487       header.jmsRedelivered = redelivered;
488    }
489
490    public String JavaDoc getJMSType()
491    {
492       return header.jmsType;
493    }
494
495    public void setJMSType(String JavaDoc type) throws JMSException JavaDoc
496    {
497       header.jmsType = type;
498    }
499
500    public long getJMSExpiration()
501    {
502       return header.jmsExpiration;
503    }
504
505    public void setJMSExpiration(long expiration) throws JMSException JavaDoc
506    {
507       header.jmsExpiration = expiration;
508    }
509
510    public int getJMSPriority()
511    {
512       return header.jmsPriority;
513    }
514
515    public void setJMSPriority(int priority) throws JMSException JavaDoc
516    {
517       if (priority < 0 || priority > 10)
518          throw new JMSException JavaDoc("Unsupported priority '" + priority + "': priority must be from 0-10");
519       header.jmsPriority = priority;
520    }
521
522    public void clearProperties() throws JMSException JavaDoc
523    {
524       header.jmsProperties.clear();
525       header.jmsPropertiesReadWrite = true;
526    }
527
528    public boolean propertyExists(String JavaDoc name) throws JMSException JavaDoc
529    {
530       return header.jmsProperties.containsKey(name);
531    }
532
533    public boolean getBooleanProperty(String JavaDoc name) throws JMSException JavaDoc
534    {
535       Object JavaDoc value = header.jmsProperties.get(name);
536       if (value == null)
537          return Boolean.valueOf(null).booleanValue();
538
539       if (value instanceof Boolean JavaDoc)
540          return ((Boolean JavaDoc) value).booleanValue();
541       else if (value instanceof String JavaDoc)
542          return Boolean.valueOf((String JavaDoc) value).booleanValue();
543       else
544          throw new MessageFormatException JavaDoc("Invalid conversion");
545    }
546
547    public byte getByteProperty(String JavaDoc name) throws JMSException JavaDoc
548    {
549       Object JavaDoc value = header.jmsProperties.get(name);
550       if (value == null)
551          throw new NumberFormatException JavaDoc("Message property '" + name + "' not set.");
552
553       if (value instanceof Byte JavaDoc)
554          return ((Byte JavaDoc) value).byteValue();
555       else if (value instanceof String JavaDoc)
556          return Byte.parseByte((String JavaDoc) value);
557       else
558          throw new MessageFormatException JavaDoc("Invalid conversion");
559    }
560
561    public short getShortProperty(String JavaDoc name) throws JMSException JavaDoc
562    {
563       Object JavaDoc value = header.jmsProperties.get(name);
564       if (value == null)
565          throw new NumberFormatException JavaDoc("Message property '" + name + "' not set.");
566
567       if (value instanceof Byte JavaDoc)
568          return ((Byte JavaDoc) value).shortValue();
569       else if (value instanceof Short JavaDoc)
570          return ((Short JavaDoc) value).shortValue();
571       else if (value instanceof String JavaDoc)
572          return Short.parseShort((String JavaDoc) value);
573       else
574          throw new MessageFormatException JavaDoc("Invalid conversion");
575    }
576
577    public int getIntProperty(String JavaDoc name) throws JMSException JavaDoc
578    {
579       Object JavaDoc value = header.jmsProperties.get(name);
580       if (value == null)
581          throw new NumberFormatException JavaDoc("Message property '" + name + "' not set.");
582
583       if (value instanceof Byte JavaDoc)
584          return ((Byte JavaDoc) value).intValue();
585       else if (value instanceof Short JavaDoc)
586          return ((Short JavaDoc) value).intValue();
587       else if (value instanceof Integer JavaDoc)
588          return ((Integer JavaDoc) value).intValue();
589       else if (value instanceof String JavaDoc)
590          return Integer.parseInt((String JavaDoc) value);
591       else
592          throw new MessageFormatException JavaDoc("Invalid conversion");
593    }
594
595    public long getLongProperty(String JavaDoc name) throws JMSException JavaDoc
596    {
597       Object JavaDoc value = header.jmsProperties.get(name);
598       if (value == null)
599          throw new NumberFormatException JavaDoc("Message property '" + name + "' not set.");
600
601       if (value instanceof Byte JavaDoc)
602          return ((Byte JavaDoc) value).longValue();
603       else if (value instanceof Short JavaDoc)
604          return ((Short JavaDoc) value).longValue();
605       else if (value instanceof Integer JavaDoc)
606          return ((Integer JavaDoc) value).longValue();
607       else if (value instanceof Long JavaDoc)
608          return ((Long JavaDoc) value).longValue();
609       else if (value instanceof String JavaDoc)
610          return Long.parseLong((String JavaDoc) value);
611       else
612          throw new MessageFormatException JavaDoc("Invalid conversion");
613    }
614
615    public float getFloatProperty(String JavaDoc name) throws JMSException JavaDoc
616    {
617       Object JavaDoc value = header.jmsProperties.get(name);
618       if (value == null)
619          return Float.valueOf(null).floatValue();
620
621       if (value instanceof Float JavaDoc)
622          return ((Float JavaDoc) value).floatValue();
623       else if (value instanceof String JavaDoc)
624          return Float.parseFloat((String JavaDoc) value);
625       else
626          throw new MessageFormatException JavaDoc("Invalid conversion");
627    }
628
629    public double getDoubleProperty(String JavaDoc name) throws JMSException JavaDoc
630    {
631       Object JavaDoc value = header.jmsProperties.get(name);
632       if (value == null)
633          return Double.valueOf(null).doubleValue();
634
635       if (value instanceof Float JavaDoc)
636          return ((Float JavaDoc) value).doubleValue();
637       else if (value instanceof Double JavaDoc)
638          return ((Double JavaDoc) value).doubleValue();
639       else if (value instanceof String JavaDoc)
640          return Double.parseDouble((String JavaDoc) value);
641       else
642          throw new MessageFormatException JavaDoc("Invalid conversion");
643    }
644
645    public String JavaDoc getStringProperty(String JavaDoc name) throws JMSException JavaDoc
646    {
647       Object JavaDoc value = header.jmsProperties.get(name);
648       if (value == null)
649          return null;
650
651       if (value instanceof Boolean JavaDoc)
652          return ((Boolean JavaDoc) value).toString();
653       else if (value instanceof Byte JavaDoc)
654          return ((Byte JavaDoc) value).toString();
655       else if (value instanceof Short JavaDoc)
656          return ((Short JavaDoc) value).toString();
657       else if (value instanceof Integer JavaDoc)
658          return ((Integer JavaDoc) value).toString();
659       else if (value instanceof Long JavaDoc)
660          return ((Long JavaDoc) value).toString();
661       else if (value instanceof Float JavaDoc)
662          return ((Float JavaDoc) value).toString();
663       else if (value instanceof Double JavaDoc)
664          return ((Double JavaDoc) value).toString();
665       else if (value instanceof String JavaDoc)
666          return (String JavaDoc) value;
667       else
668          throw new MessageFormatException JavaDoc("Invalid conversion");
669    }
670
671    public Object JavaDoc getObjectProperty(String JavaDoc name) throws JMSException JavaDoc
672    {
673       Object JavaDoc value = header.jmsProperties.get(name);
674       return value;
675    }
676
677    public Enumeration JavaDoc getPropertyNames() throws JMSException JavaDoc
678    {
679       Enumeration JavaDoc names = Collections.enumeration(header.jmsProperties.keySet());
680       return names;
681    }
682
683    public void setBooleanProperty(String JavaDoc name, boolean value) throws JMSException JavaDoc
684    {
685       if (!header.jmsPropertiesReadWrite)
686          throw new MessageNotWriteableException JavaDoc("Properties are read-only");
687       Boolean JavaDoc b = Primitives.valueOf(value);
688       checkProperty(name, b);
689       header.jmsProperties.put(name, b);
690    }
691
692    public void setByteProperty(String JavaDoc name, byte value) throws JMSException JavaDoc
693    {
694       if (!header.jmsPropertiesReadWrite)
695          throw new MessageNotWriteableException JavaDoc("Properties are read-only");
696       Byte JavaDoc b = new Byte JavaDoc(value);
697       checkProperty(name, b);
698       header.jmsProperties.put(name, b);
699    }
700
701    public void setShortProperty(String JavaDoc name, short value) throws JMSException JavaDoc
702    {
703       if (!header.jmsPropertiesReadWrite)
704          throw new MessageNotWriteableException JavaDoc("Properties are read-only");
705       Short JavaDoc s = new Short JavaDoc(value);
706       checkProperty(name, s);
707       header.jmsProperties.put(name, s);
708    }
709
710    public void setIntProperty(String JavaDoc name, int value) throws JMSException JavaDoc
711    {
712       if (!header.jmsPropertiesReadWrite)
713          throw new MessageNotWriteableException JavaDoc("Properties are read-only");
714       Integer JavaDoc i = new Integer JavaDoc(value);
715       checkProperty(name, i);
716       header.jmsProperties.put(name, i);
717    }
718
719    public void setLongProperty(String JavaDoc name, long value) throws JMSException JavaDoc
720    {
721       if (!header.jmsPropertiesReadWrite)
722          throw new MessageNotWriteableException JavaDoc("Properties are read-only");
723       Long JavaDoc l = new Long JavaDoc(value);
724       checkProperty(name, l);
725       header.jmsProperties.put(name, l);
726    }
727
728    public void setFloatProperty(String JavaDoc name, float value) throws JMSException JavaDoc
729    {
730       if (!header.jmsPropertiesReadWrite)
731          throw new MessageNotWriteableException JavaDoc("Properties are read-only");
732       Float JavaDoc f = new Float JavaDoc(value);
733       checkProperty(name, f);
734       header.jmsProperties.put(name, f);
735    }
736
737    public void setDoubleProperty(String JavaDoc name, double value) throws JMSException JavaDoc
738    {
739       if (!header.jmsPropertiesReadWrite)
740          throw new MessageNotWriteableException JavaDoc("Properties are read-only");
741       Double JavaDoc d = new Double JavaDoc(value);
742       checkProperty(name, d);
743       header.jmsProperties.put(name, d);
744    }
745
746    public void setStringProperty(String JavaDoc name, String JavaDoc value) throws JMSException JavaDoc
747    {
748       if (!header.jmsPropertiesReadWrite)
749          throw new MessageNotWriteableException JavaDoc("Properties are read-only");
750       checkProperty(name, value);
751       header.jmsProperties.put(name, value);
752    }
753
754    public void setObjectProperty(String JavaDoc name, Object JavaDoc value) throws JMSException JavaDoc
755    {
756       if (!header.jmsPropertiesReadWrite)
757          throw new MessageNotWriteableException JavaDoc("Properties are read-only");
758       checkProperty(name, value);
759       if (value instanceof Boolean JavaDoc)
760          header.jmsProperties.put(name, value);
761       else if (value instanceof Byte JavaDoc)
762          header.jmsProperties.put(name, value);
763