Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

[SPR-10412] Support generics in JmsTemplate #266

Open
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
Contributor

marschall commented Mar 24, 2013

The #convertAndSend and #receiveAndConvert methods and the
MessageConverter interface currently are not type safe. Everywhere
Object is passed around casts have to be made.

This pull request tries to address the issue by:

  • split MessageConverter into two interfaces, MessageDecoder and
    MessageEncoder so that Java 8 lambdas can be used
  • add generics to MessageConverter, MessageDecoder and
    MessageEncoder
  • for every #convertAndSend method add a new one that has a
    MessageEncoder as a second argument
  • for every #receiveAndConvert method add a new one that
    has a MessageDecoder as a second argument
  • add generics to the new #convertAndSend and
    #receiveAndConvert methods

MessageConverter and MessageDecoder are not be best names but the best
ones I could come up with.

Maybe MessageConverter and MessageDecoder should be annotated with
java.lang.FunctionalInterface but this would have to be done over the
entire code base eg. org.springframework.jdbc.core.RowMapper.

As usual, I'm not one hundred percent certain when it comes to wild
cards.

And tests are missing.

Issue: SPR-10412
https://jira.springsource.org/browse/SPR-10412

@marschall marschall [SPR-10412] Support generics in JmsTemplate
The `#convertAndSend` and `#receiveAndConvert` methods and the
`MessageConverter` interface currently are not type safe. Everywhere
`Object` is passed around casts have to be made.

This pull request tries to address the issue by:

 - split `MessageConverter` into two interfaces, `MessageDecoder` and
   `MessageEncoder` so that Java 8 lambdas can be used

 - add generics to `MessageConverter`, `MessageDecoder` and
   `MessageEncoder`

 - for every `#convertAndSend` method add a new one that has a
  `MessageEncoder` as a second argument

 - for every `#receiveAndConvert` method add a new one that
   has a `MessageDecoder` as a second argument

 - add generics to the new `#convertAndSend` and
  `#receiveAndConvert` methods

MessageConverter and MessageDecoder are not be best names but the best
ones I could come up with.

Maybe `MessageConverter` and `MessageDecoder` should be annotated with
`java.lang.FunctionalInterface` but this would have to be done over the
entire code base eg. `org.springframework.jdbc.core.RowMapper`.

As usual, I'm not one hundred percent certain when it comes to wild
cards.

And tests are missing.

Issue: SPR-10412
https://jira.springsource.org/browse/SPR-10412
4e3ecd9

@ghost ghost assigned jhoeller Mar 25, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment