KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > walend > somnifugi > SomniMessage


1 package net.walend.somnifugi;
2
3 import java.util.Enumeration JavaDoc;
4 import java.util.Map JavaDoc;
5 import java.util.HashMap JavaDoc;
6 import java.util.Collections JavaDoc;
7 import java.util.Set JavaDoc;
8 import java.util.HashSet JavaDoc;
9 import java.util.Arrays JavaDoc;
10
11 import java.io.ByteArrayOutputStream JavaDoc;
12 import java.io.ObjectOutputStream JavaDoc;
13 import java.io.ByteArrayInputStream JavaDoc;
14 import java.io.ObjectInputStream JavaDoc;
15 import java.io.IOException JavaDoc;
16
17 import javax.jms.Message JavaDoc;
18 import javax.jms.JMSException JavaDoc;
19 import javax.jms.Destination JavaDoc;
20 import javax.jms.MessageNotWriteableException JavaDoc;
21 import javax.jms.MessageFormatException JavaDoc;
22
23 /**
24 A message to shuttle around inside somnifugi.
25
26 @author <a HREF="http://walend.net">David Walend</a> <a HREF="mailto:david@walend.net">david@walend.net</a>
27 @author @pwang@ added support for client acknowledgement.
28  */

29
30 public class SomniMessage
31     implements Message JavaDoc
32 {
33     private static final Set JavaDoc<Class JavaDoc> PROPERTYCLASSES = new HashSet JavaDoc<Class JavaDoc>(Arrays.asList(new Class JavaDoc[] {Boolean JavaDoc.class,Byte JavaDoc.class,Short JavaDoc.class,Integer JavaDoc.class,Long JavaDoc.class,Float JavaDoc.class,Double JavaDoc.class,String JavaDoc.class}));
34     private static final String JavaDoc TRUE="true";
35     private static final String JavaDoc FALSE="false";
36
37     /**
38 Synch guard for message state.
39     */

40     protected final Object JavaDoc guard = new Object JavaDoc();
41
42     private String JavaDoc messageID;
43     private long timeStamp=0;
44     private String JavaDoc correlationID;
45     private Destination JavaDoc replyTo;
46     private Destination JavaDoc destination;
47     private int deliveryMode;
48     private long expirationTime;
49     private int priority=0;
50     private int producerCount=Integer.MIN_VALUE;
51     private String JavaDoc producerConnectionClientID;
52     private boolean readOnly=false;
53     private boolean redelivered=false;
54
55     /**
56 Messages that support client acknowledgement need to know about their consumers. This member is set on message delivery.
57     */

58     //todo penyu - is that comment right?
59
private SomniMessageConsumer consumer = null;
60
61     private Map JavaDoc<String JavaDoc,Object JavaDoc> properties=new HashMap JavaDoc<String JavaDoc,Object JavaDoc>();
62     private Map JavaDoc<String JavaDoc,Class JavaDoc> propertiesToClasses=new HashMap JavaDoc<String JavaDoc,Class JavaDoc>();
63
64     protected SomniMessage()
65     {
66     }
67
68     /**
69 Copy constructor.
70     */

71     protected SomniMessage(SomniMessage message,boolean deep)
72         throws JMSException JavaDoc
73     {
74         this.messageID = message.getJMSMessageID();
75         this.timeStamp = message.getJMSTimestamp();
76         this.correlationID = message.getJMSCorrelationID();
77         this.replyTo = message.getJMSReplyTo();
78         this.destination = message.getJMSDestination();
79         this.deliveryMode = message.getJMSDeliveryMode();
80         this.expirationTime = message.getJMSExpiration();
81         this.priority = message.getJMSPriority();
82         this.producerCount = message.getSomniProducerCount();
83         this.producerConnectionClientID = message.getSomniProducerConnectionClientID();
84         this.readOnly = message.getReadOnly();
85         this.redelivered = message.getJMSRedelivered();
86
87         if(deep)
88         {
89             this.properties = (Map JavaDoc<String JavaDoc,Object JavaDoc>)serializedCopy(message.getProperties());
90             this.propertiesToClasses = (Map JavaDoc<String JavaDoc,Class JavaDoc>)serializedCopy(message.getPropertiesToClasses());
91         }
92         else
93         {
94             this.properties = message.getProperties();
95             this.propertiesToClasses = message.getPropertiesToClasses();
96         }
97     }
98
99     @SuppressWarnings JavaDoc("unchecked")
100     protected static <Thing> Thing serializedCopy(Thing victem)
101         throws SomniMessageCopyingException
102     {
103         try
104         {
105             ByteArrayOutputStream JavaDoc byteOut = new ByteArrayOutputStream JavaDoc();
106             ObjectOutputStream JavaDoc objectOut = new ObjectOutputStream JavaDoc(byteOut);
107             
108             objectOut.writeObject(victem);
109             objectOut.close();
110
111             ByteArrayInputStream JavaDoc byteIn = new ByteArrayInputStream JavaDoc(byteOut.toByteArray());
112             ObjectInputStream JavaDoc objectIn = new ObjectInputStream JavaDoc(byteIn);
113
114             Thing result = (Thing)objectIn.readObject();
115
116             objectIn.close();
117
118             return result;
119         }
120         catch(IOException JavaDoc ioe)
121         {
122             throw new SomniMessageCopyingException(ioe);
123         }
124         catch(ClassNotFoundException JavaDoc cnfe)
125         {
126             throw new SomniMessageCopyingException(cnfe);
127         }
128     }
129
130     /** Gets the message ID.
131 <p>
132 <P>The <CODE>JMSMessageID</CODE> header field contains a value that
133 uniquely identifies each message sent by a provider.
134  
135 <P>When a message is sent, <CODE>JMSMessageID</CODE> can be ignored.
136 When the <CODE>send</CODE> or <CODE>publish</CODE> method returns, it
137 contains a provider-assigned value.
138 <p>
139 <P>A <CODE>JMSMessageID</CODE> is a <CODE>String</CODE> value that
140 should function as a
141 unique key for identifying messages in a historical repository.
142 The exact scope of uniqueness is provider-defined. It should at
143 least cover all messages for a specific installation of a
144 provider, where an installation is some connected set of message
145 routers.
146 <p>
147 <P>All <CODE>JMSMessageID</CODE> values must start with the prefix
148 <CODE>'ID:'</CODE>.
149 Uniqueness of message ID values across different providers is
150 not required.
151 <p>
152 <P>Since message IDs take some effort to create and increase a
153 message's size, some JMS providers may be able to optimize message
154 overhead if they are given a hint that the message ID is not used by
155 an application. By calling the
156 <CODE>MessageProducer.setDisableMessageID</CODE> method, a JMS client
157 enables this potential optimization for all messages sent by that
158 message producer. If the JMS provider accepts this
159 hint, these messages must have the message ID set to null; if the
160 provider ignores the hint, the message ID must be set to its normal
161 unique value.
162 <p>
163 @return the message ID
164 <p>
165 @exception JMSException if the JMS provider fails to get the message ID
166                         due to some internal error.
167 @see javax.jms.Message#setJMSMessageID(String)
168 @see javax.jms.MessageProducer#setDisableMessageID(boolean)
169       */

170     public String JavaDoc getJMSMessageID()
171         throws JMSException JavaDoc
172     {
173         synchronized(guard)
174             {
175                 return messageID;
176             }
177     }
178
179     /** Sets the message ID.
180  
181 <P>JMS providers set this field when a message is sent. This method
182 can be used to change the value for a message that has been received.
183 <p>
184 @param id the ID of the message
185 <p>
186 @exception JMSException if the JMS provider fails to set the message ID
187                         due to some internal error.
188 <p>
189 @see javax.jms.Message#getJMSMessageID()
190       */

191     public void setJMSMessageID(String JavaDoc id)
192         throws JMSException JavaDoc
193     {
194         synchronized(guard)
195             {
196                 messageID = id;
197             }
198     }
199
200     /** Gets the message timestamp.
201  
202 <P>The <CODE>JMSTimestamp</CODE> header field contains the time a
203 message was
204 handed off to a provider to be sent. It is not the time the
205 message was actually transmitted, because the actual send may occur
206 later due to transactions or other client-side queueing of messages.
207 <p>
208 <P>When a message is sent, <CODE>JMSTimestamp</CODE> is ignored. When
209 the <CODE>send</CODE> or <CODE>publish</CODE>
210 method returns, it contains a a time value somewhere in the interval
211 between the call and the return. The value is in the format of a normal
212 millis time value in the Java programming language.
213 <p>
214 <P>Since timestamps take some effort to create and increase a
215 message's size, some JMS providers may be able to optimize message
216 overhead if they are given a hint that the timestamp is not used by an
217 application. By calling the
218 <CODE>MessageProducer.setDisableMessageTimestamp</CODE> method, a JMS
219 client enables this potential optimization for all messages sent by
220 that message producer. If the JMS provider accepts this
221 hint, these messages must have the timestamp set to zero; if the
222 provider ignores the hint, the timestamp must be set to its normal
223 value.
224 <p>
225 @return the message timestamp
226 <p>
227 @exception JMSException if the JMS provider fails to get the timestamp
228                         due to some internal error.
229 <p>
230 @see javax.jms.Message#setJMSTimestamp(long)
231 @see javax.jms.MessageProducer#setDisableMessageTimestamp(boolean)
232       */

233     public long getJMSTimestamp()
234         throws JMSException JavaDoc
235     {
236         synchronized(guard)
237             {
238                 return timeStamp;
239             }
240     }
241
242     /** Sets the message timestamp.
243  
244 <P>JMS providers set this field when a message is sent. This method
245 can be used to change the value for a message that has been received.
246 <p>
247 @param timestamp the timestamp for this message
248  
249 @exception JMSException if the JMS provider fails to set the timestamp
250                         due to some internal error.
251 <p>
252 @see javax.jms.Message#getJMSTimestamp()
253       */

254     public void setJMSTimestamp(long timestamp)
255         throws JMSException JavaDoc
256     {
257         synchronized(guard)
258             {
259                 timeStamp = timestamp;
260             }
261     }
262
263     /** Gets the correlation ID as an array of bytes for the message.
264  
265 <P>The use of a <CODE>byte[]</CODE> value for
266 <CODE>JMSCorrelationID</CODE> is non-portable.
267 <p>
268 @return the correlation ID of a message as an array of bytes
269 <p>
270 @exception JMSException if the JMS provider fails to get the correlation
271                         ID due to some internal error.
272  
273 @see javax.jms.Message#setJMSCorrelationID(String)
274 @see javax.jms.Message#getJMSCorrelationID()
275 @see javax.jms.Message#setJMSCorrelationIDAsBytes(byte[])
276       */

277     public byte[] getJMSCorrelationIDAsBytes()
278         throws JMSException JavaDoc
279     {
280         synchronized(guard)
281             {
282                 return correlationID.getBytes();
283             }
284     }
285
286     /** Sets the correlation ID as an array of bytes for the message.
287
288 <P>The array is copied before the method returns, so
289 future modifications to the array will not alter this message header.
290  
291 <P>If a provider supports the native concept of correlation ID, a
292 JMS client may need to assign specific <CODE>JMSCorrelationID</CODE>
293 values to match those expected by native messaging clients.
294 JMS providers without native correlation ID values are not required to
295 support this method and its corresponding get method; their
296 implementation may throw a
297 <CODE>java.lang.UnsupportedOperationException</CODE>.
298 <p>
299 <P>The use of a <CODE>byte[]</CODE> value for
300 <CODE>JMSCorrelationID</CODE> is non-portable.
301 <p>
302 @param correlationID the correlation ID value as an array of bytes
303  
304 @exception JMSException if the JMS provider fails to set the correlation
305                         ID due to some internal error.
306  
307 @see javax.jms.Message#setJMSCorrelationID(String)
308 @see javax.jms.Message#getJMSCorrelationID()
309 @see javax.jms.Message#getJMSCorrelationIDAsBytes()
310       */

311     public void setJMSCorrelationIDAsBytes(byte[] correlationID)
312         throws JMSException JavaDoc
313     {
314         synchronized(guard)
315             {
316                 this.correlationID = new String JavaDoc(correlationID);
317             }
318     }
319
320     /** Sets the correlation ID for the message.
321  
322 <P>A client can use the <CODE>JMSCorrelationID</CODE> header field to
323 link one message with another. A typical use is to link a response
324 message with its request message.
325  
326 <P><CODE>JMSCorrelationID</CODE> can hold one of the following:
327    <UL>
328      <LI>A provider-specific message ID
329      <LI>An application-specific <CODE>String</CODE>
330      <LI>A provider-native <CODE>byte[]</CODE> value
331    </UL>
332  
333 <P>Since each message sent by a JMS provider is assigned a message ID
334 value, it is convenient to link messages via message ID. All message ID
335 values must start with the <CODE>'ID:'</CODE> prefix.
336  
337 <P>In some cases, an application (made up of several clients) needs to
338 use an application-specific value for linking messages. For instance,
339 an application may use <CODE>JMSCorrelationID</CODE> to hold a value
340 referencing some external information. Application-specified values
341 must not start with the <CODE>'ID:'</CODE> prefix; this is reserved for
342 provider-generated message ID values.
343  
344 <P>If a provider supports the native concept of correlation ID, a JMS
345 client may need to assign specific <CODE>JMSCorrelationID</CODE> values
346 to match those expected by clients that do not use the JMS API. A
347 <CODE>byte[]</CODE> value is used for this
348 purpose. JMS providers without native correlation ID values are not
349 required to support <CODE>byte[]</CODE> values. The use of a
350 <CODE>byte[]</CODE> value for <CODE>JMSCorrelationID</CODE> is
351 non-portable.
352  
353 @param correlationID the message ID of a message being referred to
354  
355 @exception JMSException if the JMS provider fails to set the correlation
356                         ID due to some internal error.
357  
358 @see javax.jms.Message#getJMSCorrelationID()
359 @see javax.jms.Message#getJMSCorrelationIDAsBytes()
360 @see javax.jms.Message#setJMSCorrelationIDAsBytes(byte[])
361       */

362     public void setJMSCorrelationID(String JavaDoc correlationID)
363         throws JMSException JavaDoc
364     {
365         synchronized(guard)
366             {
367                 this.correlationID = correlationID;
368             }
369     }
370
371     /** Gets the correlation ID for the message.
372  
373 <P>This method is used to return correlation ID values that are
374 either provider-specific message IDs or application-specific
375 <CODE>String</CODE> values.
376 <p>
377 @return the correlation ID of a message as a <CODE>String</CODE>
378 <p>
379 @exception JMSException if the JMS provider fails to get the correlation
380                         ID due to some internal error.
381 <p>
382 @see javax.jms.Message#setJMSCorrelationID(String)
383 @see javax.jms.Message#getJMSCorrelationIDAsBytes()
384 @see javax.jms.Message#setJMSCorrelationIDAsBytes(byte[])
385       */

386     public String JavaDoc getJMSCorrelationID()
387         throws JMSException JavaDoc
388     {
389         synchronized(guard)
390             {
391                 return correlationID;
392             }
393     }
394
395     /** Gets the <CODE>Destination</CODE> object to which a reply to this
396 message should be sent.
397  
398 @return <CODE>Destination</CODE> to which to send a response to this
399         message
400 <p>
401 @exception JMSException if the JMS provider fails to get the
402                         <CODE>JMSReplyTo</CODE> destination due to some
403                         internal error.
404 <p>
405 @see javax.jms.Message#setJMSReplyTo(Destination)
406       */

407     public Destination JavaDoc getJMSReplyTo()
408         throws JMSException JavaDoc
409     {
410         synchronized(guard)
411             {
412                 return replyTo;
413             }
414     }
415
416     /** Sets the <CODE>Destination</CODE> object to which a reply to this
417 message should be sent.
418  
419 <P>The <CODE>JMSReplyTo</CODE> header field contains the destination
420 where a reply
421 to the current message should be sent. If it is null, no reply is
422 expected. The destination may be either a <CODE>Queue</CODE> object or
423 a <CODE>Topic</CODE> object.
424 <p>
425 <P>Messages sent with a null <CODE>JMSReplyTo</CODE> value may be a
426 notification of some event, or they may just be some data the sender
427 thinks is of interest.
428 <p>
429 <P>Messages with a <CODE>JMSReplyTo</CODE> value typically expect a
430 response. A response is optional; it is up to the client to decide.
431 These messages are called requests. A message sent in response to a
432 request is called a reply.
433 <p>
434 <P>In some cases a client may wish to match a request it sent earlier
435 with a reply it has just received. The client can use the
436 <CODE>JMSCorrelationID</CODE> header field for this purpose.
437 <p>
438 @param replyTo <CODE>Destination</CODE> to which to send a response to
439                this message
440 <p>
441 @exception JMSException if the JMS provider fails to set the
442                         <CODE>JMSReplyTo</CODE> destination due to some
443                         internal error.
444 <p>
445 @see javax.jms.Message#getJMSReplyTo()
446       */

447     public void setJMSReplyTo(Destination JavaDoc replyTo)
448         throws JMSException JavaDoc
449     {
450         synchronized(guard)
451             {
452                 this.replyTo = replyTo;
453             }
454     }
455
456     /** Gets the <CODE>Destination</CODE> object for this message.
457  
458 <P>The <CODE>JMSDestination</CODE> header field contains the
459 destination to which the message is being sent.
460  
461 <P>When a message is sent, this field is ignored. After completion
462 of the <CODE>send</CODE> or <CODE>publish</CODE> method, the field
463 holds the destination specified by the method.
464  
465 <P>When a message is received, its <CODE>JMSDestination</CODE> value
466 must be equivalent to the value assigned when it was sent.
467 <p>
468 @return the destination of this message
469  
470 @exception JMSException if the JMS provider fails to get the destination
471                         due to some internal error.
472  
473 @see javax.jms.Message#setJMSDestination(Destination)
474       */

475     public Destination JavaDoc getJMSDestination()
476         throws JMSException JavaDoc
477     {
478         synchronized(guard)
479             {
480                 return destination;
481             }
482     }
483
484     /** Sets the <CODE>Destination</CODE> object for this message.
485  
486 <P>JMS providers set this field when a message is sent. This method
487 can be used to change the value for a message that has been received.
488 <p>
489 @param destination the destination for this message
490  
491 @exception JMSException if the JMS provider fails to set the destination
492                         due to some internal error.
493  
494 @see javax.jms.Message#getJMSDestination()
495       */

496     public void setJMSDestination(Destination JavaDoc destination)
497         throws JMSException JavaDoc
498     {
499         synchronized(guard)
500             {
501                 this.destination = destination;
502             }
503     }
504
505     /** Gets the <CODE>DeliveryMode</CODE> value specified for this message.
506  
507 @return the delivery mode for this message
508  
509 @exception JMSException if the JMS provider fails to get the
510                         delivery mode due to some internal error.
511  
512 @see javax.jms.Message#setJMSDeliveryMode(int)
513 @see <{DeliveryMode}>
514       */

515     public int getJMSDeliveryMode()
516         throws JMSException JavaDoc
517     {
518         synchronized(guard)
519             {
520                 return deliveryMode;
521             }
522     }
523
524     /** Sets the <CODE>DeliveryMode</CODE> value for this message.
525  
526 <P>JMS providers set this field when a message is sent. This method
527 can be used to change the value for a message that has been received.
528 <p>
529 @param deliveryMode the delivery mode for this message
530  
531 @exception JMSException if the JMS provider fails to set the
532                         delivery mode due to some internal error.
533  
534 @see javax.jms.Message#getJMSDeliveryMode()
535 @see <{DeliveryMode}>
536       */

537     public void setJMSDeliveryMode(int deliveryMode)
538         throws JMSException JavaDoc
539     {
540         synchronized(guard)
541             {
542                 this.deliveryMode = deliveryMode;
543             }
544     }
545
546     /** Gets an indication of whether this message is being redelivered.
547 <p>
548 <P>If a client receives a message with the <CODE>JMSRedelivered</CODE>
549 field set,
550 it is likely, but not guaranteed, that this message was delivered
551 earlier but that its receipt was not acknowledged
552 at that time.
553 <p>
554 @return true if this message is being redelivered
555  
556 @exception JMSException if the JMS provider fails to get the redelivered
557                         state due to some internal error.
558 <p>
559 @see javax.jms.Message#setJMSRedelivered(boolean)
560       */

561     public boolean getJMSRedelivered()
562         throws JMSException JavaDoc
563     {
564         return redelivered;
565     }
566
567     /** Specifies whether this message is being redelivered.
568  
569 <P>This field is set at the time the message is delivered. This
570 method can be used to change the value for a message that has
571 been received.
572 <p>
573 @param redelivered an indication of whether this message is being
574 redelivered
575  
576 @exception JMSException if the JMS provider fails to set the redelivered
577                         state due to some internal error.
578 <p>
579 @see javax.jms.Message#getJMSRedelivered()
580       */

581     public void setJMSRedelivered(boolean redelivered)
582         throws JMSException JavaDoc
583     {
584         this.redelivered=redelivered;
585     }
586
587     /** Gets the message type identifier supplied by the client when the
588 message was sent.
589 <p>
590 @return the message type
591  
592 @exception JMSException if the JMS provider fails to get the message
593                         type due to some internal error.
594 <p>
595 @see javax.jms.Message#setJMSType(String)
596       */

597     public String JavaDoc getJMSType()
598         throws JMSException JavaDoc
599     {
600         return this.getClass().getName();
601     }
602
603     /** Sets the message type.
604 <p>
605 <P>Some JMS providers use a message repository that contains the
606 definitions of messages sent by applications. The <CODE>JMSType</CODE>
607 header field may reference a message's definition in the provider's
608 repository.
609 <p>
610 <P>The JMS API does not define a standard message definition repository,
611 nor does it define a naming policy for the definitions it contains.
612 <p>
613 <P>Some messaging systems require that a message type definition for
614 each application message be created and that each message specify its
615 type. In order to work with such JMS providers, JMS clients should
616 assign a value to <CODE>JMSType</CODE>, whether the application makes
617 use of it or not. This ensures that the field is properly set for those
618 providers that require it.
619 <p>
620 <P>To ensure portability, JMS clients should use symbolic values for
621 <CODE>JMSType</CODE> that can be configured at installation time to the
622 values defined in the current provider's message repository. If string
623 literals are used, they may not be valid type names for some JMS
624 providers.
625 <p>
626 @param type the message type
627  
628 @exception JMSException if the JMS provider fails to set the message
629                         type due to some internal error.
630 <p>
631 @see javax.jms.Message#getJMSType()
632 @exception UnsupportedOperationException because it isn't implemented.
633       */

634     public void setJMSType(String JavaDoc type)
635         throws JMSException JavaDoc
636     {
637         throw new UnsupportedOperationException JavaDoc("This JMS implementation isn't that sophisticated.");
638     }
639
640     /** Gets the message's expiration value.
641  
642 <P>When a message is sent, the <CODE>JMSExpiration</CODE> header field
643 is left unassigned. After completion of the <CODE>send</CODE> or
644 <CODE>publish</CODE> method, it holds the expiration time of the
645 message. This is the sum of the time-to-live value specified by the
646 client and the GMT at the time of the <CODE>send</CODE> or
647 <CODE>publish</CODE>.
648 <p>
649 <P>If the time-to-live is specified as zero, <CODE>JMSExpiration</CODE>
650 is set to zero to indicate that the message does not expire.
651 <p>
652 <P>When a message's expiration time is reached, a provider should
653 discard it. The JMS API does not define any form of notification of
654 message expiration.
655 <p>
656 <P>Clients should not receive messages that have expired; however,
657 the JMS API does not guarantee that this will not happen.
658 <p>
659 @return the time the message expires, which is the sum of the
660 time-to-live value specified by the client and the GMT at the
661 time of the send
662  
663 @exception JMSException if the JMS provider fails to get the message
664                         expiration due to some internal error.
665 <p>
666 @see javax.jms.Message#setJMSExpiration(long)
667       */

668     public long getJMSExpiration()
669         throws JMSException JavaDoc
670     {
671         synchronized(guard)
672             {
673                 return expirationTime;
674             }
675     }
676
677     /** Sets the message's expiration value.
678 <p>
679 <P>JMS providers set this field when a message is sent. This method
680 can be used to change the value for a message that has been received.
681  
682 @param expiration the message's expiration time
683  
684 @exception JMSException if the JMS provider fails to set the message
685                         expiration due to some internal error.
686 <p>
687 @see javax.jms.Message#getJMSExpiration()
688       */

689     public void setJMSExpiration(long expiration)
690         throws JMSException JavaDoc
691     {
692         synchronized(guard)
693             {
694                 expirationTime = expiration;
695             }
696     }
697
698     /** Gets the message priority level.
699  
700 <P>The JMS API defines ten levels of priority value, with 0 as the
701 lowest
702 priority and 9 as the highest. In addition, clients should consider
703 priorities 0-4 as gradations of normal priority and priorities 5-9
704 as gradations of expedited priority.
705  
706 <P>The JMS API does not require that a provider strictly implement
707 priority
708 ordering of messages; however, it should do its best to deliver
709 expedited messages ahead of normal messages.
710  
711 @return the default message priority
712  
713 @exception JMSException if the JMS provider fails to get the message
714                         priority due to some internal error.
715 <p>
716 @see javax.jms.Message#setJMSPriority(int)
717       */

718     public int getJMSPriority()
719         throws JMSException JavaDoc
720     {
721         synchronized(guard)
722         {
723             return priority;
724         }
725     }
726
727
728     public void checkPriority(int priority)
729         throws SomniBadPriorityException
730     {
731         if((priority<0)||(priority>9))
732             {
733                 throw new SomniBadPriorityException("priority is "+priority+" but must be 0-9.",priority);
734             }
735     }
736
737
738     /** Sets the priority level for this message.
739  
740 <P>JMS providers set this field when a message is sent. This method
741 can be used to change the value for a message that has been received.
742 <p>
743 @param priority the priority of this message
744  
745 @exception JMSException if the JMS provider fails to set the message
746                         priority due to some internal error.
747 <p>
748 @see javax.jms.Message#getJMSPriority()
749       */

750     public void setJMSPriority(int priority)
751         throws JMSException JavaDoc
752     {
753         checkPriority(priority);
754         synchronized(guard)
755         {
756             this.priority = priority;
757         }
758     }
759
760         /** Gets the message producer count -- a unique number for a message from a given producer. This value is used to keep computational stability inside a PriorityQueue.
761  
762 @return the message producer count.
763  
764 @exception JMSException if the JMS provider fails to get the message producer count due to some internal error.
765 @since alpha-0-10
766       */

767     public int getSomniProducerCount()
768         throws JMSException JavaDoc
769     {
770         synchronized(guard)
771         {
772             return producerCount;
773         }
774     }
775
776     /** Sets the message producer count -- a unique number for messages from a given producer. This value is used to keep computational stability inside a priority queue.
777 @param producerCount the count.
778  
779 @exception JMSException if the JMS provider fails to set the message
780                         priority due to some internal error.
781 @since alpha-0-10
782       */

783     void setSomniProducerCount(int producerCount)
784         throws JMSException JavaDoc
785     {
786         synchronized(guard)
787             {
788                 this.producerCount = producerCount;
789             }
790     }
791
792         /**
793 Gets the sender connection name.
794  
795 @return the sender connection name.
796  
797 @since alpha-0-11
798       */

799     public String JavaDoc getSomniProducerConnectionClientID()
800     {
801         synchronized(guard)
802         {
803             return producerConnectionClientID;
804         }
805     }
806
807     /**
808 Sets the sender connection name.
809     
810 @param producerConnectionClientID
811  
812 @since alpha-0-11
813       */

814     void setSomniProducerConnectionClientID(String JavaDoc producerConnectionClientID)
815     {
816         synchronized(guard)
817             {
818                 this.producerConnectionClientID = producerConnectionClientID;
819             }
820     }
821
822     
823     
824     /** Clears a message's properties.
825 <p>
826 <P>The message's header fields and body are not cleared.
827 <p>
828 @exception JMSException if the JMS provider fails to clear the message
829                         properties due to some internal error.
830       */

831     public void clearProperties()
832         throws JMSException JavaDoc
833     {
834         properties.clear();
835         propertiesToClasses.clear();
836     }
837
838     /** Indicates whether a property value exists.
839 <p>
840 @param name the name of the property to test
841 <p>
842 @return true if the property exists
843  
844 @exception JMSException if the JMS provider fails to determine if the
845                         property exists due to some internal error.
846       */

847     public boolean propertyExists(String JavaDoc name)
848         throws JMSException JavaDoc
849     {
850         return properties.keySet().contains(name);
851     }
852
853     /** Returns the value of the <CODE>boolean</CODE> property with the
854 specified name.
855  
856 @param name the name of the <CODE>boolean</CODE> property
857  
858 @return the <CODE>boolean</CODE> property value for the specified name
859  
860 @exception JMSException if the JMS provider fails to get the property
861                         value due to some internal error.
862 @exception MessageFormatException if this type conversion is invalid.
863       */

864     public boolean getBooleanProperty(String JavaDoc name)
865         throws JMSException JavaDoc
866     {
867         String JavaDoc value = (String JavaDoc)properties.get(name);
868         if(value==null||FALSE.equals(value))
869             {
870                 return false;
871             }
872         else if(TRUE.equals(value))
873             {
874                 return true;
875             }
876         else
877             {
878                 throw new MessageFormatException JavaDoc("Property "+name+" has value "+value+" but must be "+TRUE+" or "+FALSE+".");
879             }
880     }
881
882     /** Returns the value of the <CODE>byte</CODE> property with the specified
883 name.
884  
885 @param name the name of the <CODE>byte</CODE> property
886  
887 @return the <CODE>byte</CODE> property value for the specified name
888  
889 @exception JMSException if the JMS provider fails to get the property
890                         value due to some internal error.
891 @exception MessageFormatException if this type conversion is invalid.
892       */

893     public byte getByteProperty(String JavaDoc name)
894         throws JMSException JavaDoc
895     {
896         String JavaDoc value = (String JavaDoc)properties.get(name);
897         try
898             {
899                 return Byte.parseByte(value);
900             }
901         catch(NumberFormatException JavaDoc nfe)
902             {
903                 throw new SomniMessageFormatException("Property "+name+" has value "+value+", which is not a valid byte.",nfe);
904             }
905     }
906
907     /** Returns the value of the <CODE>short</CODE> property with the specified
908 name.
909 <p>
910 @param name the name of the <CODE>short</CODE> property
911 <p>
912 @return the <CODE>short</CODE> property value for the specified name
913 <p>
914 @exception JMSException if the JMS provider fails to get the property
915                         value due to some internal error.
916 @exception MessageFormatException if this type conversion is invalid.
917       */

918     public short getShortProperty(String JavaDoc name)
919         throws JMSException JavaDoc
920     {
921         String JavaDoc value = (String JavaDoc)properties.get(name);
922         try
923             {
924                 return Short.parseShort(value);
925             }
926         catch(NumberFormatException JavaDoc nfe)
927             {
928                 throw new SomniMessageFormatException("Property "+name+" has value "+value+", which is not a valid short.",nfe);
929             }
930     }
931
932     /** Returns the value of the <CODE>int</CODE> property with the specified
933 name.
934  
935 @param name the name of the <CODE>int</CODE> property
936  
937 @return the <CODE>int</CODE> property value for the specified name
938  
939 @exception JMSException if the JMS provider fails to get the property
940                         value due to some internal error.
941 @exception MessageFormatException if this type conversion is invalid.
942       */

943     public int getIntProperty(String JavaDoc name)
944         throws JMSException JavaDoc
945     {
946         String JavaDoc value = (String JavaDoc)properties.get(name);
947         try
948             {
949                 return Integer.parseInt(value);
950             }
951         catch(NumberFormatException JavaDoc nfe)
952             {
953                 throw new SomniMessageFormatException("Property "+name+" has value "+value+", which is not a valid int.",nfe);
954             }
955     }
956
957     /** Returns the value of the <CODE>long</CODE> property with the specified
958 name.
959  
960 @param name the name of the <CODE>long</CODE> property
961  
962 @return the <CODE>long</CODE> property value for the specified name
963  
964 @exception JMSException if the JMS provider fails to get the property
965                         value due to some internal error.
966 @exception MessageFormatException if this type conversion is invalid.
967       */

968     public long getLongProperty(String JavaDoc name)
969         throws JMSException JavaDoc
970     {
971         String JavaDoc value = (String JavaDoc)properties.get(name);
972         try
973             {
974                 return Long.parseLong(value);
975             }
976         catch(NumberFormatException JavaDoc nfe)
977             {
978                 throw new SomniMessageFormatException("Property "+name+" has value "+value+", which is not a valid long.",nfe);
979             }
980     }
981
982     /** Returns the value of the <CODE>float</CODE> property with the specified
983 name.
984  
985 @param name the name of the <CODE>float</CODE> property
986  
987 @return the <CODE>float</CODE> property value for the specified name
988  
989 @exception JMSException if the JMS provider fails to get the property
990                         value due to some internal error.
991 @exception MessageFormatException if this type conversion is invalid.
992       */

993     public float getFloatProperty(String JavaDoc name)
994         throws JMSException JavaDoc
995     {
996         String JavaDoc value = (String JavaDoc)properties.get(name);
997         try
998             {
999                 return Float.parseFloat(value);
1000            }
1001        catch(NumberFormatException JavaDoc nfe)
1002            {
1003                throw new SomniMessageFormatException("Property "+name+" has value "+value+", which is not a valid float.",nfe);
1004            }
1005    }
1006
1007    /** Returns the value of the <CODE>double</CODE> property with the specified
1008name.
1009 
1010@param name the name of the <CODE>double</CODE> property
1011 
1012@return the <CODE>double</CODE> property value for the specified name
1013 
1014@exception JMSException if the JMS provider fails to get the property
1015                        value due to some internal error.
1016@exception MessageFormatException if this type conversion is invalid.
1017      */

1018    public double getDoubleProperty(String JavaDoc name)
1019        throws JMSException JavaDoc
1020    {
1021        String JavaDoc value = (String JavaDoc)properties.get(name);
1022        try
1023            {
1024                return Double.parseDouble(value);
1025            }
1026        catch(NumberFormatException JavaDoc nfe)
1027            {
1028                throw new SomniMessageFormatException("Property "+name+" has value "+value+", which is not a valid double.",nfe);
1029            }
1030    }
1031
1032    /** Returns the value of the <CODE>String</CODE> property with the specified
1033name.
1034 
1035@param name the name of the <CODE>String</CODE> property
1036 
1037@return the <CODE>String</CODE> property value for the specified name;
1038if there is no property by this name, a null value is returned
1039 
1040@exception JMSException if the JMS provider fails to get the property
1041                        value due to some internal error.
1042@exception MessageFormatException if this type conversion is invalid.
1043      */

1044    public String JavaDoc getStringProperty(String JavaDoc name)
1045        throws JMSException JavaDoc
1046    {
1047        String JavaDoc value = (String JavaDoc)properties.get(name);
1048
1049        return value;
1050    }
1051
1052    /** Returns the value of the Java object property with the specified name.
1053 
1054<P>This method can be used to return, in objectified format,
1055an object that has been stored as a property in the message with the
1056equivalent <CODE>setObjectProperty</CODE> method call, or its equivalent
1057primitive <CODE>set<I>type</I>Property</CODE> method.
1058 
1059@param name the name of the Java object property
1060 
1061@return the Java object property value with the specified name, in
1062objectified format (for example, if the property was set as an
1063<CODE>int</CODE>, an <CODE>Integer</CODE> is
1064returned); if there is no property by this name, a null value
1065is returned
1066 
1067@exception JMSException if the JMS provider fails to get the property
1068                        value due to some internal error.
1069      */

1070    public Object JavaDoc getObjectProperty(String JavaDoc name)
1071        throws JMSException JavaDoc
1072    {
1073        if(!properties.containsKey(name))
1074            {
1075                return null;
1076            }
1077        Class JavaDoc propClass = (Class JavaDoc)propertiesToClasses.get(name);
1078        String JavaDoc prop = (String JavaDoc)properties.get(name);
1079        if(propClass.equals(String JavaDoc.class))
1080            {
1081                return prop;
1082            }
1083        else if(propClass.equals(Boolean JavaDoc.class))
1084            {
1085                return new Boolean JavaDoc(prop);
1086            }
1087        else if(propClass.equals(Byte JavaDoc.class))
1088            {
1089                return new Byte JavaDoc(prop);
1090            }
1091        else if(propClass.equals(Short JavaDoc.class))
1092            {
1093                return new Short JavaDoc(prop);
1094            }
1095        else if(propClass.equals(Integer JavaDoc.class))
1096            {
1097                return new Integer JavaDoc(prop);
1098            }
1099        else if(propClass.equals(Long JavaDoc.class))
1100            {
1101                return new Long JavaDoc(prop);
1102            }
1103        else if(propClass.equals(Float JavaDoc.class))
1104            {
1105                return new Float JavaDoc(prop);
1106            }
1107        else if(propClass.equals(Double JavaDoc.class))
1108            {
1109                return new Double JavaDoc(prop);
1110            }
1111        else
1112            {
1113                throw new SomniMessageFormatException("Property "+name+" with value "+prop+" has type "+propClass.getName());
1114            }
1115    }
1116
1117    /** Returns an <CODE>Enumeration</CODE> of all the property names.
1118<p>
1119<P>Note that JMS standard header fields are not considered
1120properties and are not returned in this enumeration.
1121 
1122@return an enumeration of all the names of property values
1123 
1124@exception JMSException if the JMS provider fails to get the property
1125                         names due to some internal error.
1126      */

1127    public Enumeration JavaDoc getPropertyNames()
1128        throws JMSException JavaDoc
1129    {
1130        return Collections.enumeration(properties.keySet());
1131    }
1132
1133    /** Sets a <CODE>boolean</CODE> property value with the specified name into
1134the message.
1135<p>
1136@param name the name of the <CODE>boolean</CODE> property
1137@param value the <CODE>boolean</CODE> property value to set
1138 
1139@exception JMSException if the JMS provider fails to set the property
1140                         due to some internal error.
1141@exception MessageNotWriteableException if properties are read-only
1142      */

1143    public void setBooleanProperty(String JavaDoc name, boolean value)
1144        throws JMSException JavaDoc
1145    {
1146        checkWritable();
1147        propertiesToClasses.put(name,Boolean JavaDoc.class);
1148        if(value)
1149            {
1150                properties.put(name,TRUE);
1151            }
1152        else
1153            {
1154                properties.put(name,FALSE);
1155            }
1156    }
1157
1158    /** Sets a <CODE>byte</CODE> property value with the specified name into
1159the message.
1160 
1161@param name the name of the <CODE>byte</CODE> property
1162@param value the <CODE>byte</CODE> property value to set
1163 
1164@exception JMSException if the JMS provider fails to set the property
1165                         due to some internal error.
1166@exception MessageNotWriteableException if properties are read-only
1167      */

1168    public void setByteProperty(String JavaDoc name, byte value)
1169        throws JMSException JavaDoc
1170    {
1171        checkWritable();
1172        propertiesToClasses.put(name,Byte JavaDoc.class);
1173        properties.put(name,Byte.toString(value));
1174    }
1175
1176    /** Sets a <CODE>short</CODE> property value with the specified name into
1177the message.
1178 
1179@param name the name of the <CODE>short</CODE> property
1180@param value the <CODE>short</CODE> property value to set
1181 
1182@exception JMSException if the JMS provider fails to set the property
1183                         due to some internal error.
1184@exception MessageNotWriteableException if properties are read-only
1185      */

1186    public void setShortProperty(String JavaDoc name, short value)
1187        throws JMSException JavaDoc
1188    {
1189        checkWritable();
1190        propertiesToClasses.put(name,Short JavaDoc.class);
1191        properties.put(name,Short.toString(value));
1192    }
1193
1194    /** Sets an <CODE>int</CODE> property value with the specified name into
1195the message.
1196 
1197@param name the name of the <CODE>int</CODE> property
1198@param value the <CODE>int</CODE> property value to set
1199 
1200@exception JMSException if the JMS provider fails to set the property
1201                         due to some internal error.
1202@exception MessageNotWriteableException if properties are read-only
1203      */

1204    public void setIntProperty(String JavaDoc name, int value)
1205        throws JMSException JavaDoc
1206    {
1207        checkWritable();
1208        propertiesToClasses.put(name,Integer JavaDoc.class);
1209        properties.put(name,Integer.toString(value));
1210    }
1211
1212    /** Sets a <CODE>long</CODE> property value with the specified name into
1213the message.
1214 
1215@param name the name of the <CODE>long</CODE> property
1216@param value the <CODE>long</CODE> property value to set
1217 
1218@exception JMSException if the JMS provider fails to set the property
1219                         due to some internal error.
1220@exception MessageNotWriteableException if properties are read-only
1221      */

1222    public void setLongProperty(String JavaDoc name, long value)
1223        throws JMSException JavaDoc
1224    {
1225        checkWritable();
1226        propertiesToClasses.put(name,Long JavaDoc.class);
1227        properties.put(name,Long.toString(value));
1228    }
1229
1230    /** Sets a <CODE>float</CODE> property value with the specified name into
1231the message.
1232 
1233@param name the name of the <CODE>float</CODE> property
1234@param value the <CODE>float</CODE> property value to set
1235 
1236@exception JMSException if the JMS provider fails to set the property
1237                         due to some internal error.
1238@exception MessageNotWriteableException if properties are read-only
1239      */

1240    public void setFloatProperty(String JavaDoc name, float value)
1241        throws JMSException JavaDoc
1242    {
1243        checkWritable();
1244        propertiesToClasses.put(name,Float JavaDoc.class);
1245        properties.put(name,Float.toString(value));
1246    }
1247
1248    /** Sets a <CODE>double</CODE> property value with the specified name into
1249the message.
1250 
1251@param name the name of the <CODE>double</CODE> property
1252@param value the <CODE>double</CODE> property value to set
1253 
1254@exception JMSException if the JMS provider fails to set the property
1255                         due to some internal error.
1256@exception MessageNotWriteableException if properties are read-only
1257      */

1258    public void setDoubleProperty(String JavaDoc name, double value)
1259        throws JMSException JavaDoc
1260    {
1261        checkWritable();
1262        propertiesToClasses.put(name,Double JavaDoc.class);
1263        properties.put(name,Double.toString(value));
1264    }
1265
1266    /** Sets a <CODE>String</CODE> property value with the specified name into
1267the message.
1268<p>
1269@param name the name of the <CODE>String</CODE> property
1270@param value the <CODE>String</CODE> property value to set
1271 
1272@exception JMSException if the JMS provider fails to set the property
1273                         due to some internal error.
1274@exception MessageNotWriteableException if properties are read-only
1275      */

1276    public void setStringProperty(String JavaDoc name, String JavaDoc value)
1277        throws JMSException JavaDoc
1278    {
1279        checkWritable();
1280        if(value==null)
1281            {
1282                throw new SomniMessageFormatException("value can not be null");
1283            }
1284        propertiesToClasses.put(name,String JavaDoc.class);
1285        properties.put(name,value);
1286    }
1287
1288    /** Sets a Java object property value with the specified name into the
1289message.
1290 
1291<P>Note that this method works only for the objectified primitive
1292object types (<CODE>Integer</CODE>, <CODE>Double</CODE>,
1293<CODE>Long</CODE> ...) and <CODE>String</CODE> objects.
1294 
1295@param name the name of the Java object property
1296@param value the Java object property value to set
1297 
1298@exception JMSException if the JMS provider fails to set the property
1299                         due to some internal error.
1300@exception MessageFormatException if the object is invalid
1301@exception MessageNotWriteableException if properties are read-only
1302      */

1303    public void setObjectProperty(String JavaDoc name, Object JavaDoc value)
1304        throws JMSException JavaDoc
1305    {
1306        checkWritable();
1307        if(!PROPERTYCLASSES.contains(value.getClass()))
1308            {
1309                throw new SomniMessageFormatException("value's class can not be "+value.getClass()+", and must be one of "+PROPERTYCLASSES);
1310            }
1311        propertiesToClasses.put(name,value.getClass());
1312        properties.put(name,value.toString());
1313    }
1314
1315    /**
1316Acknowledges all consumed messages of the session of this consumed
1317message.
1318 
1319<P>All consumed JMS messages support the <CODE>acknowledge</CODE>
1320method for use when a client has specified that its JMS session's
1321consumed messages are to be explicitly acknowledged. By invoking
1322<CODE>acknowledge</CODE> on a consumed message, a client acknowledges
1323all messages consumed by the session that the message was delivered to.
1324
1325<P>Calls to <CODE>acknowledge</CODE> are ignored for both transacted
1326sessions and sessions specified to use implicit acknowledgement modes.
1327<p>
1328<P>A client may individually acknowledge each message as it is consumed,
1329or it may choose to acknowledge messages as an application-defined group
1330(which is done by calling acknowledge on the last received message of the group,
1331 thereby acknowledging all messages consumed by the session.)
1332<p>
1333<P>Messages that have been received but not acknowledged may be
1334redelivered.
1335<p>
1336@exception JMSException if the JMS provider fails to acknowledge the
1337                        messages due to some internal error.
1338@exception IllegalStateException if this method is called on a closed
1339                        session.
1340<p>
1341@see javax.jms.Session#CLIENT_ACKNOWLEDGE
1342      */

1343    public void acknowledge()
1344        throws JMSException JavaDoc
1345    {
1346        synchronized(guard)
1347        {
1348            //todo if we're in CLIENT_ACKNOWLEDGE mode, then the consumer will have been set. Otherwise, not. Yuck. Rethink this
1349
if(consumer!=null)
1350            {
1351                consumer.acknowledge();
1352            }
1353            else
1354            {
1355                //todo if things aren't set right, I'd like to be able to log a warning. But consumer==null isn't an error condition for AUTOACKNOWLDGE.
1356
// SomniLogger.IT.warning("Something called acknowledge while consumer==null");
1357
}
1358        }
1359    }
1360
1361    /**
1362Clears out the message body. Clearing a message's body does not clear
1363its header values or property entries.
1364<p>
1365<P>If this message body was read-only, calling this method leaves
1366the message body in the same state as an empty body in a newly
1367created message.
1368<p>
1369@exception JMSException if the JMS provider fails to clear the message
1370                        body due to some internal error.
1371      */

1372    public void clearBody()
1373        throws JMSException JavaDoc
1374    {
1375        synchronized(guard)
1376            {
1377                readOnly=false;
1378            }
1379    }
1380
1381
1382    //Somnifugi-only methods
1383
void checkWritable()
1384        throws MessageNotWriteableException JavaDoc
1385    {
1386        synchronized(guard)
1387            {
1388                if(readOnly)
1389                    {
1390                        throw new MessageNotWriteableException JavaDoc("Don't call mutators on SomniMessages after they have been sent.");
1391                    }
1392            }
1393    }
1394
1395    void setReadOnly()
1396    {
1397        synchronized(guard)
1398            {
1399                readOnly=true;
1400            }
1401    }
1402
1403    boolean getReadOnly()
1404    {
1405        synchronized(guard)
1406            {
1407                return readOnly;
1408            }
1409    }
1410
1411    Map JavaDoc<String JavaDoc,Object JavaDoc> getProperties()
1412    {
1413        synchronized(guard)
1414        {
1415            return properties;
1416        }
1417    }
1418
1419    private Map JavaDoc<String JavaDoc,Class JavaDoc> getPropertiesToClasses()
1420    {
1421        synchronized(guard)
1422        {
1423            return propertiesToClasses;
1424        }
1425    }
1426
1427    /**
1428    Make a copy of this message appropriate for the copyMode from SomniProperties.
1429    */

1430    public SomniMessage copy(String JavaDoc copyMode)
1431    {
1432        try
1433        {
1434            //only if we're in shallow copy mode, shallow copy message
1435
if (SomniProperties.SHALLOWCOPY.equals(copyMode))
1436            {
1437                return shallowCopy();
1438            }
1439            //only if we're in deep copy mode, deep copy message
1440
if (SomniProperties.DEEPCOPY.equals(copyMode))
1441            {
1442                return deepCopy();
1443            }
1444            return this;
1445        }
1446        catch(JMSException JavaDoc jmse)
1447        {
1448            throw new SomniRuntimeException("Can not copy message.",jmse);
1449        }
1450    }
1451    
1452    
1453    /**
1454Create a shallow copy of this message. Override this method if you extend this class to call your own copy constructor.
1455    */

1456    //todo make this private
1457
protected SomniMessage shallowCopy()
1458        throws JMSException JavaDoc
1459    {
1460        synchronized(guard)
1461        {
1462            return new SomniMessage(this,false);
1463        }
1464    }
1465
1466    /**
1467Create a deep copy of this message. Override this method if you extend this class to call your own copy constructor.
1468    */

1469    //todo make this private
1470
protected SomniMessage deepCopy()
1471        throws JMSException JavaDoc
1472    {
1473        synchronized(guard)
1474        {
1475            return new SomniMessage(this,true);
1476        }
1477    }
1478
1479    /**
1480Used to set the consumer of the message after it arrives, to support client acknowledgement.
1481    */

1482    void setConsumer(SomniMessageConsumer consumer)
1483    {
1484        synchronized(guard)
1485        {
1486            this.consumer = consumer;
1487        }
1488    }
1489
1490    //logging override
1491
public String JavaDoc toString()
1492    {
1493        synchronized(guard)
1494            {
1495                StringBuffer JavaDoc buffy = new StringBuffer JavaDoc();
1496                buffy.append(getClass().getName());
1497                buffy.append(":");
1498                buffy.append(messageID);
1499                buffy.append(" ts:"+timeStamp);
1500                if(correlationID!=null)
1501                    {
1502                        buffy.append(" correlationID:");
1503                        buffy.append(correlationID);
1504                    }
1505                if(replyTo!=null)
1506                    {
1507                        buffy.append(" replyTo:");
1508                        buffy.append(replyTo.toString());
1509                    }
1510                if(destination!=null)
1511                    {
1512                        buffy.append(" destination:");
1513                        buffy.append(destination.toString());
1514                    }
1515                buffy.append(" deliveryMode:");
1516                buffy.append(deliveryMode);
1517                if(expirationTime!=0)
1518                    {
1519                        buffy.append(" expirationTime:"+expirationTime);
1520                    }
1521                if(priority!=0)
1522                    {
1523                        buffy.append(" priority:"+priority);
1524                    }
1525                if(producerCount!=Integer.MIN_VALUE)
1526                    {
1527                        buffy.append(" producerCount:"+producerCount);
1528                    }
1529                if(producerConnectionClientID!=null)
1530                    {
1531                        buffy.append(" producerConnectionClientID:"+producerConnectionClientID);
1532                    }
1533                if(readOnly)
1534                    {
1535                        buffy.append(" readOnly");
1536                    }
1537                if(redelivered)
1538                    {
1539                        buffy.append(" redelivered");
1540                    }
1541                return buffy.toString();
1542            }
1543    }
1544}
1545
1546/* Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 David Walend
1547All rights reserved.
1548
1549Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1550
1551Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
1552
1553Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
1554
1555Neither the name of the SomnifugiJMS Project, walend.net, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission from David Walend.
1556
1557Credits in redistributions in source or binary forms must include a link to http://somnifugi.sourceforge.net .
1558
1559THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1560The net.walend.somnifugi.sql92 package is modified code from the openmq project, https://mq.dev.java.net/ , Copyright (c) of Sun, and carries the CDDL license, repeated here: You can obtain a copy of the license at https://glassfish.dev.java.net/public/CDDLv1.0.html. See the License for the specific language governing permissions and limitations under the License.
1561
1562=================================================================================
1563
1564For more information and the latest version of this software, please see http://somnifugi.sourceforge.net and http://walend.net or email <a HREF="mailto:david@walend.net">david@walend.net</a>.
1565 */

1566
Popular Tags