Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8250333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:51:20+00:00 2026-06-07T23:51:20+00:00

I inherited a codebase that offers similar services over two channels: REST/HTTP – handled

  • 0

I inherited a codebase that offers similar services over two channels:

  1. REST/HTTP – handled by annotated Spring controller
  2. JMS – handled by a Message Driven POJO

Message structure on both channels is more or less similar, so there is a lot of redundant/duplicate processing logic in controller and JMS listener. One way to fix that is to extract common logic into another component and inject that component into both @Controller and JMS listener.

Lets say I don’t have time to do that for now. Is there a way I could inject controller into JMS listener and call the same controller methods that are automatically invoked by Spring’s dispatcher servlet when a REST request arrives. Since there is no XML configuration for controller, how can I get its reference for injection into JMS listener? I don’t want to create another controller bean with a different ‘id’.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T23:51:22+00:00Added an answer on June 7, 2026 at 11:51 pm

    One way to fix that is to extract common logic

    It is not “one way“, it is the only way. Not only because injecting controller into JMS message listener is one of the most awkward things you can do you to your architecture. But also because Spring itself will not let you do this.

    In Spring MVC there are actually two contexts: main one (where JMS listeners are declared) and DispatcherServlet (MVC) context. The latter is a child of the former which means it can access beans from main context (otherwise it wouldn’t be possible to access services and DAOs in controllers), but not the other way around.

    Lets say I don’t have time to do that for now

    The fact that your current architecture is rather poor does not justify making it much worse. Probably some developer in the past had no time to extract common logic, hence the duplication. Now you want to introduce very unusual dependency from JMS layer to web layer… I would rather live with duplication.

    Since there is no XML configuration for controller, how can I get its reference

    Just for the record, if your controller is named FooBarController, this:

    @Resource
    private FooBarController fooBarController;
    

    might work, but fortunately not from parent to child context.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have inherited a DotNetNuke codebase and have come across areas that have included
Background: Many years ago, I inherited a codebase that was using the Visual Studio
I got a line in the codebase that I inherited and it goes like
A site heavily using a main iframe I inherited a legacy codebase/website, http://ninjawars.net .
I've inherited a large C++ codebase for several Windows applications that successfully is in
Let's say you've inherited a C# codebase that uses one class with 200 static
I just inherited an existing codebase that has multiple configuration files in it. These
am not a ruby programmer, have to maintain a codebase that i inherited, pardon
I've inherited a long term maintenance code base that has two radically different iPhone
I inherited a shell-script application that is a combination of kshell scripts, awk, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.