Unused beans on a spring context

340 views
Skip to first unread message

Cayetano

unread,
Mar 6, 2012, 4:34:40 AM3/6/12
to Beanoh
Hi,

While searching "how to find unused spring beans on a context" I
spotted this project Beanoh, which it can be used to assert Spring
context, it looks very interesting and promising, kudos!

The point is that I'm on a legacy project with many beans defined, and
I want to get rid of those one that are no longer in use, and before
doing the try and error method, I wanted to check if there's anything
existing, that load an application context, and return all those beans
that are not referenced from any other bean.
As far I can understand, that's not the purpose of Beanoh, but wanted
to ask you if you know something about, or maybe a plugin for Sonar.
Or even better, if you consider this feature useful to be included on
Beanoh :)

Cheers!
Cayetano

David Kessler

unread,
Mar 8, 2012, 3:56:45 PM3/8/12
to Beanoh
This is a great question. What do you mean by the word "unused"? I
can think of a few scenarios off the top of my head:
- A bean that is defined but never injected.
- A bean that is injected but is never called in the code.
- A bean that is defined but never loaded into the Spring context.

Each of these scenarios are quite different and require different
solutions. Please describe the problem that you're trying to solve.
Thank you.

J. Cayetano

unread,
Mar 9, 2012, 3:48:29 AM3/9/12
to bea...@googlegroups.com
Hi David, thanks for replying.

I think the second one fits better with what I'm more interested.
In summary, the project we're working on it was originally based on
Spring 2.0, so an architecture of beans defined on several XML context
files, and new development, which is adding more Spring 3.x code with
annotations. As we've done lot of refactors and have a good coverage
on functional testing, I think the best will be verify which or those
defined beans on XML/Annotations, are never called, even if they are
injected.

Hope it helps now,
Cheers

--
Cayetano

David Kessler

unread,
Apr 4, 2012, 9:19:57 PM4/4/12
to Beanoh
Sorry for the delayed response. Beanoh is not designed to identify
unused code. Take a look at http://pmd.sourceforge.net/ and/or
http://emma.sourceforge.net/. Good luck.

On Mar 9, 3:48 am, "J. Cayetano" <juancayetano.delg...@gmail.com>
wrote:

J. Cayetano

unread,
Apr 5, 2012, 2:23:37 AM4/5/12
to bea...@googlegroups.com
Hi David,

Yes, I'm familiar with PMD and EMMA, but my intention was more about
unused Spring beans, nor unused code.

Thanks anyway! :)

--
Cayetano

Biswajit Purkayastha

unread,
May 12, 2014, 7:27:13 AM5/12/14
to bea...@googlegroups.com, juancayeta...@gmail.com
Hi Cayetano,

Me 2 looking to do same,
did u find any proper solution.
I was looking at different methods in application context and different listener but could not figure out any yet
Reply all
Reply to author
Forward
0 new messages