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

  • SEARCH
  • Home
  • 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 8453425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:46:16+00:00 2026-06-10T11:46:16+00:00

I have a bunch of projects which declare some spring bean files. I would

  • 0

I have a bunch of projects which declare some spring bean files. I would like to write a “library” which supplies a utility which takes some bean names and adds some behaviour “around” the objects (example: Call Counting, Monitoring, Logging etc)

One obvious way for doing this would be to add some AspectJ annotations in the spring xml files in the projects but I would like the “utility” to search for some beans and add behaviour to them (This way the projects themselves are not aware of the utility).

The utility will be declared in the spring xml file somewhere so it has access to the ApplicationContext as it could implement ApplicationContextAware interface however I am keen on exploring how one would go about modifying behaviour of another bean in the app context programmatically. ex, something like find a bean of id “OrderService”, create an aspected bean with some monitoring/call counting etc around all methods and replace that bean in the application context for “OrderService”

I know there are disadvantages with this approach but what I am after is “IS it possible to do this? And if yes how?”

  • 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-10T11:46:18+00:00Added an answer on June 10, 2026 at 11:46 am

    If you don’t want to use AOP, you can achieve this using a BeanPostProcessor. The Spring documentation states:

    The BeanPostProcessor interface defines callback methods that you can
    implement to provide your own (or override the container’s default)
    instantiation logic, dependency-resolution logic, and so forth. If you
    want to implement some custom logic after the Spring container
    finishes instantiating, configuring, and otherwise initializing a
    bean, you can plug in one or more BeanPostProcessor implementations.

    So you may create and register a BeanPostProcessor and implement the postProcessAfterInitialization(Object bean, String beanName) method to modify the methods you want to customize. Here is an example.

    (But I would still recommend that you do this with AOP as this is the classical use case for it and it’s much easier and more declarative. With the bean() pointcut, you can even advise beans with names matching a certain pattern.)

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

Sidebar

Related Questions

I have bunch of strings, some of which are fairly long, like so: movie.titles
I have a whole bunch of projects which I want to reuse between the
Suppose that you have a bunch of projects in your Eclipse workspace. Some are
I have a bunch of projects which have a similar architecture... A----1 Y \
I have a big VS2010 solution, which contains a bunch of C# projects. One
I have a bunch of ant projects that build plug-ins that all conform to
I have a whole bunch of mavenised projects, and I want to check that
I have a workspace with a bunch of java projects. If I go to
I have bunch of lists like this: out[3] [[3]] [1] forum=28&mid=11883 [2] forum=29&mid=11884 out[4]
Background I have a bunch of students, their desired projects and the supervisors for

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.