jsr343-experts@jms-spec.java.net

[jsr343-experts] Re: [jms-spec users] JMSProducer#getProperyNames()

From: Nigel Deakin <nigel.deakin_at_oracle.com>
Date: Fri, 04 Jan 2013 10:57:36 +0000

Hi Philippe,

On 03/01/2013 22:14, Philippe Marschall wrote:
> Hi
>
> Why is the return type of JMSProducer#getProperyNames() a raw (!)
> Enumeration instead of a Set<String>?

Good question. This method (and many other methods on JMSProducer) is
simply a copy of the corresponding method on Message. And
Message#getPropertyNames returns a "raw" Enumeration.

http://docs.oracle.com/javaee/6/api/javax/jms/Message.html#getPropertyNames%28%29

(Both methods return a collection of message property names)

Hmm. There are two issues here:

1. whether it should return an Enumeration or a Set
2. whether it should use a generic type, i.e. <String>

In general I think we should avoid try to keep the methods on
JMSProducer and Message consistent since the user will need to use both.

(The exception to this is that whereas Message has nine methods to set
properties with names like setStringProperty, setShortProperty etc,
JMSProducer has nine methods all called setProperty. So I have broken my
own "rule" in this case in order to simplify the API.)

My feeling is that returning a generic type would be a fairly
transparent improvement.

However, given that Message#getPropertyNames returns an Enumeration I
think it might be confusing if JMSProducer#getPropertyNames returns a Set.

So I suggest we change this to return an Enumeration <String>.

Comments?

Nigel