Announcement Announcement Module
No announcement yet.
What can be injected using Spring? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • What can be injected using Spring?

    I am new to Spring and hence the question. I have some MDBs (inherited ones) that have a lot of business logic and am trying to move them out of the MDBs to POJOs. Now, what is the best way to do this using Spring (considering the project uses Spring heavily)? In the non-Spring world, I would have created a new class and simply forwarded the request to that class by creating an object of that class and passing all the dynamic values (coming to the MDB) as arguments. But, I know that I should use a Spring bean and injection in this case, but since these arguments are ofcourse not static values (and derived from some other objects passed to the MDB), is there anyway I can do this differently from the usual case? Or, should I simply get a Spring bean for my new class and manually call some setter methods to set these values?


  • #2
    It sounds like you are looking to replace your MDB's with message-driven POJOs, documented here:


    • #3
      Yes, that looks like it, except that the example wasn't very clear to me. There needs to be a call to some POJO from the onMessage() API, isn't it? It appears that the class that contains this API is referred to as a POJO here.. Basically, given the way it is in the example, I still can't see how it can unit tested...


      • #4
        Its arguable that an object which implements MessageListener isn't a POJO. But POJOs do implement interfaces, so its not really a big deal. The difference between an MDB and MDP implementing MessageListener is that an MDB has the EJB overhead, the MDP doesn't.

        You can also have an adapter class unwrap the javax.jms.Message and invoke a non-interface method on your POJO. That should be covered in the reference guide section mentioned.